Created
March 7, 2017 22:33
-
-
Save DaffyDuke/ae3e9bd90c05cd49c6f5bacde2ed2839 to your computer and use it in GitHub Desktop.
Nagios check for systemd failed units
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Source http://lzone.de/blog/Nagios+Check+for+Systemd+Failed+Units | |
if [ -f /bin/systemctl ]; then | |
failed=$(/bin/systemctl --failed --no-legend) | |
failed=${failed/ */} # Strip everything after first space | |
failed=${failed/.service/} # Strip .service suffix if [ "$failed" != "" ]; then | |
echo "Failed units: $failed" | |
exit 1 | |
else | |
echo "No failed units." | |
exit 0 | |
fi | |
else | |
echo "No systemd. Nothing was checked!" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there's an error in line 6. a little bit improved version: https://gist.github.com/jazzl0ver/0d69d487d6c3deab5cebcb1595acb02c