source: trunk/munin-plugins/apachessl_processes @ 37

Last change on this file since 37 was 22, checked in by sebas, 17 years ago

la dependance.... a ne pas oublier.

  • Property svn:executable set to *
File size: 4.2 KB
RevLine 
[21]1#!/usr/bin/perl
2#
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.
6#
7# Requirements:
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.
[22]11#       - also requires libcrypt-ssleay-perl
[21]12#
13# Tip: To see if it's already set up correctly, just run this plugin
14# with the parameter "autoconf". If you get a "yes", everything should
15# work like a charm already.
16#
17# Parameters supported:
18#
19#       config
20#       autoconf
21#
22# Configurable variables
23#
24#       urls      - Override default status-url (SSL)
25#       ports     - HTTPS ports numbers (SSL)
26#
27# $Log$
28# Revision 1.8  2006/03/07 20:30:00  fra519
29# modified for Apache SSL Server.
30#
31# Revision 1.7.2.1  2005/02/24 17:51:08  jimmyo
32# modified graph_args of generic/apache_processes, to work around an rrdtool bug (Deb#296528).
33#
34# Revision 1.7  2004/05/20 13:57:11  jimmyo
35# Set categories to some of the plugins.
36#
37# Revision 1.6  2004/05/14 21:16:46  jimmyo
38# "Upped" som plugins from contrib/manual to auto.
39#
40# Revision 1.5  2004/04/27 08:46:57  jimmyo
41# Fixed broken autoconf in apache-* plugins (Deb#236144).
42#
43# Revision 1.4  2004/02/03 17:17:25  jimmyo
44# Generic/apache-plugins have been modified to properly to report the correct autoconf value. Also, bugfixes in _processes and _volume.
45#
46# Revision 1.3  2004/01/29 18:47:30  jimmyo
47# Made plugins apache_* compatible with older versions of LWP::UserAgent (SF#881411).
48#
49# Revision 1.2  2004/01/29 18:26:12  jimmyo
50# Bugfix, apache_processes now takes port numbers into account. (SF#882263)
51#
52# Revision 1.1  2004/01/02 18:50:00  jimmyo
53# Renamed occurrances of lrrd -> munin
54#
55# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
56# Import of LRRD CVS tree after renaming to Munin
57#
58# Revision 1.4  2003/12/18 16:55:45  jimmyo
59# Enabled multiple ports
60#
61# Revision 1.3  2003/12/18 16:35:33  jimmyo
62# fail more gracefully when using uninstalled perl modules.
63#
64# Revision 1.2  2003/11/07 17:43:16  jimmyo
65# Cleanups and log entries
66#
67#
68#
69# Magic markers:
70#%# family=auto
71#%# capabilities=autoconf
72
73my $ret = undef;
74if (! eval "require LWP::UserAgent;")
75{
76        $ret = "LWP::UserAgent not found";
77}
78if (! eval "require Crypt::SSLeay;")
79{
80        $ret = "Crypt::SSLeay not found";
81}
82
83my $URLS = exists $ENV{'urls'} ? $ENV{'urls'} : "https://127.0.0.1:%d/server-status?auto";
84my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (443);
85
86if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
87{
88        if ($ret)
89        {
90                print "no ($ret)\n";
91                exit 1;
92        }
93        my $ua = LWP::UserAgent->new(timeout => 30);
94        my @badports;
95
96        foreach my $port (@PORTS) {
97                my $url = sprintf $URLS, $port;
98                my $response = $ua->request(HTTP::Request->new('GET',$url));
99                push @badports, $port unless $response->is_success and $response->content =~ /Idle(?:Servers|Workers)/im;
100        }
101
102        if (@badports)
103        {
104                print "no (no apache server-status on ports @badports)\n";
105                exit 1;
106        }
107        else
108        {
109                print "yes\n";
110                exit 0;
111        }
112}
113
114if ( exists $ARGV[0] and $ARGV[0] eq "config" )
115{
116        print "graph_title ApacheSSL processes\n";
117        print "graph_args --base 1000 -l 0\n";
118        print "graph_category apache\n";
119        print "graph_order ";
120        foreach my $port (@PORTS) {
121            print "busy$port idle$port ";
122        }
123        print "\n";
124        print "graph_vlabel processes\n";
125        print "graph_total total\n";
126        foreach my $port (@PORTS) {
127            print "busy$port.label busy servers $port\n";
128            if (@PORTS == 1) {
129                print "busy$port.draw AREA\n";
130            }
131            else
132            {
133                print "busy$port.draw LINE2\n";
134            }
135            print "idle$port.label idle servers $port\n";
136            print "idle$port.draw STACK\n";
137        }
138        exit 0;
139}
140
141foreach my $port (@PORTS)
142{
143    my $ua = LWP::UserAgent->new(timeout => 30);
144    my $url = sprintf $URLS, $port;
145    my $response = $ua->request(HTTP::Request->new('GET',$url));
146    if ($response->content =~ /^Busy(?:Servers|Workers):\s+(.+)$/im) {
147            print "busy$port.value $1\n";
148    } else {
149            print "busy$port.value U\n";
150    }
151    if ($response->content =~ /^Idle(?:Servers|Workers):\s+(.+)$/im) {
152            print "idle$port.value $1\n";
153    } else {
154            print "idle$port.value U\n";
155    }
156}
157
158# vim:syntax=perl
Note: See TracBrowser for help on using the repository browser.