Page MenuHomePhabricator
Paste P6112

(An Untitled Masterwork)
ActivePublic

Authored by awight on Oct 12 2017, 7:50 PM.
Tags
None
Referenced Files
F10166355:
Oct 12 2017, 8:16 PM
F10165831:
Oct 12 2017, 7:50 PM
Subscribers
None
PGID=29377
total_stats() {
NUM_KIDS=`ps -g $PGID | wc -l`
TOTAL_FILES=`sudo lsof -g $PGID | wc -l`
echo Running $NUM_KIDS workers with $TOTAL_FILES total open file handles.
}
# List child PIDs
child_stats() {
# Note that we're actually limiting to 10 to reduce execution time.
CHILDREN=`ps -g $PGID --no-headers | head -10 | grep -v $PGID | cut -f 1 -d " "`
for pid in $CHILDREN
do
COUNT=`sudo lsof -p $pid | wc -l`
echo Child $pid has $COUNT open file handles.
done
}
datestamp() {
echo `date -u "+%Y%m%d-%H%M%S"`
}
watch_stats_and_log() {
while true
do
FILE=file-stats-`datestamp`
date > $FILE
total_stats >> $FILE
child_stats >> $FILE
printf "\033c"
cat $FILE
sleep 15
done
}