You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Princeton/pu/libexec/eventhandlers/cp_restart

51 lines
860 B
Bash

#!/bin/bash
if [[ "$#" -ne "6" ]]; then
echo "Usage: $0 "'"$HOSTNAME$" "$SERVICENAME$" $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ "$SERVICEOUTPUT$"'
exit 1
fi
hname="$1"
sname="$2"
sstate="$3"
stype="$4"
sattempt="$5"
sout="$6"
case $sstate in
OK) # Recovery
exit 0
;;
WARNING)
;;
CRITICAL)
case $sattempt in
2)
res=`/usr/local/monitoring/princeton/clearpass_restart "$hname" 2>&1`
stat=$?
echo "$(date): $res" >> /usr/local/monitoring/log/clearpass_restart
echo "$res" | mail -s "ClearPass services restarted by monitoring on $hname" dw10@Princeton.EDU drinker@Princeton.EDU igubenko@Princeton.EDU
exit $stat
;;
*)
# Do nothing - too early to do anything
;;
esac
;;
UNKNOWN)
echo "Service state is unknown"
exit 1
;;
*)
echo "Invalid service state passed"
exit 1
;;
esac
exit 0