Difference between revisions of "Nginx: Monitoring Statistics"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
Line 46: | Line 46: | ||
chmod +x rrd_nginx.pl | chmod +x rrd_nginx.pl | ||
− | + | Ubah setting di rrd_nginx.pl agar script tahu dimana menyimpan rrd-base dan image | |
+ | |||
+ | |||
+ | vi /usr/local/src/rrd_nginx.pl | ||
#!/usr/bin/perl | #!/usr/bin/perl | ||
use RRDs; | use RRDs; | ||
use LWP::UserAgent; | use LWP::UserAgent; | ||
− | + | ||
# define location of rrdtool databases | # define location of rrdtool databases | ||
my $rrd = ‘/opt/rrd’; | my $rrd = ‘/opt/rrd’; | ||
Line 61: | Line 64: | ||
Last step is to insert following string to /etc/crontab file and to restart cron daemon: | Last step is to insert following string to /etc/crontab file and to restart cron daemon: | ||
− | * * * * * root / | + | * * * * * root /usr/local/rrd_nginx.pl |
+ | |||
+ | |||
+ | When all preparations will be finished, you get images in your $img directory: | ||
==Referensi== | ==Referensi== |
Revision as of 16:41, 22 February 2011
Script untuk monitoring statistics Nginx relatif mudah di instalasi dan di konfigurasi. Kita perlu melakukan langkah berikut untuk memperoleh gambar statistik dari server nginx.
Ubah konfigurasi file ngix dan tambahkan kalimat berikut
vi /etc/nginx/sites-enabled/default
http { … server { listen SOME.IP.ADD.RESS; … location /nginx_status { stub_status on; access_log off; allow SOME.IP.ADD.RESS; deny all; } … } … }
Test file konfigurasi
/etc/init.d/nginx stop /usr/sbin/nginx -t
the configuration file /etc/nginx/nginx.conf syntax is ok configuration file /etc/nginx/nginx.conf test is successful
Jika ada error tentang stub_status, check nginx. Nginx harusnya di konfigurasi dengan —-with-http_stub_status_module. Jika semua OK menggunakan shell lakukan test
# GET http://hostname.anda/nginx_status
Active connections: 1 server accepts handled requests 1 1 1 Reading: 0 Writing: 1 Waiting: 0
Download perl script: rrd_nginx.pl dan jadikan executable
cd /usr/local/src/ wget http://kovyrin.net/files/mrtg/rrd_nginx.pl.txt mv rrd_nginx.pl.txt rrd_nginx.pl chmod +x rrd_nginx.pl
Ubah setting di rrd_nginx.pl agar script tahu dimana menyimpan rrd-base dan image
vi /usr/local/src/rrd_nginx.pl
#!/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 /usr/local/rrd_nginx.pl
When all preparations will be finished, you get images in your $img directory:
Referensi
- http://linxfo.wordpress.com/2008/03/08/monitoring-nginx-server-statistics-with-rrdtool/
- http://kovyrin.net/files/mrtg/rrd_nginx.pl.txt