]> git.michaelhowe.org Git - packages/n/nagios-plugins-local.git/commitdiff
Add check_systemd plugin
authorMichael Howe <michael@michaelhowe.org>
Fri, 28 Apr 2017 22:53:33 +0000 (23:53 +0100)
committerMichael Howe <michael@michaelhowe.org>
Fri, 28 Apr 2017 22:53:33 +0000 (23:53 +0100)
Very simple - checks the is-system-running output

debian/changelog
debian/nagios-plugins-local-client.install
plugins/check_systemd [new file with mode: 0755]

index 8c5a6ef0221092c2560d3621803a5027369aba26..1ab025872a1a75cd558c689162ccaef1b9e51ad0 100644 (file)
@@ -1,10 +1,11 @@
-nagios-plugins-local (0.14~test.2) UNRELEASED; urgency=low
+nagios-plugins-local (0.14~test.3) UNRELEASED; urgency=low
 
   * nagios-plugins-local-server:
     - new plugin: check_mqtt 
     - fix dependency
   * nagios-plugins-local-client:
     - new plugin: check_iostat
+    - new plugin: check_systemd
 
  -- Michael Howe <michael@michaelhowe.org>  Mon, 21 Dec 2015 21:15:56 +0000
 
index d29b8f6a83481593089b6ddd31cd4aec2e352a50..dba27fe05a2bec0254aefa38244c38eb2e2879cc 100644 (file)
@@ -2,3 +2,4 @@
 /usr/lib/nagios/plugins/check_configtool
 /usr/lib/nagios/plugins/check_md_raid
 /usr/lib/nagios/plugins/check_iostat
+/usr/lib/nagios/plugins/check_systemd
diff --git a/plugins/check_systemd b/plugins/check_systemd
new file mode 100755 (executable)
index 0000000..fa16cf1
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+STATE=$(systemctl is-system-running)
+
+if [ "$STATE" == "running" ]; then
+    echo "systemd running"
+    exit 0
+else
+    echo -n "systemd in state $STATE - failed units: "
+    systemctl list-units --state=failed | awk '/ failed / {print $2}' | tr '\n' ' '
+    exit 2
+fi
+
+# if we've got this far, we don't know what state we're in
+exit 3