~ubuntu-branches/ubuntu/gutsy/munin/gutsy

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Tore Anderson
  • Date: 2004-05-21 20:51:19 UTC
  • Revision ID: james.westby@ubuntu.com-20040521205119-oz8bllbjp9hs80ig
Tags: upstream-0+1.0.0pre5
ImportĀ upstreamĀ versionĀ 0+1.0.0pre5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@@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.
 
11
#
 
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.
 
15
#
 
16
# Parameters supported:
 
17
#
 
18
#       config
 
19
#       autoconf
 
20
#
 
21
# Configurable variables
 
22
#
 
23
#       url      - Override default status-url
 
24
#
 
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).
 
28
#
 
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.
 
31
#
 
32
# Revision 1.3  2004/01/29 18:47:30  jimmyo
 
33
# Made plugins apache_* compatible with older versions of LWP::UserAgent (SF#881411).
 
34
#
 
35
# Revision 1.2  2004/01/29 18:26:12  jimmyo
 
36
# Bugfix, apache_processes now takes port numbers into account. (SF#882263)
 
37
#
 
38
# Revision 1.1  2004/01/02 18:50:00  jimmyo
 
39
# Renamed occurrances of lrrd -> munin
 
40
#
 
41
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
 
42
# Import of LRRD CVS tree after renaming to Munin
 
43
#
 
44
# Revision 1.4  2003/12/18 16:55:45  jimmyo
 
45
# Enabled multiple ports
 
46
#
 
47
# Revision 1.3  2003/12/18 16:35:33  jimmyo
 
48
# fail more gracefully when using uninstalled perl modules.
 
49
#
 
50
# Revision 1.2  2003/11/07 17:43:16  jimmyo
 
51
# Cleanups and log entries
 
52
#
 
53
#
 
54
#
 
55
# Magic markers:
 
56
#%# family=manual
 
57
#%# capabilities=autoconf
 
58
 
 
59
my $ret = undef;
 
60
if (! eval "require LWP::UserAgent;")
 
61
{
 
62
        $ret = "LWP::UserAgent not found";
 
63
}
 
64
 
 
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);
 
67
 
 
68
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
 
69
{
 
70
        if ($ret)
 
71
        {
 
72
                print "no ($ret)\n";
 
73
                exit 1;
 
74
        }
 
75
        my $ua = LWP::UserAgent->new(timeout => 30);
 
76
        my @badports;
 
77
 
 
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;
 
82
        }
 
83
 
 
84
        if (@badports)
 
85
        {
 
86
                print "no (no apache server-status on ports @badports)\n";
 
87
                exit 1;
 
88
        }
 
89
        else
 
90
        {
 
91
                print "yes\n";
 
92
                exit 0;
 
93
        }
 
94
}
 
95
 
 
96
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
 
97
{
 
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 ";
 
103
        }
 
104
        print "\n";
 
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";
 
109
            if (@PORTS == 1) {
 
110
                print "busy$port.draw AREA\n";
 
111
            }
 
112
            else
 
113
            {
 
114
                print "busy$port.draw LINE2\n";
 
115
            }
 
116
            print "idle$port.label idle servers $port\n";
 
117
            print "idle$port.draw STACK\n";
 
118
        }
 
119
        exit 0;
 
120
}
 
121
 
 
122
foreach my $port (@PORTS)
 
123
{
 
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";
 
129
    } else {
 
130
            print "busy$port.value U\n";
 
131
    }
 
132
    if ($response->content =~ /^Idle(?:Servers|Workers):\s+(.+)$/im) {
 
133
            print "idle$port.value $1\n";
 
134
    } else {
 
135
            print "idle$port.value U\n";
 
136
    }
 
137
}
 
138
 
 
139
# vim:syntax=perl