Nginx: Monitoring Statistics: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
New page: This script is very easy to install and configure. You can use following steps to get pretty stats graph for your nginx-powered server: Modify your nginx config file and add following loc...
 
Onnowpurbo (talk | contribs)
No edit summary
Line 4: Line 4:


  http {
  http {
 
server {
    server {
listen SOME.IP.ADD.RESS;
      listen SOME.IP.ADD.RESS;
     
location /nginx_status {
      location /nginx_status {
stub_status on;
        stub_status on;
access_log  off;
        access_log  off;
allow SOME.IP.ADD.RESS;
        allow SOME.IP.ADD.RESS;
deny all;
        deny all;
}
        }
   
}
    }
 
  }
  }


Line 34: Line 34:
  Download  perl script: rrd_nginx.pl and make it executable with
  Download  perl script: rrd_nginx.pl and make it executable with


  # chmod +x rrd_nginx.pl
  wget http://kovyrin.net/files/mrtg/rrd_nginx.pl.txt
Change settings in rrd_nginx.pl to let script know where it will save rrd-base and images:
mv rrd_nginx.pl.txt rrd_nginx.pl
chmod +x rrd_nginx.pl
 
hange settings in rrd_nginx.pl to let script know where it will save rrd-base and images:


  #!/usr/bin/perl
  #!/usr/bin/perl
Line 51: Line 54:


  * *    * * *  root    /some/path/rrd_nginx.pl  When all preparations will be finished, you get  images in your $img directory:  
  * *    * * *  root    /some/path/rrd_nginx.pl  When all preparations will be finished, you get  images in your $img directory:  


==Referensi==
==Referensi==

Revision as of 09:23, 22 February 2011

This script is very easy to install and configure. You can use following steps to get pretty stats graph for your nginx-powered server:

Modify your nginx config file and add following location to it:

http {
  …
    server {
      listen SOME.IP.ADD.RESS;
      …
      location /nginx_status {
        stub_status on;
        access_log   off;
        allow SOME.IP.ADD.RESS;
        deny all;
        }
    …
    }
  …
}

Test your config file with following command:

# /your/installation/sbin/nginx -t
2006/04/29 04:24:36 [info] 31676#0: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
2006/04/29 04:24:36 [info] 31676#0: the configuration file /opt/nginx/conf/nginx.conf was tested successfully
#
# If you will get error about stub_status directive, check your nginx – it should be configured with —-with-http_stub_status_module option. If your configuration is OK, you can restart nginx and test it:
# GET http://your-domain.com/nginx_status
Active connections: 1492
server accepts handled requests
2124355 2124355 8278635
Reading: 6 Writing: 405 Waiting: 1081
Download  perl script: rrd_nginx.pl and make it executable with
wget http://kovyrin.net/files/mrtg/rrd_nginx.pl.txt
mv rrd_nginx.pl.txt rrd_nginx.pl
chmod +x rrd_nginx.pl

hange settings in rrd_nginx.pl to let script know where it will save rrd-base and images:

#!/usr/bin/perl
use RRDs;
use LWP::UserAgent;
# define location of rrdtool databases
my $rrd = ‘/opt/rrd’;
# define location of images
my $img = ‘/opt/rrd/html’;
# define your nginx stats URL
my $URL = “http://your-domain.com/nginx_status”;

Last step is to insert following string to /etc/crontab file and to restart cron daemon:

* *     * * *   root    /some/path/rrd_nginx.pl  When all preparations will be finished, you get  images in your $img directory: 

Referensi

Pranala Menarik