Zabbix – monitoring service status in Centos 7 via UserParameter

A series of articles on Zabbix monitoring
[*]

  • Monitoring a specific Linux machine service in Zabbix
  • Monitoring a specific Windows service of a machine in Zabbix
  • Monitoring a specific Windows process on a machine in Zabbix
  • Monitoring Linux daemon status in Zabbix
  • Zabbix – monitoring service status in Centos 7 via UserParameter
  • 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:

    [*]

  • whether the service is active (is-active)
  • did it fail with an error (is-failed)
  • is it added to startup (is-enabled)
  • 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

    Zabbix - monitoring service status in Centos 7 via UserParameter 2Create 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

    Zabbix - monitoring service status in Centos 7 via UserParameter 3Create trigger

    Имя: srv-ftp-01:vsftpd_status
    Важность: Высокая
    Выражение: {srv-ftp-01:systemd.unit.is-active[vsftpd].last(0)}=0
    Описание: Проверка статуса сервиса vsftpd - systemctl status vsftpd
    Sidebar