123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!/bin/bash
-
- . $(ffoom path)
-
- ffoo import pretty
- ffoo import recon
-
- interval=2
-
- report_limits() {
- echo "ulimit -m:$(ulimit -m)"
- echo "ulimit -Sm:$(ulimit -Sm)"
- echo "ulimit -Hm:$(ulimit -Hm)"
- echo "ulimit -n:$(ulimit -n)"
- echo "ulimit -Sn:$(ulimit -Sn)"
- echo "ulimit -Hn:$(ulimit -Hn)"
- }
-
- report_on_pids() {
- local pid
- for pid in "$@";
- do
- echo "$pid:name:$(ps -p $pid -o comm=)"
- echo "$pid:rss:$(ps -p $pid -o rss=)"
- echo "$pid:files:$(lsof -p $pid | wc -l)"
- done
- }
-
- usage() {
- usage_is "[-i INTERVAL] [-d] -p PID[,PID]..." \
- "[-i INTERVAL] [-d] -r REGEX[,REGEX]..."
- }
-
- regexes=""
- pids=""
-
- while true;
- do
- case $1 in
- -i|--interval)
- interval=$2
- shift 2
- ;;
- -r|--regexes)
- regexes=$2
- shift 2
- ;;
- -p|--pids)
- pids=$2
- shift 2
- ;;
- "")
- if test -z "$regexes" && test -z "$pids";
- then usage;
- else break;
- fi
- ;;
- *)
- usage
- ;;
- esac
- done
-
- pids=$(tr "," " " <<<"$pids")
- regexes=$(tr "," " " <<<"$regexes")
-
- report_limits
- while true;
- do
- # append PIDS from regexes to pids from command line
- current_pids="$pids $(pids_matching $regexes)"
- debug -v current_pids
- report_on_pids $current_pids
- sleep $interval
- done
|