forked from djones6/Swift-Bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitorRSS.sh
executable file
·38 lines (33 loc) · 892 Bytes
/
monitorRSS.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
# Simple script to capture resident set and virtual size of a process (as reported by 'ps')
# periodically, to monitor process footprint over time.
# Kitura zombie process causes problems here... an alternative (get the RSS from one of the threads)
# would be:
# ps -p <pid> -L -o pid,ppid,tid,time,rss,cmd
# or:
# ps -p <pid> -L -o rss,vsz
PID=$1
INTERVAL=$2
if [ -z "$INTERVAL" ]; then
echo "Usage: monitorRSS <pid> <interval>"
exit 1
fi
# Need to use different options to extract the RSS from Kitura on Linux, as (currently)
# the process gets marked as 'defunct' and the information is only reported against the
# other application threads.
case `uname` in
Linux)
#fix for Kitura:
PS_OPTS="-L -o rss,vsz"
;;
Darwin)
PS_OPTS="-o rss,vsz"
;;
*)
echo "Unknown OS '`uname`'"
exit 1
esac
while true; do
ps -p $PID $PS_OPTS | tail -n 1
sleep $INTERVAL
done