aboutsummaryrefslogtreecommitdiff
path: root/modules/pkgs/check_systemd/check_systemd
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2016-09-29 13:51:44 +0300
committerIgor Pashev <pashev.igor@gmail.com>2016-09-29 13:51:44 +0300
commit62f28d30a069135f9c48678507203958adfc334f (patch)
tree7f38af0c8d3f445ee8cc50906a639baec7011127 /modules/pkgs/check_systemd/check_systemd
parent1af9e6589bdd18e6ba7eeabf073aa7d710020cdd (diff)
downloadnixsap-62f28d30a069135f9c48678507203958adfc334f.tar.gz
Moved everything into ./modules
Diffstat (limited to 'modules/pkgs/check_systemd/check_systemd')
-rwxr-xr-xmodules/pkgs/check_systemd/check_systemd20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/pkgs/check_systemd/check_systemd b/modules/pkgs/check_systemd/check_systemd
new file mode 100755
index 0000000..e668331
--- /dev/null
+++ b/modules/pkgs/check_systemd/check_systemd
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+readarray -t failed < <( systemctl show '*.service' \
+ --state=failed --property=Names \
+ | sed -r -n 's,Names=(.+)\.service,\1,p' \
+ | sort
+ )
+
+if [ ${#failed[@]} -ne 0 ]; then
+ printf -v list ', %s' "${failed[@]}"
+ printf 'WARNING: %s failed\n' "${list:2}"
+ exit 1
+else
+ echo "OK: no failed services"
+ exit 0
+fi
+
+