From 972fdaf614b406cf0a3390d2c6d0806d9214c570 Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Wed, 18 Aug 2021 20:03:48 -0500
Subject: [PATCH] Fix me not knowing Nagios return codes

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

The more you know
---
 check_systemd_unit | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/check_systemd_unit b/check_systemd_unit
index 85a108a..289c640 100755
--- a/check_systemd_unit
+++ b/check_systemd_unit
@@ -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