Created
December 3, 2014 14:03
-
-
Save maethor/33d6062dea9fc1fe9e7b to your computer and use it in GitHub Desktop.
This is a nagios/shinken plugin to check if all LSB services are running using the "service" command.
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/sh | |
# | |
# Guillaume Subiron, Sysnove, 2014 | |
# | |
# Description : | |
# | |
# This plugin checks if all installed daemons are running. | |
# Works on Debian. | |
# | |
# Copyright 2014 Guillaume Subiron <[email protected]> | |
# This work is free. You can redistribute it and/or modify it under the | |
# terms of the Do What The Fuck You Want To Public License, Version 2, | |
# as published by Sam Hocevar. See the http://www.wtfpl.net/ file for more details. | |
# | |
STATE_OK=0 | |
STATE_WARNING=1 | |
STATE_CRITICAL=2 | |
STATE_UNKNOWN=3 | |
services="amavis apache2 atd bind9 ceph cron dibbler-client dovecot exim4 fail2ban fcgiwrap glassfish gitlab lm-sensors mailgraph memcached mongodb nagios-nrpe-server nginx npcd ntp openvpn pgbouncer php5-fpm postfix pure-ftpd-mysql rabbitmq-server redis-server resolvconf rsyslog shinken shorewall shorewall6 slapd spamassassin ssh uwsgi" | |
down="" | |
for service in $services ; do | |
if [ -f /etc/init.d/$service ] ; then | |
/usr/sbin/service $service status > /dev/null || down="$down $service" | |
fi | |
done | |
# Postgres special case : 4 means that postgresql-common is installed but not | |
# postgresql-server, so it's OK if postgres is not running | |
if [ -f /etc/init.d/postgresql ] ; then | |
/usr/sbin/service postgresql status > /dev/null | |
s=$? | |
[ $s -ne 0 -a $s -ne 4 ] && down="$down $service" | |
fi | |
if [ "$down" != "" ] ; then | |
echo "WARNING - Services down:$down" | |
exit $STATE_WARNING | |
else | |
echo "OK - All services are running." | |
exit $STATE_OK | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment