This little snippet and template allows you to monitor services on Linux. It’s really simple and might not work on all distributions. So far I’ve mainly used it on CentOS6.
The required files can be downloaded from github here.
To get things working, copy the files from github to /etc/zabbix. You need to change the owner of userscripts to zabbix and add the execute privileges to the .sh file.
chmod u+x /etc/zabbix/userscripts/service_check.sh chown -R zabbix:zabbix /etc/zabbix/userscripts
To get things working, you need to add the zabbix user to visudo and allow the command to be run. In this example we use rsyslog as the service we want to monitor.
zabbix ALL = NOPASSWD: /etc/init.d/rsyslog
Also allow users to run sudo without tty by editing /etc/sudoers and add a # before “defaults requiretty”.
Now you can import the template and apply it to a host. If you want to monitor something else than rsyslog, just clone the template and edit the service to monitor in the item key. Also remember to update trigger name accordingly as well as the visudo file to allow service query of that service.