/usr/share/munin/plugins/nginx_request is in munin-node 1.4.6-3ubuntu3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | #!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
nginx_request - Munin plugin to show number of requests pr. second to nginx.
=head1 APPLICABLE SYSTEMS
Any nginx host
=head1 CONFIGURATION
This shows the default configuration of this plugin. You can override
the status URL.
[nginx*]
env.url http://localhost/nginx_status
Nginx must also be configured. Firstly the stub-status module must be
compiled, and secondly it must be configured like this:
server {
listen 127.0.0.1;
server_name localhost;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
$Id: nginx_request.in 2431 2009-09-16 10:04:17Z janl $
=head1 BUGS
None known
=head1 AUTHOR
Unknown
=head1 LICENSE
Unknown. Not specified by the unknown author. Nginx has a BSD
license. Munin is GPLv2 licensed.
=cut
my $ret = undef;
if (! eval "require LWP::UserAgent;"){
$ret = "LWP::UserAgent not found";
}
chomp(my $fqdn=`hostname -f 2>/dev/null | hostname`);
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
my $port = exists $ENV{'port'} ? $ENV{'port'} : "80";
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
if ($ret){
print "no ($ret)\n";
exit 0;
}
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 0;
}
else
{
print "yes\n";
exit 0;
}
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
{
print "graph_title Nginx requests\n";
print "graph_args --base 1000\n";
print "graph_category nginx\n";
print "graph_vlabel Request per second\n";
print "request.label req/sec\n";
print "request.type DERIVE\n";
print "request.min 0\n";
print "request.label requests port $port\n";
print "request.draw LINE2\n";
exit 0;
}
my $ua = LWP::UserAgent->new(timeout => 30);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
if ($response->content =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/m) {
print "request.value $3\n";
} else {
print "request.value U\n";
}
|