Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- BSDCFG_SHARE="/usr/share/bsdconfig"
- . "$BSDCFG_SHARE/common.subr" || exit 1
- f_include "$BSDCFG_SHARE/strings.subr"
- PIDS= pidcmd_list=
- exec <<EOI
- $( ps ax -o pid= -o ucomm= )
- EOI
- while read pid ucomm; do
- { f_which "$ucomm" pidcmd && [ -r "$pidcmd" ]; } || continue
- PIDS="$PIDS $pid"
- setvar pidcmd_$pid "$pidcmd"
- done
- exec <<EOI
- $( ps -o pid= -o lstart= -p $PIDS )
- EOI
- while read pid lstart; do
- setvar piddate_$pid "$( date -j -f %c "$lstart" +%s )"
- done
- for pid in $PIDS; do
- f_getvar pidcmd_$pid pidcmd
- f_shell_escape "$pidcmd" _pidcmd
- pidcmd_list="$pidcmd_list '$_pidcmd'"
- done
- exec <<EOI
- $( eval stat -f %m $pidcmd_list )
- EOI
- set -- $PIDS
- while read ondiskdate rest_ignored; do
- [ "$1" ] || break
- setvar ondiskdate_$1 "$ondiskdate"
- shift 1 # pid
- done
- for pid in $PIDS; do
- f_getvar ondiskdate_$pid ondiskdate &&|| continue
- f_getvar piddate_$pid piddate || continue
- f_getvar pidcmd_$pid pidcmd || continue
- echo "Comparing $ondiskdate and $piddate for pid $pid $pidcmd"
- [ $ondiskdate -gt $piddate ] &&
- echo "ALERT! $ondisk needs to be reloaded!"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement