zabbix monitoring system - zabbix monitors the running status of nginx

Use zabbix to monitor the running status of nginx (either running or not running) (configure the corresponding trigger)

Method 1: Customize key to monitor nginx running status

1. Zabbix-agent side operation

1. Install and start nginx in zabbix-agent server

[root@zabbix-agent ~]# yum -y install nginx
[root@zabbix-agent ~]# systemctl start nginx

2. Customize the monitoring item key (UserParameter) in the zabbix configuration file as nginx.status

[root@zabbix-agent ~]# vim /etc/zabbix/zabbix_agentd.d/nginx_status.conf
Add the following:
Insert image description here

    UserParameter=nginx.status,systemctl status nginx | awk NR==3'{print $3}'| awk -F '(' '{print $2}'| awk -F')' '{print $1}'

3. Restart zabbix-agent

[root@zabbix-agent ~]# systemctl restart zabbix-agent

2. Zabbix-agent side operation

1. Install zabbix-get

[root@zabbix-agent ~]# yum -y install zabbix-get

2. Test the customized monitoring item nginx.status on the zabbix-agent side

[root@zabbix-agent ~]# zabbix_get -s 192.168.58.143 -k "nginx.status"
Insert image description here
When nginx is running, running is displayed, and when nginx is not running, dead is displayed.

3. Create monitoring items and triggers on the web side

Create monitoring items in the zabbix web interface
Insert image description here

Add trigger
Insert image description here
Insert image description here
Trigger test:
1. Close nginx on the zabbix-agent side
2. Check the alarm situation
Insert image description here

Method 2: Use monitoring templates to monitor nginx running status

Since there are too many monitoring templates and I don’t know much about monitoring templates, I didn’t know that there is a monitoring template net.tcp.listen[port] that can implement the listening port, so I used a custom key to monitor the running status of nginx, which is this article. Method 1 in .

1. Create monitoring items

Use monitoring templates to monitor nginx status
Insert image description here

2. Create a trigger

Insert image description here

3. Verification

The zabbix-agent side closes nginx and simulates nginx to stop running. Check the alarm status
Insert image description here
and issue an alarm. The trigger configuration is successful.

Guess you like

Origin blog.csdn.net/weixin_44178770/article/details/124706744