From dc892da5e2cb58cdb24b7584257a3dce6c6b68fe Mon Sep 17 00:00:00 2001 From: unkown Date: Sun, 4 Feb 2007 21:36:00 +0100 Subject: [PATCH] Initial version --- plugins/other/nginx_status | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 plugins/other/nginx_status diff --git a/plugins/other/nginx_status b/plugins/other/nginx_status new file mode 100755 index 00000000..27735c97 --- /dev/null +++ b/plugins/other/nginx_status @@ -0,0 +1,82 @@ +#!/usr/bin/perl -w +# +# Magic markers: +#%# family=auto +#%# capabilities=autoconf + +my $ret = undef; + +if (! eval "require LWP::UserAgent;"){ + $ret = "LWP::UserAgent not found"; +} + +chomp(my $fqdn=`hostname -f`); + +my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status"; + +if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" ) +{ + if ($ret){ + print "no ($ret)\n"; + exit 1; + } + + my $ua = LWP::UserAgent->new(timeout => 30); + my $response = $ua->request(HTTP::Request->new('GET',$URL)); + + unless ($response->is_success and $response->content =~ /server/im) + { + print "no (no nginx status on $URL)\n"; + exit 1; + } + else + { + print "yes\n"; + exit 0; + } +} + +if ( exists $ARGV[0] and $ARGV[0] eq "config" ) +{ + print "graph_title NGINX status\n"; + print "graph_args --base 1000\n"; + print "graph_category nginx\n"; + print "graph_vlabel Connections\n"; + + print "total.label Active connections\n"; + print "total.info Active connections\n"; + print "total.draw LINE2\n"; + + print "reading.label Reading\n"; + print "reading.info Reading\n"; + print "reading.draw LINE2\n"; + + print "writing.label Writing\n"; + print "writing.info Writing\n"; + print "writing.draw LINE2\n"; + + print "waiting.label Waiting\n"; + print "waiting.info Waiting\n"; + print "waiting.draw LINE2\n"; + + exit 0; +} + +my $ua = LWP::UserAgent->new(timeout => 30); + +my $response = $ua->request(HTTP::Request->new('GET',$URL)); + +#Active connections: 1845 +#server accepts handled requests +# 4566318 4566318 84218236 +# Reading: 2 Writing: 278 Waiting: 1565 +if ($response->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s) { + print "total.value $1\n"; + print "reading.value $2\n"; + print "writing.value $3\n"; + print "waiting.value $4\n"; +} else { + foreach (qw(total reading writing waiting)){ + print "$_.value U\n"; + } +}