mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
98
plugins/apache/apache_activity
Executable file
98
plugins/apache/apache_activity
Executable file
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Parameters supported:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configurable variables
|
||||
#
|
||||
# url - Override default status-url
|
||||
#
|
||||
# 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);
|
||||
my %chars = (
|
||||
# '\_' => 'Waiting',
|
||||
# 'S' => 'Starting up',
|
||||
'R' => 'Reading request',
|
||||
'W' => 'Sending reply',
|
||||
'K' => 'Keepalive',
|
||||
'D' => 'DNS lookup',
|
||||
'C' => 'Closing',
|
||||
# 'L' => 'Logging',
|
||||
# 'G' => 'Gracefully finishing',
|
||||
# 'I' => 'Idle cleanup',
|
||||
# '\.' => 'Open slot',
|
||||
);
|
||||
|
||||
# "_" Waiting for Connection, "S" Starting up, "R" Reading Request,
|
||||
# "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
|
||||
# "C" Closing connection, "L" Logging, "G" Gracefully finishing,
|
||||
# "I" Idle cleanup of worker, "." Open slot with no current process
|
||||
|
||||
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 =~ /Scoreboard/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 activity\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category apache\n";
|
||||
print "graph_vlabel processes\n";
|
||||
foreach my $port (@PORTS) {
|
||||
while (my ($char, $val) = each (%chars)) {
|
||||
$char =~ s/\\\./dot/;
|
||||
$char =~ s/\\\_/underline/;
|
||||
print "activity_${port}_${char}.label ";
|
||||
print $val, "\n";
|
||||
print "activity_${port}_${char}.type GAUGE\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 =~ /^Scoreboard\:\s?(.*)$/sm) {
|
||||
my $string = $1;
|
||||
chomp $string;
|
||||
my @act = split (//, $string);
|
||||
foreach my $char (keys (%chars)) {
|
||||
my $num = scalar (grep (/$char/, @act));
|
||||
$char =~ s/\\\./dot/;
|
||||
$char =~ s/\\\_/underline/;
|
||||
print "activity_${port}_${char}.value $num\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
103
plugins/apache/apache_average_time_last_n_requests
Executable file
103
plugins/apache/apache_average_time_last_n_requests
Executable file
|
@ -0,0 +1,103 @@
|
|||
#!/usr/bin/perl -w
|
||||
# $Id$
|
||||
# Author: Nicolas Mendoza <nicolasm@opera.com> - 2008-06-18
|
||||
#
|
||||
# Monitors the average time requests matching a custom regexp takes
|
||||
# For instance monitor time execution of files in http://example.com/foo/bar,
|
||||
# requests from google, images etc.
|
||||
#
|
||||
# Simply add an entry in the 'type' hashref and modify the description fields
|
||||
# for munin, and make the 'matches' member contain a subref that returns
|
||||
# true if a request matches, parameters are a list containing the request
|
||||
# split on spaces.
|
||||
#
|
||||
# NOTE: You need to add a field in your Apache logs showing time executed.
|
||||
# This is normally done using the %T (seconds) or %D (microseconds)
|
||||
# For instance:
|
||||
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %T %v"
|
||||
# Check http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats for more info
|
||||
|
||||
use strict;
|
||||
|
||||
my $LAST_N_REQUESTS = 100000; # calculate based on this amount of requests
|
||||
my $ACCESS_LOG_PATTERN = '/var/log/apache2/access.log.*'; # log pattern, if many it will take the last one.
|
||||
my $TIME_FIELD_INDEX = -2; # second last field
|
||||
|
||||
my $config =<< "CONFIG"
|
||||
graph_title Apache average seconds last $LAST_N_REQUESTS requests
|
||||
graph_args --base 1000
|
||||
graph_scale no
|
||||
graph_vlabel Average request time
|
||||
graph_category Apache
|
||||
graph_info This graph shows average request times for the last $LAST_N_REQUESTS requests
|
||||
CONFIG
|
||||
;
|
||||
|
||||
my $types = {
|
||||
# any kind of request
|
||||
total => {
|
||||
munin_fields => {
|
||||
label => 'All requests',
|
||||
draw => 'LINE2',
|
||||
info => 'Average seconds per any request',
|
||||
},
|
||||
sum => 0,
|
||||
lines => 0,
|
||||
matches => sub {
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
|
||||
# image requests
|
||||
images => {
|
||||
munin_fields => {
|
||||
label => 'Image requests',
|
||||
draw => 'LINE2',
|
||||
info => 'Average seconds per image request',
|
||||
},
|
||||
sum => 0,
|
||||
lines => 0,
|
||||
matches => sub {
|
||||
my ($fields) = @_;
|
||||
my $script;
|
||||
($script = $fields->[6]) =~ s/\?.*\z //mx;
|
||||
return $script =~ m{ \.(png|jpe?g|jpg|gif|tiff|ilbm|tga) \z }mx;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (defined(@ARGV) && ($ARGV[0] eq 'config')) {
|
||||
|
||||
print $config;
|
||||
|
||||
foreach my $type (keys %{$types}) {
|
||||
foreach my $key (keys %{$types->{$type}->{'munin_fields'}}) {
|
||||
printf "%s.%s %s\n", ($type, $key, $types->{$type}->{'munin_fields'}->{$key});
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
my $config_file = `ls -1 $ACCESS_LOG_PATTERN | tail -n 1`;
|
||||
|
||||
chomp $config_file;
|
||||
|
||||
my @lines = `tail -n $LAST_N_REQUESTS "$config_file"`;
|
||||
|
||||
foreach my $line (@lines) {
|
||||
foreach my $type (keys %{$types}) {
|
||||
my @fields = split /\s+/, $line;
|
||||
if ($types->{$type}->{'matches'}(\@fields)) {
|
||||
$types->{$type}->{'sum'} += $fields[$TIME_FIELD_INDEX];
|
||||
$types->{$type}->{'lines'}++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $type (keys %{$types}) {
|
||||
my $value = $types->{$type}->{'lines'} ? $types->{$type}->{'sum'} / $types->{$type}->{'lines'} : 'U';
|
||||
printf "%s.value %s\n", ($type, $value);
|
||||
}
|
||||
|
||||
|
||||
|
41
plugins/apache/apache_request_rate
Executable file
41
plugins/apache/apache_request_rate
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'rubygems'
|
||||
require 'json'
|
||||
require 'open-uri'
|
||||
|
||||
if ARGV.first == 'config'
|
||||
puts 'graph_category Apache'
|
||||
puts 'graph_title Requests per second'
|
||||
puts 'graph_vlabel reqs/sec'
|
||||
puts 'graph_scale no'
|
||||
puts 'requests_per_second.label Apache reqs/sec'
|
||||
exit 0
|
||||
end
|
||||
|
||||
STATUS_URL = 'http://localhost/server-status?auto'
|
||||
TMPFILE = '/tmp/apache-status-monitor'
|
||||
SECONDS_BEFORE_STALE = 900
|
||||
|
||||
begin
|
||||
previous_sample = File.exists?(TMPFILE) ? JSON.parse(File.open(TMPFILE, 'r').read) : {}
|
||||
output = {}
|
||||
|
||||
apache_status = open(STATUS_URL).read
|
||||
new_total_requests = apache_status.match(/Total Accesses: (\d+)$/)[1].to_i #subtract one to account for request we just made!
|
||||
sample_duration = previous_sample['updated_at'] ? Time.now - Time.at(previous_sample['updated_at'].to_i) : nil
|
||||
|
||||
if sample_duration && sample_duration < SECONDS_BEFORE_STALE
|
||||
output['requests_per_second'] = "%0.2f" % ((new_total_requests - 1 - previous_sample['total_requests'].to_i) / sample_duration.to_f)
|
||||
else
|
||||
output = {}
|
||||
end
|
||||
|
||||
# Write back to tmpfile
|
||||
new_tmp_data = {'total_requests' => new_total_requests, 'updated_at' => Time.now.to_i}
|
||||
File.open(TMPFILE, 'w') { |f| f.puts(new_tmp_data.to_json)}
|
||||
|
||||
puts "requests_per_second.value #{output['requests_per_second']}"
|
||||
rescue Exception => e
|
||||
puts "Exception: #{e.message}"
|
||||
exit -1
|
||||
end
|
97
plugins/apache/apache_smaps
Executable file
97
plugins/apache/apache_smaps
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# This plugin watches the Linux kernel SMAPS memory usage statistics
|
||||
# available in kernel revisions later than 2.6.14. It watches only the
|
||||
# Apache 2 processes, and creates averages, maximums and minimums for
|
||||
# a given moment in time for the shared size and the virtual size of
|
||||
# the processes. This is useful for estimating the constraints to give
|
||||
# to Apache2::SizeLimit.
|
||||
|
||||
# Author: Kjetil Kjernsmo <kjetilk@opera.com>, based on work by William Viker
|
||||
# Copyright (C) 2007 Opera Software ASA
|
||||
#
|
||||
# Contibutors: Earle Nietzel <earle.nietzel@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
use strict;
|
||||
|
||||
my $ret = undef;
|
||||
if (!eval "require Linux::Smaps;") {
|
||||
$ret = "Linux::Smaps not found, fix with cpan -i Linux::Smaps";
|
||||
}
|
||||
|
||||
# allow process name and process user to be specified
|
||||
my $PNAME = exists $ENV{'pname'} ? $ENV{'pname'} : "httpd";
|
||||
my $PUSER = exists $ENV{'puser'} ? $ENV{'puser'} : "apache";
|
||||
|
||||
if (defined(@ARGV) && ($ARGV[0] eq 'config')) {
|
||||
print "graph_title Apache Smaps\n";
|
||||
print "graph_args --base 1024 -l 0\n";
|
||||
print "graph_vlabel Bytes\n";
|
||||
print "graph_category apache\n";
|
||||
print "graph_info This graph shows memory usage for each given process.\n";
|
||||
|
||||
print "shr_max.label Shared memory max\n";
|
||||
print "shr_max.draw LINE2\n";
|
||||
print "shr_max.info Max shared memory.\n";
|
||||
print "shr_min.label Shared memory min\n";
|
||||
print "shr_min.draw LINE2\n";
|
||||
print "shr_min.info Minimum shared memory.\n";
|
||||
print "shr_avg.label Shared memory average\n";
|
||||
print "shr_avg.draw LINE2\n";
|
||||
print "shr_avg.info Average shared memory.\n";
|
||||
|
||||
print "vsz_max.label Virtual memory max\n";
|
||||
print "vsz_max.draw LINE2\n";
|
||||
print "vsz_max.info Max Virtual memory.\n";
|
||||
print "vsz_min.label Virtual memory min\n";
|
||||
print "vsz_min.draw LINE2\n";
|
||||
print "vsz_min.info Minimum Virtual memory.\n";
|
||||
print "vsz_avg.label Virtual memory avg\n";
|
||||
print "vsz_avg.draw LINE2\n";
|
||||
print "vsz_avg.info Average Virtual memory.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
my $i = 0;
|
||||
my $max_shared = 0;
|
||||
my $sum_shared = 0;
|
||||
my $min_shared = 1171541713117116171; # An insanely high number
|
||||
my $max_virt = 0;
|
||||
my $sum_virt = 0;
|
||||
my $min_virt = 1171541713117116171; # An insanely high number
|
||||
for my $pid (split(/\n/,`pgrep -x $PNAME -u $PUSER`)) {
|
||||
my $map = Linux::Smaps->new($pid);
|
||||
$i++;
|
||||
my $shared = $map->shared_clean + $map->shared_dirty;
|
||||
my $size = $map->size;
|
||||
$sum_shared += $shared;
|
||||
$max_shared = $shared if ($shared > $max_shared);
|
||||
$min_shared = $shared if ($shared < $min_shared);
|
||||
$sum_virt += $size;
|
||||
$max_virt = $size if ($size > $max_virt);
|
||||
$min_virt = $size if ($size < $min_virt);
|
||||
}
|
||||
|
||||
# if no processes were found prevents divide by 0
|
||||
if ($i gt 0) {
|
||||
print "shr_max.value $max_shared\n";
|
||||
print "shr_min.value $min_shared\n";
|
||||
print "shr_avg.value ".$sum_shared/$i."\n";
|
||||
print "vsz_max.value $max_virt\n";
|
||||
print "vsz_min.value $min_virt\n";
|
||||
print "vsz_avg.value ".$sum_virt/$i."\n";
|
||||
}
|
170
plugins/apache/apache_users
Executable file
170
plugins/apache/apache_users
Executable file
|
@ -0,0 +1,170 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# apache_users - Munin plugin, displays traffic by user
|
||||
#
|
||||
# Version: 03.06.2009
|
||||
# Author: Rainer Wolff <rainer.wolff@gmx.com>
|
||||
#
|
||||
# ################################################################################ MAGIC MARKERS
|
||||
|
||||
#%# family=contrib
|
||||
#%# capabilities=autoconf
|
||||
|
||||
# ####################################################################################### CONFIG
|
||||
|
||||
DIRECTORY=${MUNIN_PLUGINSTATE:-/var/lib/munin/plugin-state/apache_users}
|
||||
TIMESTAMP=$DIRECTORY/.apache_users
|
||||
ACCESSLOG=/var/log/apache2/access_log
|
||||
|
||||
# ##################################################################################### AUTOCONF
|
||||
|
||||
if [ "$1" = "autoconf" ]
|
||||
then
|
||||
if ! ls $ACCESSLOG > /dev/null
|
||||
then
|
||||
echo "no (could not find apache access log \"$ACCESSLOG\")"
|
||||
exit 1
|
||||
elif ! ls $DIRECTORY > /dev/null
|
||||
then
|
||||
echo "no (could not find munin plugins directory \"$DIRECTORY\")"
|
||||
exit 2
|
||||
|
||||
else
|
||||
echo "yes"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# ######################################################################################### INIT
|
||||
|
||||
# Define regex for all possible timestamps of last 5 minutes block
|
||||
REGEX=$(LC_ALL=en_US date -d "5 minutes ago" "+\[%d\/%b\/%Y:%H: %M :[0-5][0-9] %z\]" \
|
||||
| awk '{ printf "%s(%02d|%02d|%02d|%02d|%02d)%s", $1, $2-$2%5, $2-$2%5+1, $2-$2%5+2, $2-$2%5+3, $2-$2%5+4, $3 }')
|
||||
|
||||
|
||||
# Analyse logfile
|
||||
while read REQUEST_ADDR REQUEST_USERNAME REQUEST_BYTES
|
||||
do
|
||||
# Name resolution for known adresses
|
||||
REQUEST_DOMAIN=$( awk '/^'"$REQUEST_ADDR"'/ { print $2 }' /etc/hosts )
|
||||
REQUEST_ADDR=${REQUEST_DOMAIN:-$REQUEST_ADDR}
|
||||
|
||||
|
||||
# Scan for known addresses, if found, sum up traffic
|
||||
FOUND=false
|
||||
for (( I=${#ADDR[@]}-1; I>=0; I-- ))
|
||||
do
|
||||
# Address known, name maybe, anonymous access (again)
|
||||
if [ "${ADDR[I]}" == "$REQUEST_ADDR" -a "$REQUEST_USERNAME" == "-" ]
|
||||
then
|
||||
FOUND=true
|
||||
BYTES[$I]=$(( ${BYTES[I]} + $REQUEST_BYTES ))
|
||||
break
|
||||
|
||||
# Known address and name
|
||||
elif [ "${ADDR[I]}" == "$REQUEST_ADDR" -a "${USERNAME[I]}" == "$REQUEST_USERNAME" ]
|
||||
then
|
||||
FOUND=true
|
||||
BYTES[$I]=$(( ${BYTES[I]} + $REQUEST_BYTES ))
|
||||
break
|
||||
|
||||
# Known address, previous access anonymous
|
||||
elif [ "${ADDR[I]}" == "$REQUEST_ADDR" -a "${USERNAME[I]}" == "-" ]
|
||||
then
|
||||
FOUND=true
|
||||
USERNAME[$I]="$REQUEST_USERNAME"
|
||||
BYTES[$I]=$(( ${BYTES[I]} + $REQUEST_BYTES ))
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Combination of address and name unknown, create new entry
|
||||
if [ "$FOUND" == "false" ]
|
||||
then
|
||||
ADDR[${#ADDR[@]}]=$REQUEST_ADDR
|
||||
USERNAME[${#USERNAME[@]}]="$REQUEST_USERNAME"
|
||||
BYTES[${#BYTES[@]}]=$REQUEST_BYTES
|
||||
fi
|
||||
|
||||
done < <( awk '/'"$REGEX"'/ { printf "%s %s %d\n", $1, $3, $10 }' $ACCESSLOG )
|
||||
|
||||
|
||||
# Assign anonymous access when possible and correct identifiers
|
||||
for (( I=0; I<${#USERNAME[@]}; I++ ))
|
||||
do
|
||||
if [ "${USERNAME[I]}" == "-" ]
|
||||
then
|
||||
if $( echo "${ADDR[I]}" | egrep -q "[^0-9.]" )
|
||||
then
|
||||
USERNAME[$I]="${ADDR[I]}"
|
||||
else
|
||||
USERNAME[$I]="anonymous"
|
||||
fi
|
||||
NAME[$I]="_${USERNAME[I]}" # Output sort order
|
||||
else
|
||||
NAME[$I]="${USERNAME[I]}"
|
||||
fi
|
||||
|
||||
NAME[$I]="$( echo "${NAME[I]}" \
|
||||
| sed "s/^[^A-Za-z_]/_/" | sed "s/[^A-Za-z0-9_]/_/g" \
|
||||
| sed "s/^\(.\{,19\}\).*/\1/" )"
|
||||
done
|
||||
|
||||
# Create timestamp
|
||||
mkdir -p $DIRECTORY
|
||||
touch -d "-1 second" $TIMESTAMP # find needs time span
|
||||
|
||||
# Aggregate parallel traffic
|
||||
for (( I=0; I<${#NAME[@]}; I++ ))
|
||||
do
|
||||
if [ -z "$( find $DIRECTORY -name "${NAME[I]}" -newer $TIMESTAMP )" ]
|
||||
then
|
||||
echo "${NAME[I]} ${BYTES[I]} ${USERNAME[I]}" > $DIRECTORY/${NAME[I]}
|
||||
else
|
||||
awk '{ printf "%s %d %s", $1, $2+${BYTES[I]}, $3 }' $DIRECTORY/${NAME[I]} > $DIRECTORY/${NAME[I]}
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# ####################################################################################### CONFIG
|
||||
|
||||
if [ "$1" = "config" ]
|
||||
then
|
||||
echo "graph_title Apache users"
|
||||
echo "graph_vlabel bytes per five minute period"
|
||||
echo "graph_args --lower-limit 1 --base 1024 --logarithmic"
|
||||
echo "graph_category Apache"
|
||||
echo "graph_total total"
|
||||
echo "graph_info Webserver traffic by user."
|
||||
|
||||
FILENAMES=$( find $DIRECTORY -type f -not -wholename $TIMESTAMP | sort)
|
||||
|
||||
awk '{ printf "%s.label %s\n%s.draw AREA\n", $1, $3, $1 }' $( echo "$FILENAMES" | head -n1 )
|
||||
|
||||
for FILENAME in $( echo "$FILENAMES" | tail -n+2)
|
||||
do
|
||||
awk '{ printf "%s.label %s\n%s.draw STACK\n", $1, $3, $1 }' $FILENAME
|
||||
done
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# ######################################################################################## VALUE
|
||||
|
||||
{
|
||||
|
||||
for FILENAME in $( find $DIRECTORY -type f -newer $TIMESTAMP -not -wholename $TIMESTAMP )
|
||||
do
|
||||
awk '{ printf "%s.value %d\n", $1, $2 }' $FILENAME
|
||||
done
|
||||
|
||||
for FILENAME in $( find $DIRECTORY -type f -not -newer $TIMESTAMP -not -wholename $TIMESTAMP )
|
||||
do
|
||||
awk '{ printf "%s.value 0\n", $1 }' $FILENAME
|
||||
done
|
||||
|
||||
} | sort
|
||||
|
||||
exit 0
|
||||
|
126
plugins/apache/apache_watch_
Executable file
126
plugins/apache/apache_watch_
Executable file
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Parameters supported:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configurable variables
|
||||
#
|
||||
# url - Override default status-url
|
||||
#
|
||||
# Must be symlinked to what the graph should monitor. Run with --suggest
|
||||
# to see valid targets - or just run munin-node-configure --shell
|
||||
#
|
||||
# Written by Bjørn Ruberg 2006-2007
|
||||
#
|
||||
# Magic markers:
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
my $ret = undef;
|
||||
if (!eval "require LWP::UserAgent;") {
|
||||
$ret = "LWP::UserAgent not found";
|
||||
}
|
||||
|
||||
# watch-list exists on localhost
|
||||
# watch-info does not
|
||||
|
||||
my %plugs = (
|
||||
'bytes' => 'Input/output (bytes)',
|
||||
'requests' => 'Requests',
|
||||
'documents' => 'Documents served',
|
||||
);
|
||||
|
||||
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://localhost:%d/watch-list";
|
||||
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
|
||||
my $type = "throughput";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (@badports) {
|
||||
print "no (no mod_watch exists on ports @badports)\n";
|
||||
exit 1;
|
||||
} else {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (exists $ARGV[0] and $ARGV[0] eq "suggest") {
|
||||
while (my ($key, undef) = each %plugs) {
|
||||
print "$key\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my @servers = ();
|
||||
my @data;
|
||||
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));
|
||||
foreach my $string (split (/\n/, $response->content)) {
|
||||
my ($server, undef, $ifInOctets, $ifOutOctets, $ifRequests,
|
||||
$ifDocuments) = split (/\s/, $string, 6);
|
||||
push @servers, $server unless $server eq "SERVER";
|
||||
push @data, "$server $ifInOctets $ifOutOctets $ifRequests $ifDocuments"
|
||||
unless $server eq "SERVER";
|
||||
}
|
||||
}
|
||||
|
||||
# From here and out, the plugin must be run with a symlinked service.
|
||||
my $check = join ("|", keys %plugs);
|
||||
die ("Plugin must be symlinked to aspect to be monitored")
|
||||
unless $0 =~ /\_($check)$/;
|
||||
|
||||
my $action = $1;
|
||||
|
||||
if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title Apache $plugs{$action}\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_category apache\n";
|
||||
print "graph_vlabel activity\n";
|
||||
my $i = 0;
|
||||
foreach my $server (sort (@servers)) {
|
||||
(my $txtserver = $server) =~ s/(-|\.)/\_/g;
|
||||
my $draw = ($i==0) ? 'AREA' : 'STACK';
|
||||
if ($action eq "bytes") {
|
||||
print "${txtserver}.label $server\n";
|
||||
print "${txtserver}.draw $draw\n";
|
||||
print "${txtserver}.type COUNTER\n";
|
||||
} else {
|
||||
print "${txtserver}.label $server\n";
|
||||
print "${txtserver}.draw $draw\n";
|
||||
print "${txtserver}.type COUNTER\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $string (sort (@data)) {
|
||||
my ($server, $ifInOctets, $ifOutOctets, $ifRequests, $ifDocuments) =
|
||||
split (/\s/, $string);
|
||||
(my $txtserver = $server) =~ s/(-|\.)/\_/g;
|
||||
if ($action eq "documents") {
|
||||
print "${txtserver}.value $ifDocuments\n";
|
||||
} elsif ($action eq "requests") {
|
||||
print "${txtserver}.value $ifRequests\n";
|
||||
} elsif ($action eq "bytes") {
|
||||
print "${txtserver}.value " . ($ifInOctets + $ifOutOctets) . "\n";
|
||||
}
|
||||
}
|
||||
|
131
plugins/apache/eaccelerator
Executable file
131
plugins/apache/eaccelerator
Executable file
|
@ -0,0 +1,131 @@
|
|||
#!/bin/sh
|
||||
#################################################################
|
||||
#
|
||||
# Script to monitor eaccelerator usage
|
||||
# This code works only with mod_php or PHP in fastcgi, read here why in Requirements section : http://eaccelerator.net/wiki/InstallFromSource
|
||||
#
|
||||
#################################################################
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#################################################################
|
||||
#
|
||||
# Requirements
|
||||
# - web server with PHP and eaccelerator enabled
|
||||
# - php file placed on web server , paste there below code (strip hash files first)
|
||||
#
|
||||
# <?php
|
||||
# $error_reporting(E_NONE);
|
||||
# // notice keys orders is very important
|
||||
# $keys = array("memorySize"=>0,"memoryAvailable"=>0,"memoryAllocated"=>0,"cachedScripts"=>0,"removedScripts"=>0,"cachedKeys"=>0);
|
||||
# if(!function_exists("eaccelerator_info"))
|
||||
# $info = $keys;
|
||||
# else
|
||||
# $info = eaccelerator_info();
|
||||
# foreach($keys as $key => $val) echo strtolower($key).".value ".$info[$key]."\n";
|
||||
# ?>
|
||||
#
|
||||
# - name that file eaccelerator_status.php, will be easier, file should be at least accesible from the address that runs this script (usally localhost)
|
||||
# you can make this file accessible globally, it just displays the memor usage by eaccelerator, thats all.
|
||||
# usually you can put it to the /var/www/ (but it depends on the server configuration etc)
|
||||
# - check if you can see the output of the file, for example if you placed file in the DocumentRoot then it should be available from
|
||||
# http://localhost/eaccelerator_status.php
|
||||
# if you see the plain text with values then its working ok!
|
||||
# if you see the plain text and all values are zero then probalby eaccelerator is not enabled.
|
||||
# - installed wget
|
||||
#
|
||||
#################################################################
|
||||
#
|
||||
# Configuration section
|
||||
#
|
||||
# URL to the script to check eaccelerator status
|
||||
URL="http://localhost/eaccelerator_status.php";
|
||||
#
|
||||
WGET=`which wget`;
|
||||
WGET_FLAGS="-Yoff"; # refer to wget manual, you may set extra parameters like disable proxy
|
||||
#
|
||||
#
|
||||
#################################################################
|
||||
#
|
||||
# Changelog
|
||||
#
|
||||
# Revision 0.1 Tue 03 Feb 2009 02:16:02 PM CET _KaszpiR_
|
||||
# - initial release,
|
||||
#
|
||||
#################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
#################################################################
|
||||
#################################################################
|
||||
# Settigs required for autoconf
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo no
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Eaccelerator usage '
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_category apache'
|
||||
echo 'graph_info This graph shows performance of the eaccelerator module on WWW server.'
|
||||
|
||||
echo 'memorysize.label total'
|
||||
echo 'memorysize.draw AREA'
|
||||
echo 'memorysize.min 0'
|
||||
echo 'memorysize.info Total memory allocated by eaccelerator.'
|
||||
|
||||
echo 'memoryallocated.label allocated'
|
||||
echo 'memoryallocated.draw AREA'
|
||||
echo 'memoryallocated.min 0'
|
||||
# echo "memoryallocated.warning 92"
|
||||
# echo "memoryallocated.critical 98"
|
||||
echo 'memoryallocated.info Memory allocated .'
|
||||
|
||||
echo 'memoryavailable.label available'
|
||||
echo 'memoryavailable.min 0'
|
||||
echo 'memoryavailable.info Memory available .'
|
||||
|
||||
echo 'cachedscripts.label cached scripts'
|
||||
echo 'cachedscripts.min 0'
|
||||
echo 'cachedscripts.info Scripts cached.'
|
||||
|
||||
echo 'removedscripts.label removed scripts'
|
||||
echo 'removedscripts.min 0'
|
||||
echo 'removedscripts.info Scripts removed.'
|
||||
|
||||
echo 'cachedkeys.label cached keys'
|
||||
echo 'cachedkeys.min 0'
|
||||
echo 'cachedkeys.info Scripts removed.'
|
||||
|
||||
|
||||
|
||||
# for key in $KEYS_WARN; do
|
||||
# echo "$key.warning 92"
|
||||
# echo "$key.critical 98"
|
||||
# exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#################################################################
|
||||
# run the sript
|
||||
if [ -x $WGET ]; then
|
||||
# quiet output to stdout
|
||||
wget -q $WGET_FLAGS "$URL" -O -
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# end of file
|
99
plugins/apache/http-response-times
Executable file
99
plugins/apache/http-response-times
Executable file
|
@ -0,0 +1,99 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
|
||||
# HTTP response times for either entire page views
|
||||
# or just the index, depending on configuration.
|
||||
# Full or index resource pulling is determined by the suffix of the
|
||||
# script name. ie. http_response_full or http_response_index
|
||||
#
|
||||
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
#
|
||||
# Configuration variables:
|
||||
#
|
||||
# domain - domain of the server to measure (default takelessons.com)
|
||||
# url[1..n] - url to measure against
|
||||
|
||||
my $domain = $ENV{'domain'} || 'http://takelessons.com';
|
||||
|
||||
# determine the intended "action" of the script
|
||||
# this is determined by the end of the script name
|
||||
# http_response_full or http_response_index
|
||||
my ($action) = ($0 =~ m/http_response_(\S+)$/);
|
||||
$ENV{'action'} = $action;
|
||||
if (! $ENV{'action'} =~ m/(full|index)/) {
|
||||
die "invalid action (determined by script suffix)";
|
||||
}
|
||||
|
||||
my @urls;
|
||||
|
||||
#debug mode
|
||||
#build urls manually
|
||||
if ($ARGV[0] eq "debug") {
|
||||
push(@urls, ( "/",
|
||||
"/san-diego-ca-92106/piano-lessons",
|
||||
"/category/browse",
|
||||
"/cities-music-lessons",
|
||||
"/new-york-music-lessons",
|
||||
"/category/singing-lessons"));
|
||||
}
|
||||
|
||||
#get the urls - build from configuration variables
|
||||
my $i = 1;
|
||||
while (defined ($ENV{"url$i"})) {
|
||||
push(@urls, $ENV{"url$i"});
|
||||
$i++;
|
||||
}
|
||||
if (! @urls) {
|
||||
die "No urls defined\n";
|
||||
}
|
||||
|
||||
#output configuration and exit - required by Munin
|
||||
if (exists $ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title $domain Site Response Times - $ENV{'action'}\n";
|
||||
print "graph_category apache\n";
|
||||
print "graph_vlabel request time (seconds)\n";
|
||||
print "graph_info Response times for public areas of $domain.\n";
|
||||
|
||||
foreach my $url (@urls) {
|
||||
my $label = $url;
|
||||
#fix up our label name to be a valid variable name
|
||||
$label =~ s@[^A-Za-z0-9_]@_@g;
|
||||
print "$label.label $url\n";
|
||||
print "$label.type GAUGE\n";
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#function to make the request and get the response time
|
||||
sub req_time {
|
||||
my $url = shift;
|
||||
my $time;
|
||||
my $outdir = '/tmp/munin/' . int(rand(32000));
|
||||
system("mkdir -p $outdir");
|
||||
if ($ENV{'action'} eq "full") {
|
||||
$time = `/usr/bin/time -f "%e" wget -pq -P $outdir --header "Accept-Encoding: gzip,deflate" "$url" 2>&1`;
|
||||
} elsif ($ENV{'action'} eq "index") {
|
||||
$time = `/usr/bin/time -f "%e" wget -q -P $outdir --header "Accept-Encoding: gzip,deflate" "$url" 2>&1`;
|
||||
}
|
||||
system("rm -rf $outdir");
|
||||
return $time;
|
||||
}
|
||||
|
||||
#loop over every url and output the responses
|
||||
foreach my $url (@urls) {
|
||||
my $label = $url;
|
||||
#fix up our label name to be a valid name
|
||||
$label =~ s@[^A-Za-z0-9_]@_@g;
|
||||
print "$label.value " . req_time($domain.$url);
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
|
36
plugins/apache/php-cgi
Executable file
36
plugins/apache/php-cgi
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
#
|
||||
# Plugin to monitor the number of PHP processes on the machine.
|
||||
#
|
||||
# Copyright Khalid Baheyeldin 2009 http://2bits.com
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# Magick markers (optional - used by munin-config and som installation
|
||||
# scripts):
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Number of php-cgi processes'
|
||||
echo 'graph_args --base 1000 -l 0 '
|
||||
echo 'graph_vlabel number of php-cgi processes'
|
||||
echo 'graph_category apache'
|
||||
echo 'graph_info This graph shows the number of php-cgi processes in the system.'
|
||||
echo 'php_processes.label php-cgi'
|
||||
echo 'php_processes.draw LINE2'
|
||||
echo 'php_processes.info The current number of php-cgi processes.'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "php_processes.value "
|
||||
/bin/ps ax | /usr/bin/grep -i php-cgi | /usr/bin/grep -v grep | /usr/bin/wc -l | /usr/bin/sed 's/\t +//' | /usr/bin/sed 's/ *//'
|
104
plugins/apache/php_eaccelerator
Executable file
104
plugins/apache/php_eaccelerator
Executable file
|
@ -0,0 +1,104 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
# Monitor your EAccelerator usage.
|
||||
# Requires: ruby
|
||||
|
||||
# Mandatory Parameters
|
||||
|
||||
# user / pwd - for basic authentication against control.php
|
||||
# url - fullpath to control.php
|
||||
|
||||
# Author: Dirk Gomez <munin@dirkgomez.de>
|
||||
# Copyright (C) 2007 Dirk Gomez
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require 'open-uri'
|
||||
|
||||
user = ENV['user'] || 'user'
|
||||
pwd = ENV['password'] || 'password'
|
||||
url = ENV['url'] || 'http://127.0.0.1/control.php'
|
||||
|
||||
if ARGV[0]=="config"
|
||||
print "EAccelerator Monitoring\n"
|
||||
print "graph_title PHP Eaccelerator\n"
|
||||
print "graph_category Apache\n"
|
||||
print "Memoryusagepercentage.label Memory Usage %\n"
|
||||
print "Memoryusagepercentage.warning 95\n"
|
||||
print "Memoryusagepercentage.critical 95\n"
|
||||
print "Memoryusage.label Memory Usage MB\n"
|
||||
print "Memorymax.label Cache Size MB\n"
|
||||
print "Freememory.label Free Memory MB\n"
|
||||
print "Cachedscripts.label Cached Scripts\n"
|
||||
print "Removedscripts.label Removed Scripts\n"
|
||||
print "Cachedkeys.label Cached Keys\n"
|
||||
exit
|
||||
end
|
||||
|
||||
one_liners=0
|
||||
three_liners=0
|
||||
key=""
|
||||
|
||||
open(url, :http_basic_authentication=>[user, pwd]) do |f|
|
||||
f.each do |line|
|
||||
if three_liners>0
|
||||
three_liners=three_liners+1
|
||||
|
||||
if three_liners==2
|
||||
print "Memoryusagepercentage.value "
|
||||
end
|
||||
|
||||
if three_liners==3
|
||||
print "Memoryusage.value "
|
||||
end
|
||||
|
||||
if three_liners==4
|
||||
print "Memorymax.value "
|
||||
end
|
||||
|
||||
print line.gsub!(/[^0-9.]/s,"")
|
||||
print "\n"
|
||||
end
|
||||
|
||||
if one_liners>0
|
||||
one_liners=one_liners+1
|
||||
print "#{key}.value "
|
||||
print line.gsub!(/[^0-9.]/s,"")
|
||||
print "\n"
|
||||
end
|
||||
|
||||
if one_liners>1
|
||||
line=""
|
||||
one_liners=0
|
||||
end
|
||||
|
||||
if three_liners>3
|
||||
line=""
|
||||
three_liners=0
|
||||
end
|
||||
|
||||
if line =~ /Memory usage/
|
||||
key=line.gsub!(/(<[^>]*>)|\n|\t| /s,"")
|
||||
three_liners=three_liners+1
|
||||
end
|
||||
|
||||
if line =~ /<td class="e">Free memory/ || line =~ /<td class="e">Cached scripts/ || line =~ /<td class="e">Removed scripts/ || line =~ /<td class="e">Cached keys/
|
||||
key=line.gsub!(/(<[^>]*>)|\n|\t| /s,"")
|
||||
one_liners=one_liners+1
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
72
plugins/apache/php_sessions
Executable file
72
plugins/apache/php_sessions
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006-2008 Benjamin Schweizer. All rights reserved.
|
||||
#
|
||||
#
|
||||
# Abstract
|
||||
# ~~~~~~~~
|
||||
# munin plugin that logs active apache sessions
|
||||
#
|
||||
# Authors
|
||||
# ~~~~~~~
|
||||
# Benjamin Schweizer <code at benjamin-schweizer dot de>
|
||||
# Ronan Guilloux <ronan at coolforest dot net>
|
||||
# Andras Kemeny <subpardaemon at gmail dot com>
|
||||
|
||||
# Copy this to your node's config file (default: plugin-conf.d/munin-node):
|
||||
# [php_sessions]
|
||||
# user root
|
||||
# env.sessiondir /var/lib/php/session
|
||||
#
|
||||
# Modify env.sessiondir to match your system's setting. This should be fine
|
||||
# on most systems.
|
||||
#
|
||||
# Changes
|
||||
# ~~~~~~~
|
||||
# 2011-02-13, subpardaemon: add env.sessiondir, make sure find uses
|
||||
# the given path (it hadn't before)
|
||||
# 2011-01-01, guilloux : find commands & plugin conf improvements
|
||||
# 2008-10-15, schweizer: added active sessions
|
||||
# 2008-10-10, schweizer: forked from munin_squid_efficiency
|
||||
# 2006-10-11, schweizer: initial release.
|
||||
#
|
||||
# Todo
|
||||
# ~~~~
|
||||
# - we'll see
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
SESSDIR=${sessiondir:-"/var/lib/php/session"}
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
test -d "$SESSDIR" > /dev/null 2>&1
|
||||
if [ $? ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (session directory not found)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Apache/PHP Sessions'
|
||||
echo 'graph_info This graph shows active Apache/PHP sessions.'
|
||||
echo 'graph_category apache'
|
||||
echo "graph_args --lower-limit 0"
|
||||
echo 'graph_vlabel n'
|
||||
|
||||
echo 'sessions.label total sessions'
|
||||
echo 'asessions.label active sessions'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ACTIVE_SESSIONS_NUM=`find $SESSDIR/ -type f -iname "sess_*" -amin -5 | wc -l`
|
||||
TOTAL_SESSIONS_NUM=`find $SESSDIR/ -type f -iname "sess_*" | wc -l`
|
||||
|
||||
echo "sessions.value ${TOTAL_SESSIONS_NUM}"
|
||||
echo "asessions.value ${ACTIVE_SESSIONS_NUM}"
|
||||
|
||||
# eof.
|
Loading…
Add table
Add a link
Reference in a new issue