📜 ⬆️ ⬇️

Nginx statistics in cacti

image

Based on the previous article , only this time we collect statistics for the nginx web server.


First you need to install nginx with the http_stub_status_module module. And turn it on, for this we add lines to /usr/local/etc/nginx/nginx.conf (for freebsd):
')
location / nginx_status {
stub_status on;
# disable access_log if requared
access_log off;
#allow XX.YY.AA.ZZ; better to allow only for 127.0.0.1
#deny all;
}


Now, when http: // localhost / nginx_status is requested, the server will output something like this:

Active connections: 1
server accepts handled requests
2 2 4
Reading: 0 Writing: 1 Waiting: 0


Now download the script for Cacti from here: <a title = " forums.cacti.net/download/file.php?id=12676 " href = " forums.cacti.net/download/file.php?id=12676

Unzip and put the files get_nginx_clients_status.pl and get_nginx_socket_status.pl in / usr / local / share / cacti / scripts / .

Now open cacti, go to Import Templates and import cacti_graph_template_nginx_clients_stat.xml and cacti_graph_template_nginx_sockets_stat.xml

Should have been 2 new templates for graphs:

Nginx_clients_stat
Nginx_sockets_stat


We create graphs, register the URL from which the statistics will be taken and watch them =)

image
image
(graphics are not mine)


PS required module PERL LWP :: UserAgent, put simply:

perl -MCPAN -e 'install "LWP :: UserAgent"'


Based on: http://forums.cacti.net/about26458.html
Similar article for lighttpd: habrahabr.ru/blogs/sysadm/66602

UPD :
Legend to the first graphic :
Active connections - how many clients are serviced.
Reading - how many connections are in the reading state.
Writing - how many connections are in the recording state.
Waiting - keep-alive connections or in the request processing state

Legend to the second graphic :
server accepts - how many connections were accepted;
handled - how many of them were processed, and not closed immediately, the connection is immediately closed if the table of connections is full.
requests - how many requests are served. With keep-alive in one connection there can be several requests.

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


All Articles