Check processes
Zur Navigation springen
Zur Suche springen
#!/bin/bash
function check_pgrep()
{
for PROC in $PROCS
do
PROCID=$(pgrep -x $PROC | head -1)
if test -z "$PROCID"
then
ERRLIST="$ERRLIST $PROC"
fi
done
if [[ -n $ERRLIST ]]
then
echo "MISSING:$ERRLIST"
exit 2
else
echo "OK: $PROCS"
fi
}
test "$#" -ne "2" && { echo not enough arguments ; exit 1 ; }
while getopts p: opt
do
case $opt in
p) PROCS=$OPTARG;;
?) echo "USAGE: $0 -p PROC"; exit 2 ;;
esac
done
if test -n "$PROCS"
then
check_pgrep
else
echo "no proc argument"
exit 1
fi