This is perl script for monitoring Nginx Web Server based on apache perl script.
*Nginx - fast,secure web servev with kqueue and epoll support.
perl-script:
zabbix_agentd.conf; Change "MYHOST" parameter:
*Nginx - fast,secure web servev with kqueue and epoll support.
perl-script:
Code:
#!/usr/local/bin/perl [COLOR="DarkRed"]!!!YOUR PATH MAY BE DIFFERENT!!![/COLOR]
my $host = $ARGV[0];
my $cmd = 'curl -A "mozilla/4.0 (compatible; cURL 7.10.5-pre2; Linux 2.4.20)" -m 12 -s -L -k -b /tmp/bbapache_cookiejar.curl -c /tmp/bbapache_cookiejar.curl -H "Pragma: no-cache" -H "Cache-control: no-cache" -H "Connection: close" "'.$host.'/nginx_status?auto"';
my $server_status = qx($cmd);
#print $server_status; #DEBUG
my @nginx_checks;
foreach (split(/\n/, $server_status)) {
$total = $1 if (/^Active connections:\s+(\d+)/);
if (/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/) {
$reading = $1;
$writing = $2;
$waiting = $3;
}
$accepted_conn = $1 if (/^\s+(\d+)\s+(\d+)\s+(\d+)/);
$handled_conn = $2 if (/^\s+(\d+)\s+(\d+)\s+(\d+)/);
$handled_req = $3 if (/^\s+(\d+)\s+(\d+)\s+(\d+)/);
}
#print "Accepted Conn:$accepted_conn; Handled:$handled_conn; Hand Req:$handled_req; Total:$total; Reading:$reading; Writing:$writing; Waiting:$waiting\n";
$nginx_checks[0] = $accepted_conn;
$nginx_checks[1] = $handled_conn;
$nginx_checks[2] = $handled_req;
$nginx_checks[3] = $total;
$nginx_checks[4] = $reading;
$nginx_checks[5] = $writing;
$nginx_checks[6] = $waiting;
print "$nginx_checks[$ARGV[1]]";
exit(0);
zabbix_agentd.conf; Change "MYHOST" parameter:
Code:
UserParameter=nginx.accepted_conn,/etc/zabbix/nginx.pl http://MYHOST 0 UserParameter=nginx.handled_conn,/etc/zabbix/nginx.pl http://MYHOST 1 UserParameter=nginx.handled_req,/etc/zabbix/nginx.pl http://MYHOST 2 UserParameter=nginx.total_conn,/etc/zabbix/nginx.pl http://MYHOST 3 UserParameter=nginx.reading,/etc/zabbix/nginx.pl http://MYHOST 4 UserParameter=nginx.writing,/etc/zabbix/nginx.pl http://MYHOST 5 UserParameter=nginx.waiting,/etc/zabbix/nginx.pl http://MYHOST 6
Comment