This file is indexed.

/usr/share/munin/plugins/apache_processes is in munin-node 1.4.6-3ubuntu3.4.

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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/perl
# -*- cperl -*-

=head1 NAME

apache_processes - Munin plugin to monitor the number of
apache-processes running on the machine.

=head1 APPLICABLE SYSTEMS

Apache HTTP servers with C</server-status> enabled.

=head1 CONFIGURATION

The plugin needs access to http://localhost/server-status?auto (or
modify the URL for another host). See your Apache documentation on
how to set up this URL in your httpd.conf. Apache needs ExtendedStatus
enabled for this plugin to work.

Tip: To see if it's already set up correctly, just run this plugin
with the parameter "autoconf". If you get a "yes", everything should
work like a charm already.

This configuration section shows the defaults of the plugin:

  [apache_*]
     env.url   http://127.0.0.1:%d/server-status?auto
     env.ports 80

The %d in the url will be replaced with the port.  The default port is
80 as shown.

The port list is a space separated list of ports.  NOTE that one
single Apache can have several open ports, and the plugin needs only
to contact one to get the servers global status.  The list of ports is
only needed if you have several B<different> Apaches configured on
your host.

If you need authenticated access to the URL you can specify the
username and password in the URL.  For example:

  [apache_volume]
     env.url http://munin:spamalot@localhost/server-status?auto

This will provide for HTTP basic authentication.

=head1 INTERPRETATION

The plugin shows the number of Apache processes running on the
machine, and in addition separate "busy" and "idle" servers count.

If there is a flat ceiling effect on the graph where the number of
servers does not increase any more, in spite of no idle servers, then
the server has probably reached its C<MaxClients> setting.  In this
case it's very likely that some clients are getting connection refused
or some other problem when connecting to your server.  In this case
increase the C<MaxClients> setting.  Unless there is also no more free
memory.

=head1 MAGIC MARKERS

  #%# family=auto
  #%# capabilities=autoconf

=head1 BUGS

Does not support digest authentication.

=head1 VERSION

  $Id: apache_processes.in 3192 2009-12-05 21:11:54Z feiner.tom $

=head1 AUTHOR

Unknown

=head1 LICENSE

GPLv2

=cut

use strict;
use warnings;
use Munin::Plugin;

my $ret = undef;
if (! eval "require LWP::UserAgent;")
{
	$ret = "LWP::UserAgent not found";
        if ( ! defined $ARGV[0] ) {
                die $ret;
        }
}

my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);

if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
{
	if ($ret)
	{
		print "no ($ret)\n";
		exit 0;
	}
	my $ua = LWP::UserAgent->new(timeout => 30);

        foreach my $port (@PORTS) {
                my $url = sprintf $URL, $port;
                my $response = $ua->request(HTTP::Request->new('GET',$url));
                if ($response->is_success) {
                        if ($response->content =~ /^Total Accesses:/im ){
                                next;
                        }
                        else {
                                print "no (ExtendedStatus option for apache" 
				      . " mod_status is missing on port $port)\n";
                                exit 0;
                        }
                }
                elsif ($response->code == 404)  {
                        print "no (apache server-status not found. check if mod_status is enabled)\n";
                        exit 0;
                }
                else {
                        print "no (Port $port: ". $response->message .")\n";
                        exit 0;
                }
	}
	print "yes\n";
	exit 0;
}

if ( defined $ARGV[0] and $ARGV[0] eq "config" )
{
        print "graph_title Apache processes\n";
        print "graph_args --base 1000 -l 0\n";
		print "graph_category apache\n";
	print "graph_order ";
	foreach my $port (@PORTS) {
	    print "busy$port idle$port ";
	}
	print "\n";
        print "graph_vlabel processes\n";
        print "graph_total total\n";
	foreach my $port (@PORTS) {
	    print "busy$port.label busy servers $port\n";
	    if (@PORTS == 1) {
		print "busy$port.draw AREA\n";
		print "busy$port.colour 33cc00\n";
	    }
	    else
	    {
		print "busy$port.draw LINE2\n";
	    }
	    print "idle$port.label idle servers $port\n";
	    print "idle$port.draw STACK\n";
	    print "idle$port.colour 0033ff\n";
	    print "free$port.label free slots $port\n";
	    print "free$port.draw STACK\n";
	    print "free$port.colour ccff00\n";
	}
	foreach my $port (@PORTS) {
		foreach my $type qw "busy idle" {
			print_thresholds("$type$port");
		}
	}
	exit 0;
}

foreach my $port (@PORTS)
{
    my $ua = LWP::UserAgent->new(timeout => 30);
    my $url = sprintf $URL, $port;
    my $response = $ua->request(HTTP::Request->new('GET',$url));
    if ($response->content =~ /^Busy(?:Servers|Workers):\s+(.+)$/im) {
	    print "busy$port.value $1\n";
    } else {
	    print "busy$port.value U\n";
    }
    if ($response->content =~ /^Idle(?:Servers|Workers):\s+(.+)$/im) {
	    print "idle$port.value $1\n";
    } else {
	    print "idle$port.value U\n";
    }
    if ($response->content =~ /^(Scoreboard: .*)$/m) {
	    my $count = () = $1 =~ /\./g;
	    print "free$port.value $count\n";
    } else {
	    print "free$port.value U\n";
    }
}

# vim:syntax=perl