~ubuntu-branches/ubuntu/saucy/munin/saucy

« back to all changes in this revision

Viewing changes to plugins/node.d/apache_processes.in

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 12:54:28 UTC
  • mfrom: (8.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120611125428-k8z25s77rp755vxe
Tags: 2.0.0-1ubuntu1
* Resync with Debian unstable.
* d/munin-node.upstart,munin.upstart: Add upstart configurations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
  [apache_*]
27
27
     env.url   http://127.0.0.1:%d/server-status?auto
28
28
     env.ports 80
 
29
     env.showfree 1
29
30
 
30
31
The %d in the url will be replaced with the port.  The default port is
31
 
80 as shown.
 
32
80 as shown. 'showfree' enables the disaplay of the "free slots" graph.
32
33
 
33
34
The port list is a space separated list of ports.  NOTE that one
34
35
single Apache can have several open ports, and the plugin needs only
68
69
 
69
70
=head1 VERSION
70
71
 
71
 
  $Id: apache_processes.in 3192 2009-12-05 21:11:54Z feiner.tom $
 
72
  $Id: apache_processes.in 4793 2012-04-04 08:06:17Z kenyon $
72
73
 
73
74
=head1 AUTHOR
74
75
 
95
96
 
96
97
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
97
98
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
 
99
my $SHOWFREE = !exists $ENV{'showfree'} || $ENV{'showfree'};
98
100
 
99
101
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
100
102
{
103
105
                print "no ($ret)\n";
104
106
                exit 0;
105
107
        }
106
 
        my $ua = LWP::UserAgent->new(timeout => 30);
 
108
        my $ua = LWP::UserAgent->new(timeout => 30,
 
109
                        agent => sprintf("munin/%s (libwww-perl/%s)", $Munin::Common::Defaults::MUNIN_VERSION, $LWP::VERSION));
107
110
 
108
111
        foreach my $port (@PORTS) {
109
112
                my $url = sprintf $URL, $port;
156
159
            print "idle$port.label idle servers $port\n";
157
160
            print "idle$port.draw STACK\n";
158
161
            print "idle$port.colour 0033ff\n";
159
 
            print "free$port.label free slots $port\n";
160
 
            print "free$port.draw STACK\n";
161
 
            print "free$port.colour ccff00\n";
 
162
            if ($SHOWFREE) {
 
163
                print "free$port.label free slots $port\n";
 
164
                print "free$port.draw STACK\n";
 
165
                print "free$port.colour ccff00\n";
 
166
            }
162
167
        }
163
168
        foreach my $port (@PORTS) {
164
 
                foreach my $type qw "busy idle" {
 
169
                foreach my $type (qw(busy idle)) {
165
170
                        print_thresholds("$type$port");
166
171
                }
167
172
        }
170
175
 
171
176
foreach my $port (@PORTS)
172
177
{
173
 
    my $ua = LWP::UserAgent->new(timeout => 30);
 
178
    my $ua = LWP::UserAgent->new(timeout => 30,
 
179
                        agent => sprintf("munin/%s (libwww-perl/%s)", $Munin::Common::Defaults::MUNIN_VERSION, $LWP::VERSION));
174
180
    my $url = sprintf $URL, $port;
175
181
    my $response = $ua->request(HTTP::Request->new('GET',$url));
176
182
    if ($response->content =~ /^Busy(?:Servers|Workers):\s+(.+)$/im) {
183
189
    } else {
184
190
            print "idle$port.value U\n";
185
191
    }
186
 
    if ($response->content =~ /^(Scoreboard: .*)$/m) {
187
 
            my $count = () = $1 =~ /\./g;
188
 
            print "free$port.value $count\n";
189
 
    } else {
190
 
            print "free$port.value U\n";
 
192
    if ($SHOWFREE) {
 
193
            if ($response->content =~ /^(Scoreboard: .*)$/m) {
 
194
                my $count = () = $1 =~ /\./g;
 
195
                print "free$port.value $count\n";
 
196
            } else {
 
197
                print "free$port.value U\n";
 
198
            }
191
199
    }
192
200
}
193
201