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
|
#!@@PERL@@
#
# Plugin to monitor the number of apache-processes running on the
# machine, and (in addition to a simple process count), separate then
# into "busy" or "idle" servers.
#
# Requirements:
# - Needs access to http://localhost/server-status?auto (or modify the
# address for another host). See your apache documentation on how to
# set up this url in your httpd.conf.
#
# 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.
#
# Parameters supported:
#
# config
# autoconf
#
# Configurable variables
#
# url - Override default status-url
#
# $Log$
# Revision 1.7.2.1 2005/02/24 17:51:08 jimmyo
# modified graph_args of generic/apache_processes, to work around an rrdtool bug (Deb#296528).
#
# Revision 1.7 2004/05/20 13:57:11 jimmyo
# Set categories to some of the plugins.
#
# Revision 1.6 2004/05/14 21:16:46 jimmyo
# "Upped" som plugins from contrib/manual to auto.
#
# Revision 1.5 2004/04/27 08:46:57 jimmyo
# Fixed broken autoconf in apache-* plugins (Deb#236144).
#
# Revision 1.4 2004/02/03 17:17:25 jimmyo
# Generic/apache-plugins have been modified to properly to report the correct autoconf value. Also, bugfixes in _processes and _volume.
#
# Revision 1.3 2004/01/29 18:47:30 jimmyo
# Made plugins apache_* compatible with older versions of LWP::UserAgent (SF#881411).
#
# Revision 1.2 2004/01/29 18:26:12 jimmyo
# Bugfix, apache_processes now takes port numbers into account. (SF#882263)
#
# Revision 1.1 2004/01/02 18:50:00 jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.4 2003/12/18 16:55:45 jimmyo
# Enabled multiple ports
#
# Revision 1.3 2003/12/18 16:35:33 jimmyo
# fail more gracefully when using uninstalled perl modules.
#
# Revision 1.2 2003/11/07 17:43:16 jimmyo
# Cleanups and log entries
#
#
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
my $ret = undef;
if (! eval "require LWP::UserAgent;")
{
$ret = "LWP::UserAgent not found";
}
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 ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
if ($ret)
{
print "no ($ret)\n";
exit 1;
}
my $ua = LWP::UserAgent->new(timeout => 30);
my @badports;
foreach my $port (@PORTS) {
my $url = sprintf $URL, $port;
my $response = $ua->request(HTTP::Request->new('GET',$url));
push @badports, $port unless $response->is_success and $response->content =~ /Idle(?:Servers|Workers)/im;
}
if (@badports)
{
print "no (no apache server-status on ports @badports)\n";
exit 1;
}
else
{
print "yes\n";
exit 0;
}
}
if ( exists $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";
}
else
{
print "busy$port.draw LINE2\n";
}
print "idle$port.label idle servers $port\n";
print "idle$port.draw STACK\n";
}
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";
}
}
# vim:syntax=perl
|