📜 ⬆️ ⬇️

Monitor Nginx with ZTC and Zabbix

Hello.

I was a little surprised that in Habré only once and casually mentioned ZTC templates for Zabbix. Let's try to correct this misunderstanding.
The author of these python scripts is Vladimir Rusinov, all the info about the versions, you can give feedback and more on the green mouse website greenmice.info .
Today I will tell how you can use these templates to monitor nginx, which I think is relevant for many habrovchan.

Download the archive with scripts:
cd /opt wget https://bitbucket.org/rvs/ztc/downloads/ztc-11.11.3.tar.gz 

or
 hg clone https://bitbucket.org/rvs/ztc 


You can also find rpm packages. For us, this is not relevant, we will consider the process on debian.
')
Unzip:
 tar zxfv ztc-11.11.3.tar.gz 


Install:
 cd /opt/ztc-11.11.3 python setup.py install 


We run over the output in search of errors, we do not find any, go further, rule the nginx config. Add:
 server { listen localhost; server_name nginx_status.localhost; location /server-status { stub_status on; access_log off; allow 127.0.0.1; deny all; } 

Restart nginx:
 /etc/init.d/nginx restart 


Edit nginx.conf config in /etc/ztc/nginx.conf!:
 proto=http host=localhost port=80 resource=/server-status 


We check the work of our scripts:

 /opt/ztc/bin/nginx.py ping IOError: [Errno 2] No such file or directory: '/var/log/zabbix/ztc.log' 

Oops ... We do:
 mkdir /var/log/zabbix/ 


We try again:
 /opt/ztc/bin/nginx.py ping 0.00252890586853 /opt/ztc/bin/nginx.py requests 35990037 


Ok, so our scripts are ready to work with the server.

Prepare the agent config /etc/zabbix/zabbix_agentd.conf:
 UserParameter=nginx[*],/opt/ztc/bin/nginx.py $1 

Restart zabbix-agent:
 /etc/init.d/zabbix-agent restart 


With the console part done. Go to the Zabbix web server, import the xml template from the ./ztc/templates folder. We tie the necessary host to it, and observe two new graphics:





Also, who will be interested in an article about setting up Zabbix for php-fpm or memcache, write in comments.

Source: https://habr.com/ru/post/140184/


All Articles