3
# Plugin to monitor the number of apache-processes running on the
4
# machine, and (in addition to a simple process count), separate then
5
# into "busy" or "idle" servers.
8
# - Needs access to http://localhost/server-status?auto (or modify the
9
# address for another host). See your apache documentation on how to
10
# set up this url in your httpd.conf.
12
# Tip: To see if it's already set up correctly, just run this plugin
13
# with the parameter "autoconf". If you get a "yes", everything should
14
# work like a charm already.
16
# Parameters supported:
21
# Configurable variables
23
# url - Override default status-url
25
# $Log: apache_processes.in,v $
26
# Revision 1.5 2004/04/27 08:46:57 jimmyo
27
# Fixed broken autoconf in apache-* plugins (Deb#236144).
29
# Revision 1.4 2004/02/03 17:17:25 jimmyo
30
# Generic/apache-plugins have been modified to properly to report the correct autoconf value. Also, bugfixes in _processes and _volume.
32
# Revision 1.3 2004/01/29 18:47:30 jimmyo
33
# Made plugins apache_* compatible with older versions of LWP::UserAgent (SF#881411).
35
# Revision 1.2 2004/01/29 18:26:12 jimmyo
36
# Bugfix, apache_processes now takes port numbers into account. (SF#882263)
38
# Revision 1.1 2004/01/02 18:50:00 jimmyo
39
# Renamed occurrances of lrrd -> munin
41
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
42
# Import of LRRD CVS tree after renaming to Munin
44
# Revision 1.4 2003/12/18 16:55:45 jimmyo
45
# Enabled multiple ports
47
# Revision 1.3 2003/12/18 16:35:33 jimmyo
48
# fail more gracefully when using uninstalled perl modules.
50
# Revision 1.2 2003/11/07 17:43:16 jimmyo
51
# Cleanups and log entries
57
#%# capabilities=autoconf
60
if (! eval "require LWP::UserAgent;")
62
$ret = "LWP::UserAgent not found";
65
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto";
66
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
68
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
75
my $ua = LWP::UserAgent->new(timeout => 30);
78
foreach my $port (@PORTS) {
79
my $url = sprintf $URL, $port;
80
my $response = $ua->request(HTTP::Request->new('GET',$url));
81
push @badports, $port unless $response->is_success and $response->content =~ /Idle(?:Servers|Workers)/im;
86
print "no (no apache server-status on ports @badports)\n";
96
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
98
print "graph_title Apache processes\n";
99
print "graph_args --base 1000\n";
100
print "graph_order ";
101
foreach my $port (@PORTS) {
102
print "busy$port idle$port ";
105
print "graph_vlabel processes\n";
106
print "graph_total total\n";
107
foreach my $port (@PORTS) {
108
print "busy$port.label busy servers $port\n";
110
print "busy$port.draw AREA\n";
114
print "busy$port.draw LINE2\n";
116
print "idle$port.label idle servers $port\n";
117
print "idle$port.draw STACK\n";
122
foreach my $port (@PORTS)
124
my $ua = LWP::UserAgent->new(timeout => 30);
125
my $url = sprintf $URL, $port;
126
my $response = $ua->request(HTTP::Request->new('GET',$url));
127
if ($response->content =~ /^Busy(?:Servers|Workers):\s+(.+)$/im) {
128
print "busy$port.value $1\n";
130
print "busy$port.value U\n";
132
if ($response->content =~ /^Idle(?:Servers|Workers):\s+(.+)$/im) {
133
print "idle$port.value $1\n";
135
print "idle$port.value U\n";