123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. . $(ffoom path)
  3. ffoo import pretty
  4. ffoo import recon
  5. interval=2
  6. report_limits() {
  7. echo "ulimit -m:$(ulimit -m)"
  8. echo "ulimit -Sm:$(ulimit -Sm)"
  9. echo "ulimit -Hm:$(ulimit -Hm)"
  10. echo "ulimit -n:$(ulimit -n)"
  11. echo "ulimit -Sn:$(ulimit -Sn)"
  12. echo "ulimit -Hn:$(ulimit -Hn)"
  13. }
  14. report_on_pids() {
  15. local pid
  16. for pid in "$@";
  17. do
  18. echo "$pid:name:$(ps -p $pid -o comm=)"
  19. echo "$pid:rss:$(ps -p $pid -o rss=)"
  20. echo "$pid:files:$(lsof -p $pid | wc -l)"
  21. done
  22. }
  23. usage() {
  24. usage_is "[-i INTERVAL] [-d] -p PID[,PID]..." \
  25. "[-i INTERVAL] [-d] -r REGEX[,REGEX]..."
  26. }
  27. regexes=""
  28. pids=""
  29. while true;
  30. do
  31. case $1 in
  32. -i|--interval)
  33. interval=$2
  34. shift 2
  35. ;;
  36. -r|--regexes)
  37. regexes=$2
  38. shift 2
  39. ;;
  40. -p|--pids)
  41. pids=$2
  42. shift 2
  43. ;;
  44. "")
  45. if test -z "$regexes" && test -z "$pids";
  46. then usage;
  47. else break;
  48. fi
  49. ;;
  50. *)
  51. usage
  52. ;;
  53. esac
  54. done
  55. pids=$(tr "," " " <<<"$pids")
  56. regexes=$(tr "," " " <<<"$regexes")
  57. report_limits
  58. while true;
  59. do
  60. # append PIDS from regexes to pids from command line
  61. current_pids="$pids $(pids_matching $regexes)"
  62. debug -v current_pids
  63. report_on_pids $current_pids
  64. sleep $interval
  65. done