aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_systemd
blob: bf8d5324e12e1c3f83ad0464ecc98a5306424435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

# USAGE:
# check_systemd [UNIT ...]

FAILED=()

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

#if ! systemctl is-system-running > /dev/null; then
#	echo systemd WARNING: System state degraded.
#	exit 1
#fi

echo "systemd OK: $# units checked"
exit 0