mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
New plugins for Apache web server
This commit is contained in:
parent
4f29ff59b1
commit
4771fd2b53
5 changed files with 417 additions and 0 deletions
128
plugins/apache/apache_average_requests
Executable file
128
plugins/apache/apache_average_requests
Executable file
|
@ -0,0 +1,128 @@
|
|||
#!/usr/bin/perl
|
||||
# -*- cperl -*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_average_request - Munin plugin to monitor the average request to
|
||||
Apache servers. It handles a list of ports passed in from a plugin
|
||||
configuration file.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Apache HTTP servers with C</server-status> enabled.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
Enable stats in apache first!:
|
||||
|
||||
<VirtualHost 127.0.0.1:80>
|
||||
<Location /server-status>
|
||||
SetHandler server-status
|
||||
AuthUserFile /route/to/auth.file
|
||||
AuthName Login-Stats
|
||||
AuthType Basic
|
||||
require valid-user
|
||||
</Location>
|
||||
</VirtualHost>
|
||||
|
||||
And now in munin conf:
|
||||
|
||||
[apache_*]
|
||||
env.url http://USER:PASS@127.0.0.1/server-status?auto
|
||||
env.ports 80
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
Unknown
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=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 Average apache request\n";
|
||||
print "graph_title Average apache Requests per second\n";
|
||||
print "graph_vlabel average reqs/sec\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_category apache\n";
|
||||
print "request.label Average apache reqs/sec\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->content =~ /^ReqPerSec:\s+(.+)$/im) {
|
||||
print "request.value $1\n";
|
||||
} else {
|
||||
print "request.value U\n";
|
||||
}
|
||||
}
|
||||
|
||||
# vim:syntax=perl
|
70
plugins/apache/apache_memmory
Executable file
70
plugins/apache/apache_memmory
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_memmory -Indicate the medium size of all the apache child process
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[apache_*]
|
||||
env.url http://USER:PASS@127.0.0.1/server-status?auto
|
||||
env.apuser user_runnin_apache
|
||||
env.binname apache_binary_name
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGICK MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
USR=$apuser
|
||||
PROCS=$binname
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Medium size of apache child process.'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel Kb'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category apache'
|
||||
echo 'graph_info Indicate the memdium size of all the apache child process.'
|
||||
|
||||
|
||||
|
||||
echo "servers.label servers"
|
||||
echo "servers.type GAUGE"
|
||||
echo "servers.min 0"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VAL1=`ps auxf | grep ${PROCS} | grep ${USR} | grep -v grep | wc -l`
|
||||
|
||||
VAL2=`ps auxf | grep ${PROCS} | grep ${USR} | grep -v grep | awk '{s+=$6} END {print s}'`
|
||||
|
||||
VAL3=`expr $VAL2 / $VAL1`
|
||||
|
||||
echo "servers.value $VAL3"
|
||||
|
||||
|
65
plugins/apache/apache_servers
Executable file
65
plugins/apache/apache_servers
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_servers -Indicate the number of apache servers running (child process)
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[apache_*]
|
||||
env.url http://USER:PASS@127.0.0.1/server-status?auto
|
||||
env.apuser user_runnin_apache
|
||||
env.binname apache_binary_name
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGICK MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
USR=$apuser
|
||||
PROCS=$binname
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Number of apache servers running.'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel servers'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category apache'
|
||||
echo 'graph_info Indicate the number of apache servers running (child process).'
|
||||
|
||||
|
||||
|
||||
echo "servers.label servers"
|
||||
echo "servers.type GAUGE"
|
||||
echo "servers.min 0"
|
||||
echo "servers.info I/O on nfs"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VAL1=`ps auxf | grep ${PROCS} | grep ${USR} | grep -v grep | wc -l`
|
||||
|
||||
echo "servers.value $VAL1"
|
||||
|
||||
|
89
plugins/apache/apache_threads
Executable file
89
plugins/apache/apache_threads
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_threads -Indicate the memdium number of threads for all child process
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[apache_*]
|
||||
env.url http://USER:PASS@127.0.0.1/server-status?auto
|
||||
env.apuser user_runnin_apache
|
||||
env.binname apache_binary_name
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGICK MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Medium number of threads for child process.'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel Threads'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category apache'
|
||||
echo 'graph_info Indicate the memdium number of threads for all child process.'
|
||||
|
||||
|
||||
|
||||
echo "threads.label threads"
|
||||
echo "threads.type GAUGE"
|
||||
echo "threads.min 0"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SUM=0
|
||||
COUNT=0
|
||||
USR=$apuser
|
||||
PROCS=$binname
|
||||
|
||||
|
||||
# Catch proccess pid
|
||||
VAL1=`ps auxf | grep ${PROCS} | grep ${USR} | grep -v grep | awk '{print $2}' `
|
||||
|
||||
# Count pids
|
||||
COUNT=`ps auxf | grep ${PROCS} | grep ${USR} | grep -v grep | wc -l`
|
||||
|
||||
# Read threads per pid
|
||||
for i in $VAL1; do
|
||||
|
||||
VAL2="$VAL2 `cat /proc/$i/status | grep 'Threads:' | awk '{print $2}'`"
|
||||
done
|
||||
|
||||
# Sun threads
|
||||
for z in ${VAL2}; do
|
||||
|
||||
SUM=`expr $SUM + $z`
|
||||
|
||||
done
|
||||
|
||||
|
||||
echo "threads.value `echo $((SUM / $COUNT))`"
|
||||
|
||||
|
||||
|
||||
|
||||
|
65
plugins/apache/apache_tmemmory
Executable file
65
plugins/apache/apache_tmemmory
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
apache_tmemmory -Indicate the total memory used by apache
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[apache_*]
|
||||
env.url http://USER:PASS@127.0.0.1/server-status?auto
|
||||
env.binname apache_binary_name
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Fraile <rfrail3@yahoo.es>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=head1 MAGICK MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
|
||||
USR=$apuser
|
||||
PROCS=$binname
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Total memory used by apache'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel Mb'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_category apache'
|
||||
echo 'graph_info Indicate the total memory used by apache.'
|
||||
|
||||
echo "servers.label servers"
|
||||
echo "servers.type GAUGE"
|
||||
echo "servers.min 0"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VAL1=`ps auxf | grep ${PROCS} | grep -v grep | awk '{s+=$6} END {print s}'`
|
||||
|
||||
VAL2=`expr $VAL1 / 1024`
|
||||
|
||||
echo "servers.value $VAL2"
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue