Description
When a service is down, the plugin is still returning status code of OKAY (zero).
root@vps3:~/icinga/nagios-plugins-master# /usr/lib/nagios/plugins/check_service.sh -s postfix -o linux
Active: inactive (dead) since Thu 2018-05-24 12:46:25 BST; 8s ago
root@vps3:~/icinga/nagios-plugins-master# echo $?
0
I think this incorrect, and the bug is due to the grep on line 79:
SERVICETOOL="systemctl status $SERVICE | grep -i Active"
I can fix this by removing the grep on this line as follows:
SERVICETOOL="systemctl status $SERVICE"
which means that SERVICETOOL will get the result variable from systemctl itself rather than the return from grep (which is matching on the text 'ACTIVE' and 'inactive' in the status line therefore returning zero).
Unfortunately the status text returned without this grep is then a bit verbose but at least the status code (i.e. critical, okay etc) is correct. Maybe the grep for '-i Active' could be moved to later in the script once the actual status code check has been performed.
OS is Ubuntu Xenial (16.04)
Last update in the header of the script is 2018-04-25.
Thanks for the script.
Andy.