12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #!/bin/bash
-
- . <(ffoom init)
- FFOO_INI_PATH="__FFOO_INI_PATH__"
-
- ffoo import core
- ffoo import recon
-
- FFOO_DEBUG=false
-
- 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
- ;;
- -d|--debug)
- FFOO_DEBUG=true
- shift 1
- ;;
- -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
|