Created
April 27, 2016 23:17
-
-
Save fser/1d3f04012a89b1094558b280e8752c1e to your computer and use it in GitHub Desktop.
nagios sensor to check wether services / server needs to be restarted. It depends on checkrestart (from debian-goodies) to list packages which needs to be restarted.
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
#!/usr/bin/env bash | |
if [ -e /var/run/reboot-required ]; then | |
echo "error: need reboot (kernel upgrade)" | |
exit 2 | |
fi | |
checkrestart &>/dev/null || { echo 'need checkrestart (apt-get install debian-goodies) to get the actual service list' ; exit 1; } | |
if [ -e /var/run/reboot-required.pkgs ]; then | |
echo -n 'error: services need restart (' | |
checkrestart | grep service | awk '{ service[$2]++; } END { for (s in service) { printf ("%s ", s) } }' | |
echo ')' | |
exit 1 | |
fi | |
echo "ok" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment