Zabbix – monitoring service status in Centos 7 via UserParameter
A series of articles on Zabbix monitoring
[*]
We configure the server that we are going to monitor
Install zabbix-agent on the server
Add UserParameter to zabbix_agentd.conf file and restart Zabbiz Agent
[[email protected]]# nano /etc/zabbix/zabbix_agentd.conf
### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
# See 'zabbix_agentd' directory for examples.
#
# Mandatory: no
# Default:
# UserParameter=
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
[[email protected]]# systemctl restart zabbix-agent
From the UserParameter values, you can see that in the future you can monitor:
[*]
Configuring Zabbix Server
Go to the Zabbix Server web interface
Add the server that we are going to monitor to a new host: Settings – Host – Create host
Create a new data item: Settings – Hosts – select the desired node – Data items – Create data item
Create item
Имя: srv-ftp-01:vsftpd_status
Тип: Zabbix агент
Ключ: systemd.unit.is-active[vsftpd]
Тип информации: Числовой (целое положительное)
Тип данных: Десятичный
Интервал обновления (в сек): 60
Новая группа элементов данных: Services
Create a new trigger Settings – Hosts – select the desired node – Triggers – Create trigger
Create trigger
Имя: srv-ftp-01:vsftpd_status
Важность: Высокая
Выражение: {srv-ftp-01:systemd.unit.is-active[vsftpd].last(0)}=0
Описание: Проверка статуса сервиса vsftpd - systemctl status vsftpd