Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teach Zabbix to monitor service status

Tags:

service

zabbix

I know that Zabbix can monitor any service on Linux machine via two options:

  • scan particular tcp or udp port, on which the service is bound
  • or count the service processes with proc.num[<processname>]

It is totally counter-intuitive, because I can spawn processes with the same executable name and they will deceive Zabbix. I'd prefer to use standard service <servicename> status or systemctl status name.service tool. But there are no standard way to use it from Zabbix except system.run[cmd]

Could you help me to write templates for monitoring a particular service state. We want to use different OSes like Centos 7 and Ubuntu 14.04 and 16.04 distributions. It is pity but service <servicename> status is completely different in listed operating systems.

like image 500
GEORG GAAL Avatar asked Apr 26 '17 07:04

GEORG GAAL


People also ask

How do I check my Zabbix service status?

You can check the status by running service pdagent status in the command line. If the agent isn't running, you can start it with the command service pdagent start .

What can be monitored by Zabbix?

Zabbix provides monitoring metrics, such as network utilization, CPU load and disk space consumption. The software monitors operations on Linux, Hewlett Packard Unix (HP-UX), Mac OS X, Solaris and other operating systems (OSes); however, Windows monitoring is only possible through agents.


2 Answers

You can also add the following UserParameters in zabbix_agentd.conf to monitor service status in systemd systems. For non-systemd the OS doesn't really monitor service status, the various bash script "status" arguments are often unreliable.

UserParameter=systemd.unit.is-active[*],systemctl is-active --quiet '$1' && echo 1 || echo 0
UserParameter=systemd.unit.is-failed[*],systemctl is-failed --quiet '$1' && echo 1 || echo 0
UserParameter=systemd.unit.is-enabled[*],systemctl is-enabled --quiet '$1' && echo 1 || echo 0

And then e.g. for sshd status create an item with a key like:

systemd.unit.is-active[sshd]
like image 180
sivann Avatar answered Oct 15 '22 08:10

sivann


If Linux services are managed by systemd (Centos 7+, Ubuntu 16+, ...), then you can use https://github.com/cavaliercoder/zabbix-module-systemd. It uses standard systemd D-Bus communication - that's what systemctl does under the hood.

like image 20
Jan Garaj Avatar answered Oct 15 '22 08:10

Jan Garaj