keepalived: change exit code (warning if runnin but not on expected state ; critical if not running)
All checks were successful
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
Jérémy Dubois 2022-11-28 17:16:28 +01:00
parent c96f28e47b
commit cd2c1931b1
2 changed files with 16 additions and 12 deletions

View file

@ -40,6 +40,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
* squid: whitelist deb.freexian.com * squid: whitelist deb.freexian.com
* varnish: better package facts usage with check mode and tags * varnish: better package facts usage with check mode and tags
* varnish: systemd override depends on Varnish version instead of Debian version * varnish: systemd override depends on Varnish version instead of Debian version
* keepalived: change exit code (warning if runnin but not on expected state ; critical if not running)
### Fixed ### Fixed

View file

@ -18,35 +18,38 @@ MASTER='true'
# checking if there are alive keepalived processes so we can trust the content of the notify 'state' file # checking if there are alive keepalived processes so we can trust the content of the notify 'state' file
KEEPALIVENUM=`ps uax|grep '/usr/sbin/keepalived'|grep -v grep|wc -l|tr -d "\n"` KEEPALIVENUM=`ps uax|grep '/usr/sbin/keepalived'|grep -v grep|wc -l|tr -d "\n"`
if [ $KEEPALIVENUM -gt 0 ]; then if [ ${KEEPALIVENUM} -gt 0 ]; then
KEEPALIVESTATE=`cat /var/run/keepalive.state` KEEPALIVESTATE=`cat /var/run/keepalive.state`
if [ "$MASTER" == "true" ]; then if [ "${MASTER}" == "true" ]; then
if [[ $KEEPALIVESTATE == *"MASTER"* ]];then if [[ ${KEEPALIVESTATE} == *"MASTER"* ]];then
echo $KEEPALIVESTATE echo "OK - ${KEEPALIVESTATE}"
exit 0 exit 0
fi fi
if [[ $KEEPALIVESTATE == *"BACKUP"* ]];then if [[ ${KEEPALIVESTATE} == *"BACKUP"* ]];then
echo $KEEPALIVESTATE echo "WARNING - ${KEEPALIVESTATE}"
exit 2 exit 1
fi fi
else else
if [[ $KEEPALIVESTATE == *"BACKUP"* ]];then if [[ ${KEEPALIVESTATE} == *"BACKUP"* ]];then
echo $KEEPALIVESTATE echo "OK - ${KEEPALIVESTATE}"
exit 0 exit 0
fi fi
if [[ $KEEPALIVESTATE == *"MASTER"* ]];then if [[ ${KEEPALIVESTATE} == *"MASTER"* ]];then
echo $KEEPALIVESTATE echo "WARNING - ${KEEPALIVESTATE}"
exit 2 exit 1
fi fi
fi fi
else
echo "CRITICAL - keepalived is not running"
exit 2
fi fi
echo "Keepalived is in UNKNOWN state" echo "Keepalived is in UNKNOWN state"