Fix me not knowing Nagios return codes

https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/pluginapi.html

The more you know
This commit is contained in:
Salt 2021-08-18 20:03:48 -05:00
parent 36e1bace98
commit 972fdaf614
1 changed files with 5 additions and 5 deletions

View File

@ -14,11 +14,11 @@ service="$1"
# If the service is null, be critical
if [ -z "$service" ]; then
echo "UNIT CRITICAL - Service is undefined"
exit 1
exit 2
# If systemctl is not present, be critical
elif ! command -v systemctl > /dev/null 2>&1; then
echo "UNIT CRITICAL - systemctl missing from PATH"
exit 1
exit 2
# If the service is failed, be critical
elif systemctl is-failed --quiet "$service" > /dev/null 2>&1; then
echo "UNIT CRITICAL - $service is failed"
@ -33,7 +33,7 @@ else
;;
1|2)
echo "UNIT CRITICAL - $service is dead"
exit 3
exit 2
;;
3)
# In this case, the unit is not running. Whether this is an issue depends on the type of service
@ -42,12 +42,12 @@ else
exit 0
else
echo "UNIT CRITICAL - $service is not running"
exit 4
exit 2
fi
;;
4)
echo "UNIT CRITICAL - $service is not present on this machine"
exit 50
exit 2
;;
esac
fi