zabbix monitoring httpd, nginx service

1. Experimental environment

Ip host environment
server4 172.25.254.4 zabbix monitoring client
server3 172.25.254.3 monitored host
server2 172.25.254.2 be monitored host

And server3 mounted in server2 zabbix-agent.
In the previous blog you have finished adding hosts to monitor, let's monitoring service.

2. server2 in httpd service monitoring

First need to install the httpd server and then open the service.

[root@server2 ~]# yum install -y httpd
[root@server2 ~]# systemctl start httpd

After the end of the web and then perform operations row
Here Insert Picture Descriptionclick the host server2, add the template into the template
Here Insert Picture DescriptionHere Insert Picture Descriptionto add HTTP template click to update, thus completing the added monitoring.
Here Insert Picture DescriptionIn the monitoring items you can view the monitoring service.

3. server3 in nginx monitoring service

1. First, install nginx on server3
access to resources, extract

[root@server3 ~]# tar zxf nginx-1.16.0.tar.gz 

Here Insert Picture DescriptionInstall the software needed.

[root@server3 nginx-1.16.0]# yum install -y gcc pcre-devel zlib-devel
[root@server3 nginx-1.16.0]# ./configure --prefix=/usr/local/nginx \
--with-http_stub_status_module
[root@server3 nginx-1.16.0]# make && make install

Compile and install.

2. modify the configuration file

vim /usr/local/nginx/conf/nginx.conf
 35     server {
 36         listen       80;
 37         server_name  localhost;
 38 
 39 
 40         location / {
 41             root   html;
 42             index  index.html index.htm;
 43         }
 44 
 45         location /status {
 46             stub_status on;
 47             access_log off;
 48             allow 127.0.0.1;
 49             deny all;
 50         }
 51 
 52         error_page   500 502 503 504  /50x.html;
 53         location = /50x.html {
 54             root   html;
 55         }
 56 
 57         }

The machine can be set only access.

[root@server3 nginx-1.16.0]# curl http://127.0.0.1/status

Here Insert Picture DescriptionAccess test.

[root@server3 nginx-1.16.0]# yum install -y httpd
[root@server3 nginx-1.16.0]# ab -c 1 -n 1000 http://127.0.0.1/status

Here Insert Picture DescriptionThis machine 1,000 concurrent access.
Here Insert Picture DescriptionHere Insert Picture DescriptionActive connection on the back of the digital crawl, then add monitoring items based on this number.

[root@server3 zabbix_agentd.d]# pwd
/etc/zabbix/zabbix_agentd.d
[root@server3 zabbix_agentd.d]# vim userparameter_nginx.conf
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active |     awk {'print $3'}

Modify the file, set the key to nginx.acive.

3. Configure the web end
first click on the monitored items in the host server3, click Create monitored item, on the following page, enter the name of the monitor in the page, this can be easily named, but the following key values to be consistent and above documents and then click update.
Here Insert Picture DescriptionAfter clicking the graphic, click Create graphics, add monitoring items nginx_active just created.
Here Insert Picture DescriptionClick Update, and then it can be viewed.
Here Insert Picture DescriptionHere Insert Picture DescriptionHere found garbled, you need to download the plug-in web simkai.ttf end server4, and put the files in the specified directory
Here Insert Picture Descriptionand then modify a file after it.

[root@server4 include]# pwd
/usr/share/zabbix/include
[root@server4 include]# vim defines.inc.php

Here Insert Picture DescriptionReplace the contents of the file.
Here Insert Picture DescriptionAfter modifying the file again to preview the graphics, you can find Chinese display properly.
Then add the second monitored item, add the first in the file

[root@server3 zabbix_agentd.d]# pwd
/etc/zabbix/zabbix_agentd.d
[root@server3 zabbix_agentd.d]# vim userparameter_nginx.conf
  1 UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active |     awk {'print $3'}
  2 UserParameter=nginx.accept,curl -s http://127.0.0.1/status | awk NR==3 | a    wk '{print $1}'

Add the contents of the second row.
After the browser is configured the same as above, create a monitored item, and then create a graphic based on monitoring items created, but here is to monitor the same service, so you can monitor the front of the item and a graphics function, there is no need to create.
Here Insert Picture DescriptionCreate a monitored item.
Here Insert Picture DescriptionNginx_status created before after clicking monitored item.
Here Insert Picture DescriptionHere Insert Picture DescriptionThe monitor features were added.
Here Insert Picture DescriptionYou will find two items monitor preview.

Published 250 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/yrx420909/article/details/104938532