Switch from colons to hyphens

This commit is contained in:
Salt 2021-08-18 19:41:04 -05:00
parent 426f96839d
commit 39f9fa3dbb

View File

@ -13,40 +13,40 @@
service="$1"
# If the service is null, be critical
if [ -z "$service" ]; then
echo "UNIT CRITICAL: Service is undefined"
echo "UNIT CRITICAL - Service is undefined"
exit 1
# If systemctl is not present, be critical
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
# If the service is failed, be critical
elif systemctl is-failed --quiet "$service" > /dev/null 2>&1; then
echo "UNIT CRITICAL: $service is failed"
echo "UNIT CRITICAL - $service is failed"
exit 2
# Otherwise, see what its state is
else
systemctl status "$service" > /dev/null 2>&1
case $? in
0)
echo "UNIT OK: $service is running"
echo "UNIT OK - $service is running"
exit 0
;;
1|2)
echo "UNIT CRITICAL: $service is dead"
echo "UNIT CRITICAL - $service is dead"
exit 3
;;
3)
# In this case, the unit is not running. Whether this is an issue depends on the type of service
if systemctl cat backup | grep -ie '^Type=' | grep -ie 'oneshot' > /dev/null 2>&1; then
echo "UNIT OK: $service is type oneshot and not running"
echo "UNIT OK - $service is type oneshot and not running"
exit 0
else
echo "UNIT CRITICAL: $service is not running"
echo "UNIT CRITICAL - $service is not running"
exit 4
fi
;;
4)
echo "UNIT CRITICAL: $service is not present on this machine"
echo "UNIT CRITICAL - $service is not present on this machine"
exit 50
;;
esac