aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-11-05 15:21:18 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-11-05 15:21:18 +0100
commitaabcd0ac01339d6cb65f4b7607a697a2fe52043d (patch)
treeac274781ee0784522b59980cc536959876f03e8f
parent5249ac078b30cf04ad87ffc97fffd16231d5f525 (diff)
downloadmonitoring_custom-aabcd0ac01339d6cb65f4b7607a697a2fe52043d.tar.gz
check_systemd
-rwxr-xr-xcheck_systemd25
1 files changed, 25 insertions, 0 deletions
diff --git a/check_systemd b/check_systemd
new file mode 100755
index 0000000..b2b140c
--- /dev/null
+++ b/check_systemd
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# USAGE:
+# check_systemd [UNIT ...]
+
+FAILED=()
+
+if ! systemctl is-system-running > /dev/null; then
+ echo systemd CRITICAL: System state degraded.
+ exit 2
+fi
+
+for unit in "$@"; do
+ if ! systemctl is-active "$unit" > /dev/null; then
+ FAILED+=("$unit")
+ fi
+done
+
+if [ ${#FAILED[@]} -gt 0 ]; then
+ echo "systemd CRITICAL: failed units: ${FAILED[@]}"
+ exit 2
+fi
+
+echo "systemd OK: $# units checked"
+exit 0