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:
parent
36e1bace98
commit
972fdaf614
@ -14,11 +14,11 @@ service="$1"
|
|||||||
# If the service is null, be critical
|
# If the service is null, be critical
|
||||||
if [ -z "$service" ]; then
|
if [ -z "$service" ]; then
|
||||||
echo "UNIT CRITICAL - Service is undefined"
|
echo "UNIT CRITICAL - Service is undefined"
|
||||||
exit 1
|
exit 2
|
||||||
# If systemctl is not present, be critical
|
# If systemctl is not present, be critical
|
||||||
elif ! command -v systemctl > /dev/null 2>&1; then
|
elif ! command -v systemctl > /dev/null 2>&1; then
|
||||||
echo "UNIT CRITICAL - systemctl missing from PATH"
|
echo "UNIT CRITICAL - systemctl missing from PATH"
|
||||||
exit 1
|
exit 2
|
||||||
# If the service is failed, be critical
|
# If the service is failed, be critical
|
||||||
elif systemctl is-failed --quiet "$service" > /dev/null 2>&1; then
|
elif systemctl is-failed --quiet "$service" > /dev/null 2>&1; then
|
||||||
echo "UNIT CRITICAL - $service is failed"
|
echo "UNIT CRITICAL - $service is failed"
|
||||||
@ -33,7 +33,7 @@ else
|
|||||||
;;
|
;;
|
||||||
1|2)
|
1|2)
|
||||||
echo "UNIT CRITICAL - $service is dead"
|
echo "UNIT CRITICAL - $service is dead"
|
||||||
exit 3
|
exit 2
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
# In this case, the unit is not running. Whether this is an issue depends on the type of service
|
# 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
|
exit 0
|
||||||
else
|
else
|
||||||
echo "UNIT CRITICAL - $service is not running"
|
echo "UNIT CRITICAL - $service is not running"
|
||||||
exit 4
|
exit 2
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
echo "UNIT CRITICAL - $service is not present on this machine"
|
echo "UNIT CRITICAL - $service is not present on this machine"
|
||||||
exit 50
|
exit 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user