Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/amavis/amavis-debian | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 |
#
|
|
| 2 |
# |
|
| 3 | 3 |
# Plugin to monitor the amavis mail filter for Debian |
| 4 | 4 |
# (based upon a plugin authored by Geoffroy Desvernay) |
| 5 | 5 |
# |
| ... | ... | |
| 32 | 32 |
|
| 33 | 33 |
mktempfile () {
|
| 34 | 34 |
mktemp |
| 35 |
}
|
|
| 35 |
} |
|
| 36 | 36 |
|
| 37 | 37 |
if [ "$1" = "autoconf" ]; then |
| 38 | 38 |
if [ -f "${AMAVIS_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" -a -n "${BC}" -a -x "${BC}" ] ; then
|
| ... | ... | |
| 96 | 96 |
virus=`grep 'INFECTED' ${TEMP_FILE} | wc -l`
|
| 97 | 97 |
spam=`grep 'Blocked SPAM' ${TEMP_FILE} | wc -l`
|
| 98 | 98 |
other=`echo ${total}-${clean}-${virus}-${other}-${spam} | ${BC}`
|
| 99 |
|
|
| 99 |
|
|
| 100 | 100 |
/bin/rm -f $TEMP_FILE |
| 101 | 101 |
fi |
| 102 | 102 |
|
| plugins/amavis/amavis_awk | ||
|---|---|---|
| 2 | 2 |
# |
| 3 | 3 |
# Plugin to monitor Amavis virus and spam statistics. |
| 4 | 4 |
# |
| 5 |
#
|
|
| 5 |
# |
|
| 6 | 6 |
# Based on a routine by William Towle |
| 7 | 7 |
# Uncomment the cdef lines to convert the graph to mails/minute |
| 8 | 8 |
# Comment out the line "total.graph no" to show the total on the graph. This may not be aesthetically pleasing. |
| ... | ... | |
| 38 | 38 |
echo 'graph_args --base 1000 -l 0' |
| 39 | 39 |
|
| 40 | 40 |
echo 'graph_order clean p_spam b_spam virus total' |
| 41 |
|
|
| 41 |
|
|
| 42 | 42 |
echo 'clean.min 0' |
| 43 | 43 |
echo 'clean.type ABSOLUTE' |
| 44 | 44 |
#echo 'clean.cdef clean,60,*' |
| ... | ... | |
| 70 | 70 |
|
| 71 | 71 |
|
| 72 | 72 |
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
|
| 73 |
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; total= 0 }
|
|
| 73 |
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; total= 0 }
|
|
| 74 |
|
|
| 75 |
{
|
|
| 74 | 76 |
|
| 75 |
{
|
|
| 76 |
|
|
| 77 |
if (index($0, "Passed CLEAN")) { na++ ; total++ }
|
|
| 78 |
else if (index($0, "Passed SPAMMY")) { nb++ ; total++ }
|
|
| 77 |
if (index($0, "Passed CLEAN")) { na++ ; total++ }
|
|
| 78 |
else if (index($0, "Passed SPAMMY")) { nb++ ; total++ }
|
|
| 79 | 79 |
else if (index($0, "Blocked SPAMMY")) { nc++ ; total++ }
|
| 80 | 80 |
else if (index($0, "INFECTED")) { nd++ ; total++ }
|
| 81 | 81 |
} |
| plugins/amule/amule_queue | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
# |
| 3 | 3 |
# Plugin to monitor the number of clients in the the aMule queue. |
| 4 |
#
|
|
| 4 |
# |
|
| 5 | 5 |
# In order to use this plugin, you need to enable the "Online Signature" feature |
| 6 | 6 |
# available in aMule's configuration options. You will also need to tell aMule to save |
| 7 | 7 |
# the signature file in '/tmp' . |
| 8 | 8 |
# For detailed instructions with screenshots, see http://linux.andreagozzi.com/content/munin_stuff.php |
| 9 | 9 |
# |
| 10 |
#
|
|
| 10 |
# |
|
| 11 | 11 |
# Parameters understood: |
| 12 | 12 |
# |
| 13 | 13 |
# config (required) |
| plugins/amule/amule_shares | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
# |
| 3 | 3 |
# Plugin to monitor the number of shared files with the aMule ed2k/KAD client. |
| 4 |
#
|
|
| 4 |
# |
|
| 5 | 5 |
# In order to use this plugin, you need to enable the "Online Signature" feature |
| 6 | 6 |
# available in aMule's configuration options. You will also need to tell aMule to save |
| 7 | 7 |
# the signature file in '/tmp' . |
| 8 | 8 |
# For detailed instructions with screenshots, see http://linux.andreagozzi.com/content/munin_stuff.php |
| 9 | 9 |
# |
| 10 |
#
|
|
| 10 |
# |
|
| 11 | 11 |
# Parameters understood: |
| 12 | 12 |
# |
| 13 | 13 |
# config (required) |
| plugins/amule/amule_transfers | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
# |
| 3 | 3 |
# Plugin to monitor the UL/DL speed of the aMule ed2k/KAD client. |
| 4 |
#
|
|
| 4 |
# |
|
| 5 | 5 |
# In order to use this plugin, you need to enable the "Online Signature" feature |
| 6 | 6 |
# available in aMule's configuration options. You will also need to tell aMule to save |
| 7 | 7 |
# the signature file in '/tmp' . |
| 8 | 8 |
# For detailed instructions with screenshots, see http://linux.andreagozzi.com/content/munin_stuff.php |
| 9 | 9 |
# |
| 10 |
#
|
|
| 10 |
# |
|
| 11 | 11 |
# Parameters understood: |
| 12 | 12 |
# |
| 13 | 13 |
# config (required) |
| plugins/amule/amule_uptime | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
# |
| 3 | 3 |
# Plugin to monitor the current aMule ed2k/KAD client uptime. |
| 4 |
#
|
|
| 4 |
# |
|
| 5 | 5 |
# In order to use this plugin, you need to enable the "Online Signature" feature |
| 6 | 6 |
# available in aMule's configuration options. You will also need to tell aMule to save |
| 7 | 7 |
# the signature file in '/tmp' . |
| 8 | 8 |
# For detailed instructions with screenshots, see http://linux.andreagozzi.com/content/munin_stuff.php |
| 9 | 9 |
# |
| 10 |
#
|
|
| 10 |
# |
|
| 11 | 11 |
# Parameters understood: |
| 12 | 12 |
# |
| 13 | 13 |
# config (required) |
| plugins/apache/apache_activity | ||
|---|---|---|
| 46 | 46 |
} |
| 47 | 47 |
my $ua = LWP::UserAgent->new(timeout => 30); |
| 48 | 48 |
my @badports; |
| 49 |
|
|
| 49 |
|
|
| 50 | 50 |
foreach my $port (@PORTS) {
|
| 51 | 51 |
my $url = sprintf $URL, $port; |
| 52 | 52 |
my $response = $ua->request(HTTP::Request->new('GET',$url));
|
| 53 | 53 |
push @badports, $port unless $response->is_success and $response->content =~ /Scoreboard/im; |
| 54 | 54 |
} |
| 55 |
|
|
| 55 |
|
|
| 56 | 56 |
if (@badports) {
|
| 57 | 57 |
print "no (no apache server-status on ports @badports)\n"; |
| 58 | 58 |
exit 1; |
| ... | ... | |
| 75 | 75 |
print $val, "\n"; |
| 76 | 76 |
print "activity_${port}_${char}.type GAUGE\n";
|
| 77 | 77 |
} |
| 78 |
}
|
|
| 78 |
} |
|
| 79 | 79 |
exit 0; |
| 80 | 80 |
} |
| 81 | 81 |
|
| plugins/apache/apache_average_time_last_n_requests | ||
|---|---|---|
| 3 | 3 |
# Raphaël Droz <raphael.droz@gmail.com> - 2016-01-08 |
| 4 | 4 |
# |
| 5 | 5 |
# Monitors the average time requests matching a custom regexp takes |
| 6 |
# For instance monitor time execution of files in http://example.com/foo/bar,
|
|
| 6 |
# For instance monitor time execution of files in http://example.com/foo/bar, |
|
| 7 | 7 |
# requests from google, images etc. |
| 8 | 8 |
# |
| 9 | 9 |
# Simply add an entry in the 'type' hashref and modify the description fields |
| ... | ... | |
| 13 | 13 |
# |
| 14 | 14 |
# NOTE: You need to add a field in your Apache logs showing time executed. |
| 15 | 15 |
# This is normally done using the %T (seconds) or %D (microseconds) |
| 16 |
# For instance:
|
|
| 16 |
# For instance: |
|
| 17 | 17 |
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %T %v"
|
| 18 | 18 |
# Check http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats for more info |
| 19 | 19 |
# |
| ... | ... | |
| 62 | 62 |
# any kind of request |
| 63 | 63 |
total => {
|
| 64 | 64 |
munin_fields => {
|
| 65 |
label => 'All requests',
|
|
| 65 |
label => 'All requests', |
|
| 66 | 66 |
draw => 'LINE2', |
| 67 | 67 |
info => 'Average seconds per any request', |
| 68 | 68 |
}, |
| 69 | 69 |
sum => 0, |
| 70 | 70 |
lines => 0, |
| 71 |
matches => sub {
|
|
| 72 |
return 1;
|
|
| 71 |
matches => sub {
|
|
| 72 |
return 1; |
|
| 73 | 73 |
}, |
| 74 | 74 |
}, |
| 75 | 75 |
|
| ... | ... | |
| 82 | 82 |
}, |
| 83 | 83 |
sum => 0, |
| 84 | 84 |
lines => 0, |
| 85 |
matches => sub {
|
|
| 86 |
my ($fields) = @_;
|
|
| 87 |
my $script;
|
|
| 88 |
($script = $fields->[6]) =~ s/\?.*\z //mx;
|
|
| 89 |
return $script =~ m{ \.(png|jpe?g|gif|tiff|ilbm|tga) \z }mx;
|
|
| 85 |
matches => sub {
|
|
| 86 |
my ($fields) = @_; |
|
| 87 |
my $script; |
|
| 88 |
($script = $fields->[6]) =~ s/\?.*\z //mx; |
|
| 89 |
return $script =~ m{ \.(png|jpe?g|gif|tiff|ilbm|tga) \z }mx;
|
|
| 90 | 90 |
}, |
| 91 | 91 |
}, |
| 92 | 92 |
}; |
| ... | ... | |
| 101 | 101 |
} |
| 102 | 102 |
} |
| 103 | 103 |
exit(0); |
| 104 |
}
|
|
| 104 |
} |
|
| 105 | 105 |
|
| 106 | 106 |
my $config_file = `ls -1 $ACCESS_LOG_PATTERN | tail -n 1`; |
| 107 | 107 |
|
| ... | ... | |
| 121 | 121 |
$types->{$type}->{'lines'}++;
|
| 122 | 122 |
} |
| 123 | 123 |
} |
| 124 |
}
|
|
| 124 |
} |
|
| 125 | 125 |
|
| 126 | 126 |
} |
| 127 | 127 |
foreach my $type (keys %{$types}) {
|
| 128 | 128 |
my $value = $types->{$type}->{'lines'} ? $types->{$type}->{'sum'} / $types->{$type}->{'lines'} : 'U';
|
| 129 | 129 |
printf "%s.value %s\n", ($type, $value); |
| 130 |
}
|
|
| 130 |
} |
|
| 131 | 131 |
|
| 132 | 132 |
|
| 133 | 133 |
|
| plugins/apache/apache_blackbox | ||
|---|---|---|
| 5 | 5 |
# luis peralta - luis@11870.com |
| 6 | 6 |
# http://www.ziritione.org |
| 7 | 7 |
# |
| 8 |
# Installing: configure apache blackbox and set the logfile to /var/log/blackbox.log
|
|
| 8 |
# Installing: configure apache blackbox and set the logfile to /var/log/blackbox.log |
|
| 9 | 9 |
# or change the BLACKBOXLOG setting below. |
| 10 | 10 |
# |
| 11 |
# Dependencies: apache mod_logio, apache blackbox
|
|
| 11 |
# Dependencies: apache mod_logio, apache blackbox |
|
| 12 | 12 |
# http://www.devco.net/archives/2008/03/05/detailed_apache_stats.php |
| 13 | 13 |
# |
| 14 | 14 |
# Last version available at: http://www.ziritione.org/http_status |
| ... | ... | |
| 23 | 23 |
|
| 24 | 24 |
use strict; |
| 25 | 25 |
|
| 26 |
my $BLACKBOXLOG = "/var/log/blackbox.log";
|
|
| 26 |
my $BLACKBOXLOG = "/var/log/blackbox.log"; |
|
| 27 | 27 |
|
| 28 |
my %WANTED = ( "apache.status.200" => "_200",
|
|
| 29 |
"apache.status.301" => "_301",
|
|
| 30 |
"apache.status.302" => "_302",
|
|
| 31 |
"apache.status.404" => "_404",
|
|
| 32 |
"apache.status.5xx" => "_5xx",
|
|
| 28 |
my %WANTED = ( "apache.status.200" => "_200", |
|
| 29 |
"apache.status.301" => "_301", |
|
| 30 |
"apache.status.302" => "_302", |
|
| 31 |
"apache.status.404" => "_404", |
|
| 32 |
"apache.status.5xx" => "_5xx", |
|
| 33 | 33 |
); |
| 34 | 34 |
|
| 35 | 35 |
my $arg = shift(); |
| ... | ... | |
| 78 | 78 |
); |
| 79 | 79 |
$num++; |
| 80 | 80 |
} |
| 81 |
|
|
| 81 |
|
|
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 | 84 |
|
| plugins/apache/apache_byprojects/README.md | ||
|---|---|---|
| 2 | 2 |
Those plugins are used to monitor different projects or vhost (i.e. either different log files or using regular expression as filters) on the same web server. |
| 3 | 3 |
|
| 4 | 4 |
## munin_byprojects_access |
| 5 |
Count the number of hits per projects/vhost.
|
|
| 5 |
Count the number of hits per projects/vhost. |
|
| 6 | 6 |
 |
| 7 | 7 |
|
| 8 | 8 |
## munin_byprojects_bandwidth |
| 9 |
Count the total bandwidth used by each projects/vhost. [Logtail] (https://www.fourmilab.ch/webtools/logtail/) is required.
|
|
| 9 |
Count the total bandwidth used by each projects/vhost. [Logtail] (https://www.fourmilab.ch/webtools/logtail/) is required. |
|
| 10 | 10 |
 |
| 11 | 11 |
|
| 12 | 12 |
## munin_byprojects_inout_bandwidth |
| 13 |
Counts the in/out bandwidth used by each projects/vhost. [Logtail] (https://www.fourmilab.ch/webtools/logtail/) is required.
|
|
| 13 |
Counts the in/out bandwidth used by each projects/vhost. [Logtail] (https://www.fourmilab.ch/webtools/logtail/) is required. |
|
| 14 | 14 |
 |
| 15 | 15 |
|
| 16 | 16 |
## Installation |
| plugins/apache/apache_byprojects/byprojects_access | ||
|---|---|---|
| 3 | 3 |
# |
| 4 | 4 |
# byprojects_access |
| 5 | 5 |
# |
| 6 |
# Perl script to monitor access *byprojects* (e.g. vhost) from multiple files
|
|
| 6 |
# Perl script to monitor access *byprojects* (e.g. vhost) from multiple files |
|
| 7 | 7 |
# and/or regex. |
| 8 | 8 |
# |
| 9 |
# Danny Fullerton <northox@mantor.org>
|
|
| 9 |
# Danny Fullerton <northox@mantor.org> |
|
| 10 | 10 |
# Mantor Organization <www.mantor.org> |
| 11 | 11 |
# This work is licensed under a MIT license. |
| 12 | 12 |
# |
| 13 | 13 |
# You need logtail (https://www.fourmilab.ch/webtools/logtail/) |
| 14 | 14 |
# |
| 15 |
# Log can be gathered from multiple sources by simply specifying multiple log
|
|
| 15 |
# Log can be gathered from multiple sources by simply specifying multiple log |
|
| 16 | 16 |
# filename or using wildcards (glob). File content can be selected using regex. |
| 17 | 17 |
# |
| 18 | 18 |
# - 'prod' => [ {'path' => '/home/prod/log/access.log'} ],
|
| ... | ... | |
| 74 | 74 |
my @paths = glob $log->{'path'};
|
| 75 | 75 |
foreach my $path (@paths) {
|
| 76 | 76 |
my $state = $statepath.'/'.$project.$x.'_access.state'; |
| 77 |
open(LT, "$logtail -f ".$log->{'path'}." -o $state |") or
|
|
| 77 |
open(LT, "$logtail -f ".$log->{'path'}." -o $state |") or
|
|
| 78 | 78 |
die "Can't open $logtail : $!"; |
| 79 | 79 |
while (<LT>) {
|
| 80 | 80 |
my $buf = $_; |
| plugins/apache/apache_byprojects/byprojects_bandwidth | ||
|---|---|---|
| 3 | 3 |
# |
| 4 | 4 |
# byprojects_bandwidth |
| 5 | 5 |
# |
| 6 |
# Perl script to monitor total bandwidth *byprojects* (e.g. vhost) from multiple
|
|
| 6 |
# Perl script to monitor total bandwidth *byprojects* (e.g. vhost) from multiple |
|
| 7 | 7 |
# files and/or regex. |
| 8 | 8 |
# |
| 9 |
# Danny Fullerton <northox@mantor.org>
|
|
| 9 |
# Danny Fullerton <northox@mantor.org> |
|
| 10 | 10 |
# Mantor Organization <www.mantor.org> |
| 11 | 11 |
# This work is licensed under a MIT license. |
| 12 | 12 |
# |
| ... | ... | |
| 17 | 17 |
# "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"
|
| 18 | 18 |
# where %I is input and %O is output. |
| 19 | 19 |
# |
| 20 |
# Log can be gathered from multiple sources by simply specifying multiple log
|
|
| 20 |
# Log can be gathered from multiple sources by simply specifying multiple log |
|
| 21 | 21 |
# filename or using wildcards (glob). File content can be selected using regex. |
| 22 | 22 |
# |
| 23 | 23 |
# - 'prod' => [ {'path' => '/home/prod/log/access.log'} ],
|
| ... | ... | |
| 81 | 81 |
my @paths = glob $log->{'path'};
|
| 82 | 82 |
foreach my $path (@paths) {
|
| 83 | 83 |
my $state = $statepath.'/'.$project.$x.'_totalbandwidth.state'; |
| 84 |
open(LT, "$logtail -f ".$log->{'path'}." -o $state |") or
|
|
| 84 |
open(LT, "$logtail -f ".$log->{'path'}." -o $state |") or
|
|
| 85 | 85 |
die "Can't open $logtail : $!"; |
| 86 | 86 |
while (<LT>) {
|
| 87 | 87 |
my $buf = $_; |
| plugins/apache/apache_byprojects/byprojects_inout_bandwidth | ||
|---|---|---|
| 3 | 3 |
# |
| 4 | 4 |
# byprojects_inout_bandwidth |
| 5 | 5 |
# |
| 6 |
# Perl script to monitor in/out bandwidth *byprojects* (e.g. vhost) from
|
|
| 6 |
# Perl script to monitor in/out bandwidth *byprojects* (e.g. vhost) from |
|
| 7 | 7 |
# multiple files and/or regex. |
| 8 | 8 |
# |
| 9 |
# Danny Fullerton <northox@mantor.org>
|
|
| 9 |
# Danny Fullerton <northox@mantor.org> |
|
| 10 | 10 |
# Mantor Organization <www.mantor.org> |
| 11 | 11 |
# This work is licensed under a MIT license. |
| 12 | 12 |
# |
| ... | ... | |
| 17 | 17 |
# "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"
|
| 18 | 18 |
# where %I is input and %O is output. |
| 19 | 19 |
# |
| 20 |
# Log can be gathered from multiple sources by simply specifying multiple log
|
|
| 20 |
# Log can be gathered from multiple sources by simply specifying multiple log |
|
| 21 | 21 |
# filename or using wildcards (glob). File content can be selected using regex. |
| 22 | 22 |
# |
| 23 | 23 |
# - 'prod' => [ {'path' => '/home/prod/log/access.log'} ],
|
| ... | ... | |
| 84 | 84 |
my @paths = glob $log->{'path'};
|
| 85 | 85 |
foreach my $path (@paths) {
|
| 86 | 86 |
my $state = $statepath.'/'.$project.$x.'_inoutbandwidth.state'; |
| 87 |
open(LT, "$logtail -f ".$log->{'path'}." -o $state |") or
|
|
| 87 |
open(LT, "$logtail -f ".$log->{'path'}." -o $state |") or
|
|
| 88 | 88 |
die "Can't open $logtail : $!"; |
| 89 | 89 |
while (<LT>) {
|
| 90 | 90 |
my $buf = $_; |
| plugins/apache/apache_memmory | ||
|---|---|---|
| 36 | 36 |
|
| 37 | 37 |
|
| 38 | 38 |
if [ "$1" = "autoconf" ]; then |
| 39 |
echo yes
|
|
| 39 |
echo yes |
|
| 40 | 40 |
exit 0 |
| 41 | 41 |
fi |
| 42 | 42 |
|
| ... | ... | |
| 65 | 65 |
VAL3=`expr $VAL2 / $VAL1` |
| 66 | 66 |
|
| 67 | 67 |
echo "servers.value $VAL3" |
| 68 |
|
|
| 68 |
|
|
| 69 | 69 |
|
| plugins/apache/apache_servers | ||
|---|---|---|
| 34 | 34 |
PROCS=$binname |
| 35 | 35 |
|
| 36 | 36 |
if [ "$1" = "autoconf" ]; then |
| 37 |
echo yes
|
|
| 37 |
echo yes |
|
| 38 | 38 |
exit 0 |
| 39 | 39 |
fi |
| 40 | 40 |
|
| plugins/apache/apache_smaps | ||
|---|---|---|
| 8 | 8 |
# to Apache2::SizeLimit. |
| 9 | 9 |
|
| 10 | 10 |
# Author: Kjetil Kjernsmo <kjetilk@opera.com>, based on work by William Viker |
| 11 |
# Copyright (C) 2007 Opera Software ASA
|
|
| 11 |
# Copyright (C) 2007 Opera Software ASA |
|
| 12 | 12 |
# |
| 13 | 13 |
# Contibutors: Earle Nietzel <earle.nietzel@gmail.com> |
| 14 | 14 |
# |
| plugins/apache/apache_status | ||
|---|---|---|
| 144 | 144 |
if ($response->content =~ /^Total Accesses:/im ) {
|
| 145 | 145 |
next; |
| 146 | 146 |
} else {
|
| 147 |
print "no (ExtendedStatus option for apache"
|
|
| 147 |
print "no (ExtendedStatus option for apache" |
|
| 148 | 148 |
. " mod_status is missing on port $port)\n"; |
| 149 | 149 |
exit 0; |
| 150 | 150 |
} |
| plugins/apache/apache_threads | ||
|---|---|---|
| 32 | 32 |
|
| 33 | 33 |
|
| 34 | 34 |
if [ "$1" = "autoconf" ]; then |
| 35 |
echo yes
|
|
| 35 |
echo yes |
|
| 36 | 36 |
exit 0 |
| 37 | 37 |
fi |
| 38 | 38 |
|
| ... | ... | |
| 81 | 81 |
|
| 82 | 82 |
|
| 83 | 83 |
echo "threads.value `echo $((SUM / $COUNT))`" |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| plugins/apache/apache_tmemmory | ||
|---|---|---|
| 35 | 35 |
|
| 36 | 36 |
|
| 37 | 37 |
if [ "$1" = "autoconf" ]; then |
| 38 |
echo yes
|
|
| 38 |
echo yes |
|
| 39 | 39 |
exit 0 |
| 40 | 40 |
fi |
| 41 | 41 |
|
| ... | ... | |
| 60 | 60 |
VAL2=`expr $VAL1 / 1024` |
| 61 | 61 |
|
| 62 | 62 |
echo "servers.value $VAL2" |
| 63 |
|
|
| 63 |
|
|
| 64 | 64 |
|
| plugins/apache/apache_users | ||
|---|---|---|
| 100 | 100 |
else |
| 101 | 101 |
USERNAME[$I]="anonymous" |
| 102 | 102 |
fi |
| 103 |
NAME[$I]="_${USERNAME[I]}" # Output sort order
|
|
| 103 |
NAME[$I]="_${USERNAME[I]}" # Output sort order
|
|
| 104 | 104 |
else |
| 105 | 105 |
NAME[$I]="${USERNAME[I]}"
|
| 106 | 106 |
fi |
| ... | ... | |
| 140 | 140 |
FILENAMES=$( find $DIRECTORY -type f -not -wholename $TIMESTAMP | sort) |
| 141 | 141 |
|
| 142 | 142 |
awk '{ printf "%s.label %s\n%s.draw AREA\n", $1, $3, $1 }' $( echo "$FILENAMES" | head -n1 )
|
| 143 |
|
|
| 143 |
|
|
| 144 | 144 |
for FILENAME in $( echo "$FILENAMES" | tail -n+2) |
| 145 | 145 |
do |
| 146 | 146 |
awk '{ printf "%s.label %s\n%s.draw STACK\n", $1, $3, $1 }' $FILENAME
|
| plugins/apache/apache_vhosts/apache_logparser | ||
|---|---|---|
| 95 | 95 |
#find sitename |
| 96 | 96 |
$file=~s/$site/$1/; |
| 97 | 97 |
$file=$vhost if $vhost; |
| 98 |
|
|
| 98 |
|
|
| 99 | 99 |
# skip broken lines |
| 100 | 100 |
next unless $file; |
| 101 | 101 |
|
| ... | ... | |
| 103 | 103 |
my $vpm=clean_fieldname("$file");
|
| 104 | 104 |
$temp{$vpm}{'label'}="$file";
|
| 105 | 105 |
$temp{$vpm}{'label'}=~s/www\.//;
|
| 106 |
|
|
| 106 |
|
|
| 107 | 107 |
# count all requests |
| 108 | 108 |
$temp{$vpm}{'requests'}++;
|
| 109 | 109 |
|
| ... | ... | |
| 118 | 118 |
# average bytes |
| 119 | 119 |
$temp{$vpm}{'avg_bytes'}=$temp{$vpm}{'bytes'}/$temp{$vpm}{'requests'} || 0;
|
| 120 | 120 |
} |
| 121 |
|
|
| 121 |
|
|
| 122 | 122 |
# count by status / error code |
| 123 | 123 |
$temp{$vpm}{"status"}{$status}++ if $status;
|
| 124 | 124 |
|
| 125 | 125 |
if ($time) {
|
| 126 | 126 |
# microsec to millisec |
| 127 |
$time=sprintf("%d",$time/1000);
|
|
| 127 |
$time=sprintf("%d",$time/1000);
|
|
| 128 | 128 |
|
| 129 | 129 |
# min/max execution time |
| 130 | 130 |
$temp{$vpm}{'max_time'}=max($temp{$vpm}{'max_time'},$time) || 0;
|
| ... | ... | |
| 144 | 144 |
# tail files, calls &count with linearray |
| 145 | 145 |
$tail->read; |
| 146 | 146 |
|
| 147 |
# begin transaction
|
|
| 147 |
# begin transaction |
|
| 148 | 148 |
$share->lock(LOCK_EX); |
| 149 |
|
|
| 149 |
|
|
| 150 | 150 |
# get data (may be updated by other loggers too) |
| 151 | 151 |
my %old=eval{%{thaw($share->fetch)}}; # using eval to suppress thaw error on empty string at the first run
|
| 152 | 152 |
|
| ... | ... | |
| 182 | 182 |
$share->store( freeze \%old ); |
| 183 | 183 |
# end transaction |
| 184 | 184 |
$share->unlock; |
| 185 |
|
|
| 185 |
|
|
| 186 | 186 |
# parse/write every n seconds (plus processing time) |
| 187 | 187 |
sleep $nsec; |
| 188 | 188 |
} |
| plugins/apache/apache_vhosts/apache_pipelogger | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
# sanity check |
| 42 | 42 |
next unless m/^([\d\w\.\-_]+\s){5}([\d\w\.\-_]+$)/; # escaped "." and "-"
|
| 43 |
|
|
| 43 |
|
|
| 44 | 44 |
# sitename to munin fieldname |
| 45 | 45 |
my $vpm=clean_fieldname($vhost); |
| 46 | 46 |
$temp{$vpm}{'label'}=$vhost;
|
| 47 | 47 |
$temp{$vpm}{'label'}=~s/www\.//;
|
| 48 |
|
|
| 48 |
|
|
| 49 | 49 |
# count all requests |
| 50 | 50 |
$temp{$vpm}{'requests'}++;
|
| 51 | 51 |
|
| ... | ... | |
| 60 | 60 |
# average bytes |
| 61 | 61 |
$temp{$vpm}{'avg_bytes'}=$temp{$vpm}{'bytes'}/$temp{$vpm}{'requests'} || 0 if ($bytes);
|
| 62 | 62 |
} |
| 63 |
|
|
| 63 |
|
|
| 64 | 64 |
# count by status / error code |
| 65 | 65 |
$temp{$vpm}{"status"}{$status}++ if $status;
|
| 66 | 66 |
|
| ... | ... | |
| 77 | 77 |
}; |
| 78 | 78 |
|
| 79 | 79 |
sub periodic_write {
|
| 80 |
# begin transaction
|
|
| 80 |
# begin transaction |
|
| 81 | 81 |
$share->lock(LOCK_EX); |
| 82 |
|
|
| 82 |
|
|
| 83 | 83 |
# get data (may be updated by other loggers too) |
| 84 | 84 |
my %old=eval{%{thaw($share->fetch)}}; # using eval to suppress thaw error on empty string at the first run
|
| 85 | 85 |
|
| plugins/apache/apache_vhosts/apache_vhosts | ||
|---|---|---|
| 18 | 18 |
- slightly less performant, but easier to apply to existing installations |
| 19 | 19 |
- If you want response time stats, you have to log them in apache: |
| 20 | 20 |
<IfModule mod_log_config.c> |
| 21 |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined-time
|
|
| 21 |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined-time
|
|
| 22 | 22 |
</IfModule> |
| 23 | 23 |
- Configure the log parser to match your installation regarding naming and log folders |
| 24 |
|
|
| 25 |
You can use both solutions simultaneously, the data will be merged.
|
|
| 24 |
|
|
| 25 |
You can use both solutions simultaneously, the data will be merged. |
|
| 26 | 26 |
Be aware that a apache log CustomLog directive in the master config will only log those vhosts that have no directive of their own. |
| 27 |
|
|
| 27 |
|
|
| 28 | 28 |
Install plugin conf (after [apache_*]) |
| 29 | 29 |
|
| 30 | 30 |
[apache_vhosts] |
| ... | ... | |
| 36 | 36 |
# subgraphs - create multigraph subgraphs (watch your graphing performance...), default 0 |
| 37 | 37 |
# checks - enable stats on bytes and response times per request, you have to log these in apache |
| 38 | 38 |
|
| 39 |
A word on performance:
|
|
| 39 |
A word on performance: |
|
| 40 | 40 |
Requests/sec should not be much of a problem. Pipelogger and Logparser should not have man performance problems, as the apply one regex per line and add some stats. |
| 41 |
Stats are saved every n seconds (default: 7) to shared mem in serialized format. That should be ok on the most loaded servers (unless you watch cache logs).
|
|
| 42 |
I would estimate that > 10k log lines/sec could start becoming a problem, you might have to start tuning there or use a dedicated system.
|
|
| 41 |
Stats are saved every n seconds (default: 7) to shared mem in serialized format. That should be ok on the most loaded servers (unless you watch cache logs). |
|
| 42 |
I would estimate that > 10k log lines/sec could start becoming a problem, you might have to start tuning there or use a dedicated system. |
|
| 43 | 43 |
You might think about splitting the logs over multiple Logparser scripts to parallelize and merge in larger intervals. |
| 44 | 44 |
|
| 45 |
Graphing is another matter, the more vhosts you have.
|
|
| 46 |
With subgraphs off, you do 3 main graphs * 4 timescales (day, week, month, year).
|
|
| 45 |
Graphing is another matter, the more vhosts you have. |
|
| 46 |
With subgraphs off, you do 3 main graphs * 4 timescales (day, week, month, year). |
|
| 47 | 47 |
With subgraphs on, you get 2 checks * (1 + 6 * #vhosts) + 1 check * (1 + #vhosts * #statuscodes * 4) |
| 48 | 48 |
With hundreds of vhosts that becomes a problem, as munin-update and munin-html do not scale well. |
| 49 | 49 |
|
| ... | ... | |
| 152 | 152 |
END |
| 153 | 153 |
} # end graph |
| 154 | 154 |
} # end sites |
| 155 |
} # end subgraph
|
|
| 155 |
} # end subgraph |
|
| 156 | 156 |
} # end checks |
| 157 | 157 |
|
| 158 | 158 |
|
| ... | ... | |
| 173 | 173 |
graph_order $order |
| 174 | 174 |
END |
| 175 | 175 |
foreach my $site (keys %data) {
|
| 176 |
|
|
| 176 |
|
|
| 177 | 177 |
print <<END; |
| 178 | 178 |
${site}_requests.label $data{$site}{'label'}
|
| 179 | 179 |
${site}_requests.info $site
|
| ... | ... | |
| 230 | 230 |
} # end sites |
| 231 | 231 |
|
| 232 | 232 |
if ($subgraphs{$check}) {
|
| 233 |
# subgraph values
|
|
| 233 |
# subgraph values |
|
| 234 | 234 |
foreach my $site (keys %data) {
|
| 235 | 235 |
print "\nmultigraph apache_vhosts_$check.$site\n"; |
| 236 | 236 |
foreach my $graph ("avg","max") {
|
| plugins/apache/apache_watch_ | ||
|---|---|---|
| 43 | 43 |
} |
| 44 | 44 |
my $ua = LWP::UserAgent->new (timeout => 30); |
| 45 | 45 |
my @badports; |
| 46 |
|
|
| 46 |
|
|
| 47 | 47 |
foreach my $port (@PORTS) {
|
| 48 | 48 |
my $url = sprintf $URL, $port; |
| 49 | 49 |
my $response = $ua->request (HTTP::Request->new('GET', $url));
|
| 50 | 50 |
push @badports, $port unless $response->is_success; |
| 51 | 51 |
} |
| 52 |
|
|
| 52 |
|
|
| 53 | 53 |
if (@badports) {
|
| 54 | 54 |
print "no (no mod_watch exists on ports @badports)\n"; |
| 55 | 55 |
exit 1; |
| ... | ... | |
| 76 | 76 |
my ($server, undef, $ifInOctets, $ifOutOctets, $ifRequests, |
| 77 | 77 |
$ifDocuments) = split (/\s/, $string, 6); |
| 78 | 78 |
push @servers, $server unless $server eq "SERVER"; |
| 79 |
push @data, "$server $ifInOctets $ifOutOctets $ifRequests $ifDocuments"
|
|
| 79 |
push @data, "$server $ifInOctets $ifOutOctets $ifRequests $ifDocuments" |
|
| 80 | 80 |
unless $server eq "SERVER"; |
| 81 | 81 |
} |
| 82 | 82 |
} |
| plugins/apache/page_load | ||
|---|---|---|
| 22 | 22 |
# |
| 23 | 23 |
# apache2.conf |
| 24 | 24 |
# LogFormat "%h %l %u %t \"%r\" %>s %O %b %D \"%{Referer}i\" \"%{User-Agent}i\"" custom
|
| 25 |
#
|
|
| 25 |
# |
|
| 26 | 26 |
# According to : http://httpd.apache.org/docs/2.2/mod/mod_log_config.html |
| 27 | 27 |
# %D The time taken to serve the request, in microseconds. |
| 28 | 28 |
# In our case %D -> 9 |
| 29 |
######################################################################################################
|
|
| 29 |
###################################################################################################### |
|
| 30 | 30 |
# GLOBALS |
| 31 | 31 |
LOGFILE="/var/log/apache2/access.log" |
| 32 | 32 |
BUFFER_SIZE=500 |
| 33 | 33 |
|
| 34 | 34 |
###################################################################################################### |
| 35 | 35 |
|
| 36 |
|
|
| 36 |
|
|
| 37 | 37 |
do_ () {
|
| 38 | 38 |
command="tail -n $BUFFER_SIZE $LOGFILE | awk '{sum=sum+\$9} END {print \"exec_time.value \"(sum/$BUFFER_SIZE)/1000000}'"
|
| 39 | 39 |
eval $command |
| 40 | 40 |
exit 0 |
| 41 | 41 |
} |
| 42 |
|
|
| 42 |
|
|
| 43 | 43 |
do_config () {
|
| 44 | 44 |
echo "graph_title Average page execution time" |
| 45 | 45 |
echo "graph_vlabel Seconds" |
| 46 | 46 |
echo "graph_category webserver" |
| 47 | 47 |
echo "graph_args --base 1000 -l 0" |
| 48 | 48 |
echo "graph_info Average page execution time" |
| 49 |
|
|
| 49 |
|
|
| 50 | 50 |
echo "exec_time.label Execution time" |
| 51 | 51 |
echo "exec_time.type GAUGE" |
| 52 | 52 |
} |
| 53 |
|
|
| 53 |
|
|
| 54 | 54 |
case $1 in |
| 55 | 55 |
config|'') |
| 56 | 56 |
eval do_$1 |
| 57 | 57 |
esac |
| 58 |
|
|
| 58 |
|
|
| 59 | 59 |
exit $? |
| plugins/apt/deb_packages/README.md | ||
|---|---|---|
| 24 | 24 |
on older installations, tell me whether it works or which errors you had. It |
| 25 | 25 |
should run past python-apt 0.7 and python 2.5. |
| 26 | 26 |
|
| 27 |
check out this git repository from
|
|
| 28 |
|
|
| 27 |
check out this git repository from |
|
| 28 |
|
|
| 29 | 29 |
aptitude install python-apt |
| 30 | 30 |
git clone git://github.com/munin-monitoring/contrib.git |
| 31 | 31 |
cd contrib/plugins/apt/deb_packages |
| ... | ... | |
| 51 | 51 |
# Age in seconds an $CACHE_FILE can be. If it is older, the script updates |
| 52 | 52 |
# default if not set is 3540 (one hour) |
| 53 | 53 |
# at the moment this is not used, the plugin always runs (if munin calls it) |
| 54 |
#
|
|
| 54 |
# |
|
| 55 | 55 |
env.CACHE_FILE_MAX_AGE 3540 |
| 56 | 56 |
|
| 57 | 57 |
# All these numbers are only for sorting, so you can use env.graph01_sort_by_0 |
| plugins/apt/deb_packages/deb_packages.py | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/python |
| 2 | 2 |
# -*- coding: utf-8 -*- |
| 3 | 3 |
|
| 4 |
"""
|
|
| 4 |
""" |
|
| 5 | 5 |
A munin plugin that prints archive and their upgradable packets |
| 6 | 6 |
|
| 7 | 7 |
TODO: make it usable and readable as commandline tool |
| ... | ... | |
| 13 | 13 |
sorting a packet to the newest archive |
| 14 | 14 |
(WONTFIX unless someone asks for) |
| 15 | 15 |
|
| 16 |
TODO:
|
|
| 16 |
TODO: |
|
| 17 | 17 |
• addinge alternative names for archives "stable -> squeeze" |
| 18 |
TODO: add gray as
|
|
| 18 |
TODO: add gray as |
|
| 19 | 19 |
foo.colour 000000 |
| 20 | 20 |
to 'now', '', '', '', '', 'Debian dpkg status file' |
| 21 | 21 |
TODO: update only if system was updated (aptitutde update has been run) |
| 22 | 22 |
• check modification date of /var/cache/apt/pkgcache.bin |
| 23 | 23 |
• cache file must not be older than mod_date of pkgcache.bin + X |
| 24 |
TODO: shorten ext_info with getShortestConfigOfOptions
|
|
| 25 |
TODO: check whether cachefile matches the config
|
|
| 24 |
TODO: shorten ext_info with getShortestConfigOfOptions |
|
| 25 |
TODO: check whether cachefile matches the config |
|
| 26 | 26 |
• i have no clever idea to do this without 100 lines of code |
| 27 |
BUG: If a package will be upgraded, and brings in new dependencies,
|
|
| 27 |
BUG: If a package will be upgraded, and brings in new dependencies, |
|
| 28 | 28 |
these new deps will not be counted. WONTFIX |
| 29 | 29 |
""" |
| 30 | 30 |
import sys |
| ... | ... | |
| 32 | 32 |
import apt_pkg |
| 33 | 33 |
from apt.progress.base import OpProgress |
| 34 | 34 |
from time import time, strftime |
| 35 |
import os
|
|
| 35 |
import os |
|
| 36 | 36 |
import StringIO |
| 37 | 37 |
import string |
| 38 | 38 |
import re |
| ... | ... | |
| 41 | 41 |
|
| 42 | 42 |
class EnvironmentConfigBroken(Exception): pass |
| 43 | 43 |
|
| 44 |
# print environmental things
|
|
| 44 |
# print environmental things |
|
| 45 | 45 |
# for k,v in os.environ.iteritems(): print >> sys.stderr, "%r : %r" % (k,v) |
| 46 | 46 |
|
| 47 | 47 |
def getEnv(name, default=None, cast=None): |
| ... | ... | |
| 68 | 68 |
|
| 69 | 69 |
STATE_DIR = getEnv('MUNIN_PLUGSTATE', default='.')
|
| 70 | 70 |
CACHE_FILE = os.path.join(STATE_DIR, "deb_packages.state") |
| 71 |
"""
|
|
| 71 |
""" |
|
| 72 | 72 |
There is no need to execute this script every 5 minutes. |
| 73 | 73 |
The Results are put to this file, next munin-run can read from it |
| 74 | 74 |
CACHE_FILE is usually /var/lib/munin/plugin-state/debian_packages.state |
| 75 | 75 |
""" |
| 76 | 76 |
|
| 77 | 77 |
CACHE_FILE_MAX_AGE = getEnv('CACHE_FILE_MAX_AGE', default=3540, cast=int)
|
| 78 |
"""
|
|
| 78 |
""" |
|
| 79 | 79 |
Age in seconds an $CACHE_FILE can be. If it is older, the script updates |
| 80 | 80 |
""" |
| 81 | 81 |
|
| ... | ... | |
| 103 | 103 |
doc = "apt_pkg.Cache instance, lazy instantiated" |
| 104 | 104 |
def fget(self): |
| 105 | 105 |
class NullProgress(OpProgress): |
| 106 |
""" used for do not giving any progress info,
|
|
| 107 |
while doing apt things used, cause documented
|
|
| 108 |
use of None as OpProgress did not worked in
|
|
| 106 |
""" used for do not giving any progress info, |
|
| 107 |
while doing apt things used, cause documented |
|
| 108 |
use of None as OpProgress did not worked in |
|
| 109 | 109 |
python-apt 0.7 |
| 110 | 110 |
""" |
| 111 | 111 |
def __init__(self): |
| ... | ... | |
| 119 | 119 |
def update(*args,**kwords): |
| 120 | 120 |
pass |
| 121 | 121 |
|
| 122 |
if self._cache is None:
|
|
| 123 |
self._cache = apt_pkg.Cache(NullProgress())
|
|
| 122 |
if self._cache is None: |
|
| 123 |
self._cache = apt_pkg.Cache(NullProgress()) |
|
| 124 | 124 |
return self._cache |
| 125 | 125 |
return locals() |
| 126 | 126 |
|
| ... | ... | |
| 129 | 129 |
doc = "apt_pkg.DepCache object" |
| 130 | 130 |
|
| 131 | 131 |
def fget(self): |
| 132 |
if self._depcache is None:
|
|
| 132 |
if self._depcache is None: |
|
| 133 | 133 |
self._depcache = apt_pkg.DepCache(self.cache) |
| 134 | 134 |
return self._depcache |
| 135 | 135 |
|
| ... | ... | |
| 180 | 180 |
apt.installedPackages |
| 181 | 181 |
apt.upgradablePackages |
| 182 | 182 |
|
| 183 |
initialisation is lazy
|
|
| 183 |
initialisation is lazy |
|
| 184 | 184 |
""" |
| 185 | 185 |
|
| 186 | 186 |
def weightOfPackageFile(detail_tuple, option_tuple): |
| ... | ... | |
| 214 | 214 |
|
| 215 | 215 |
class TreeTwig(defaultdict): |
| 216 | 216 |
def __init__(self, defaultFactory): |
| 217 |
super(TreeTwig, self).__init__(defaultFactory)
|
|
| 217 |
super(TreeTwig, self).__init__(defaultFactory) |
|
| 218 | 218 |
|
| 219 | 219 |
def printAsTree(self, indent=0): |
| 220 | 220 |
for k, tree in self.iteritems(): |
| ... | ... | |
| 245 | 245 |
|
| 246 | 246 |
|
| 247 | 247 |
def getShortestConfigOfOptions(optionList = ['label', 'archive', 'site']): |
| 248 |
"""
|
|
| 248 |
""" |
|
| 249 | 249 |
tries to find the order to print a tree of the optionList |
| 250 |
with the local repositories with the shortest line
|
|
| 250 |
with the local repositories with the shortest line |
|
| 251 | 251 |
possible options are: |
| 252 | 252 |
'component' |
| 253 | 253 |
'label' |
| 254 | 254 |
'site' |
| 255 | 255 |
'archive' |
| 256 |
'origin'
|
|
| 257 |
'architecture'
|
|
| 256 |
'origin' |
|
| 257 |
'architecture' |
|
| 258 | 258 |
Architecture values are usually the same and can be ignored. |
| 259 | 259 |
|
| 260 | 260 |
tells you which representation of a tree as line is shortest. |
| ... | ... | |
| 262 | 262 |
to write the shortest readable output. |
| 263 | 263 |
""" |
| 264 | 264 |
l = optionList # just because l is much shorter |
| 265 |
|
|
| 265 |
|
|
| 266 | 266 |
# creating possible iterations |
| 267 | 267 |
fieldCount = len(optionList) |
| 268 | 268 |
if fieldCount == 1: |
| 269 | 269 |
selection = l |
| 270 | 270 |
elif fieldCount == 2: |
| 271 |
selection = [(x,y)
|
|
| 272 |
for x in l
|
|
| 271 |
selection = [(x,y) |
|
| 272 |
for x in l |
|
| 273 | 273 |
for y in l if x!=y ] |
| 274 | 274 |
elif fieldCount == 3: |
| 275 |
selection = [(x,y,z)
|
|
| 276 |
for x in l
|
|
| 277 |
for y in l if x!=y
|
|
| 275 |
selection = [(x,y,z) |
|
| 276 |
for x in l |
|
| 277 |
for y in l if x!=y |
|
| 278 | 278 |
for z in l if z!=y and z!=x] |
| 279 | 279 |
else: |
| 280 | 280 |
raise Exception("NotImplemented for size %s" % fieldCount)
|
| ... | ... | |
| 289 | 289 |
r = min( d.items(), key=lambda x: x[1] ) |
| 290 | 290 |
|
| 291 | 291 |
return list(r[0]), r[1] |
| 292 |
|
|
| 292 |
|
|
| 293 | 293 |
def getOptionsTree(cache, keys=None): |
| 294 | 294 |
""" |
| 295 | 295 |
t = getOptionsTree(cache, ['archive', 'site', 'label']) |
| ... | ... | |
| 322 | 322 |
""" |
| 323 | 323 |
if type(key) in StringTypes: |
| 324 | 324 |
return file.__getattribute__(key) |
| 325 |
elif type(key) in (TupleType, ListType):
|
|
| 325 |
elif type(key) in (TupleType, ListType): |
|
| 326 | 326 |
nKey = tuple() |
| 327 | 327 |
for pKey in key: |
| 328 | 328 |
nKey = nKey.__add__((file.__getattribute__(pKey),)) |
| 329 | 329 |
return nKey |
| 330 | 330 |
else: |
| 331 |
raise Exception("Not implemented for keytype %s" % type(key))
|
|
| 331 |
raise Exception("Not implemented for keytype %s" % type(key))
|
|
| 332 | 332 |
|
| 333 | 333 |
def getOptionsTree2(cache, primary=None, secondary=None): |
| 334 |
"""
|
|
| 334 |
""" |
|
| 335 | 335 |
primary muss ein iterable oder StringType sein |
| 336 | 336 |
secondary muss iterable oder StringType sein |
| 337 | 337 |
t1 = getOptionsTree2(apt.cache, 'origin', ['site', 'archive']) |
| ... | ... | |
| 369 | 369 |
dKey = file.__getattribute__(sKey) |
| 370 | 370 |
d = d[dKey] |
| 371 | 371 |
return t |
| 372 |
|
|
| 372 |
|
|
| 373 | 373 |
#def getAttributeSet(iterable, attribute): |
| 374 | 374 |
# return set(f.__getattribute__(attribute) for f in iterable) |
| 375 | 375 |
# |
| 376 | 376 |
#def getOrigins(cache): |
| 377 |
# return getAttributeSet(cache.file_list, 'origin')
|
|
| 377 |
# return getAttributeSet(cache.file_list, 'origin') |
|
| 378 | 378 |
# |
| 379 | 379 |
#def getArchives(cache): |
| 380 |
# return getAttributeSet(cache.file_list, 'archive')
|
|
| 380 |
# return getAttributeSet(cache.file_list, 'archive') |
|
| 381 | 381 |
# |
| 382 | 382 |
#def getComponents(cache): |
| 383 |
# return getAttributeSet(cache.file_list, 'component')
|
|
| 383 |
# return getAttributeSet(cache.file_list, 'component') |
|
| 384 | 384 |
# |
| 385 | 385 |
#def getLabels(cache): |
| 386 |
# return getAttributeSet(cache.file_list, 'label')
|
|
| 386 |
# return getAttributeSet(cache.file_list, 'label') |
|
| 387 | 387 |
# |
| 388 | 388 |
#def getSites(cache): |
| 389 |
# return getAttributeSet(cache.file_list, 'site')
|
|
| 389 |
# return getAttributeSet(cache.file_list, 'site') |
|
| 390 | 390 |
# |
| 391 | 391 |
|
| 392 | 392 |
class PackageStat(defaultdict): |
| ... | ... | |
| 397 | 397 |
with some abilities to print output munin likes |
| 398 | 398 |
""" |
| 399 | 399 |
|
| 400 |
sortDict = { 'label': defaultdict( lambda : 20,
|
|
| 401 |
{'Debian': 90,
|
|
| 400 |
sortDict = { 'label': defaultdict( lambda : 20,
|
|
| 401 |
{'Debian': 90,
|
|
| 402 | 402 |
'' : 1, |
| 403 | 403 |
'Debian Security' : 90, |
| 404 | 404 |
'Debian Backports': 90}), |
| 405 | 405 |
'archive': defaultdict( lambda : 5, |
| 406 |
{ 'now': 0,
|
|
| 406 |
{ 'now': 0,
|
|
| 407 | 407 |
'experimental': 10, |
| 408 |
'unstable': 50,
|
|
| 409 |
'sid': 50,
|
|
| 408 |
'unstable': 50, |
|
| 409 |
'sid': 50, |
|
| 410 | 410 |
'testing': 70, |
| 411 | 411 |
'wheezy': 70, |
| 412 | 412 |
'squeeze-backports': 80, |
| ... | ... | |
| 426 | 426 |
} |
| 427 | 427 |
""" |
| 428 | 428 |
Values to sort options (label, archive, origin ...) |
| 429 |
(0..99) is allowed.
|
|
| 429 |
(0..99) is allowed. |
|
| 430 | 430 |
(this is needed for other graphs to calc aggregated weights) |
| 431 |
higher is more older and more official or better
|
|
| 431 |
higher is more older and more official or better |
|
| 432 | 432 |
""" |
| 433 | 433 |
|
| 434 | 434 |
dpkgStatusValue = { 'site': '', 'origin': '', 'label': '', 'component': '', 'archive': 'now' }
|
| ... | ... | |
| 443 | 443 |
'component' : 10**2, |
| 444 | 444 |
} |
| 445 | 445 |
""" |
| 446 |
Dict that stores multipliers
|
|
| 446 |
Dict that stores multipliers |
|
| 447 | 447 |
to compile a sorting value for each archivefile |
| 448 | 448 |
""" |
| 449 | 449 |
|
| ... | ... | |
| 483 | 483 |
def addPackage(self, sourceFile, package): |
| 484 | 484 |
if self.packetHandler.decider(package): |
| 485 | 485 |
self.packetHandler.adder(package, self) |
| 486 |
|
|
| 486 |
|
|
| 487 | 487 |
@classmethod |
| 488 | 488 |
def configD(cls, key, value): |
| 489 | 489 |
i = { 'rrdName': cls.generate_rrd_name_from(key),
|
| ... | ... | |
| 514 | 514 |
print "{rrdName}.draw AREASTACK".format(**i)
|
| 515 | 515 |
|
| 516 | 516 |
def optionIsDpkgStatus(self, details, options=None): |
| 517 |
"""
|
|
| 518 |
give it details and options and it tells you whether the datails looks like they come from
|
|
| 517 |
""" |
|
| 518 |
give it details and options and it tells you whether the datails looks like they come from |
|
| 519 | 519 |
a 'Debian dpkg status file'. |
| 520 | 520 |
""" |
| 521 | 521 |
# setting defaults |
| ... | ... | |
| 530 | 530 |
return isNow |
| 531 | 531 |
|
| 532 | 532 |
def printValues(self): |
| 533 |
print "\nmultigraph packages_{option}_{type}".format(option=self.generate_rrd_name_from(self.option),
|
|
| 533 |
print "\nmultigraph packages_{option}_{type}".format(option=self.generate_rrd_name_from(self.option),
|
|
| 534 | 534 |
type=self.packetHandler.type) |
| 535 | 535 |
for options, item in self.options_sorted: |
| 536 | 536 |
if not self.packetHandler.includeNow and self.optionIsDpkgStatus(details=options): |
| ... | ... | |
| 555 | 555 |
|
| 556 | 556 |
class PacketHandler(object): |
| 557 | 557 |
""" |
| 558 |
Baseclass, that represents the Interface which is used
|
|
| 558 |
Baseclass, that represents the Interface which is used |
|
| 559 | 559 |
""" |
| 560 | 560 |
|
| 561 | 561 |
type = None |
| ... | ... | |
| 591 | 591 |
return weightOfPackageFile(details, options) |
| 592 | 592 |
|
| 593 | 593 |
class PacketHandlerUpgradable(PacketHandler): |
| 594 |
|
|
| 594 |
|
|
| 595 | 595 |
type='upgradable' |
| 596 | 596 |
includeNow = False |
| 597 | 597 |
extInfoItemString = " {i[0].name} <{i[1]} -> {i[2]}>"
|
| ... | ... | |
| 628 | 628 |
# this item (as i) is used for input in extInfoItemString |
| 629 | 629 |
item = package |
| 630 | 630 |
packageStat[keys].append(item) |
| 631 |
|
|
| 631 |
|
|
| 632 | 632 |
# registering PackageHandler for Usage |
| 633 | 633 |
packetHandlerD[PacketHandlerInstalled.type] = PacketHandlerInstalled |
| 634 | 634 |
|
| ... | ... | |
| 637 | 637 |
def __init__(self, commandLineArgs=None): |
| 638 | 638 |
self.commandLineArgs = commandLineArgs |
| 639 | 639 |
self.argParser = self._argParser() |
| 640 |
self.executionMatrix = {
|
|
| 640 |
self.executionMatrix = {
|
|
| 641 | 641 |
'config': self.config, |
| 642 | 642 |
'run' : self.run, |
| 643 | 643 |
'autoconf' : self.autoconf, |
| ... | ... | |
| 685 | 685 |
else: |
| 686 | 686 |
raise Exception('DPKG-statusfile %r not found, really strange!!!'%dpkgStatusFile)
|
| 687 | 687 |
newestFileTimestamp = max(timeL) |
| 688 |
age = newestFileTimestamp - cacheMTime
|
|
| 688 |
age = newestFileTimestamp - cacheMTime |
|
| 689 | 689 |
if age > 0: |
| 690 | 690 |
return True |
| 691 | 691 |
else: |
| ... | ... | |
| 709 | 709 |
# cacheNeedUpdate = True |
| 710 | 710 |
|
| 711 | 711 |
if self._cacheIsOutdated() or self.args.nocache: |
| 712 |
# save stdout
|
|
| 712 |
# save stdout |
|
| 713 | 713 |
stdoutDef = sys.stdout |
| 714 | 714 |
try: |
| 715 | 715 |
out = StringIO.StringIO() |
| ... | ... | |
| 765 | 765 |
def _argParser(self): |
| 766 | 766 |
parser = argparse.ArgumentParser(description="Show some statistics "\ |
| 767 | 767 |
"about debian packages installed on system by archive", |
| 768 |
)
|
|
| 768 |
) |
|
| 769 | 769 |
parser.set_defaults(command='run', debug=True, nocache=True) |
| 770 | 770 |
|
| 771 | 771 |
parser.add_argument('--nocache', '-n', default=False, action='store_true',
|
| ... | ... | |
| 775 | 775 |
run ........ munin run (writes values) |
| 776 | 776 |
autoconf ... writes 'yes' |
| 777 | 777 |
""" |
| 778 |
parser.add_argument('command', nargs='?',
|
|
| 778 |
parser.add_argument('command', nargs='?',
|
|
| 779 | 779 |
choices=['config', 'run', 'autoconf', 'drun'], |
| 780 | 780 |
help='mode munin wants to use. "run" is default' + helpCommand) |
| 781 | 781 |
return parser |
| ... | ... | |
| 783 | 783 |
def _envParser(self): |
| 784 | 784 |
""" |
| 785 | 785 |
reads environVars from [deb_packages] and generate |
| 786 |
a list of dicts, each dict holds a set of settings made in
|
|
| 786 |
a list of dicts, each dict holds a set of settings made in |
|
| 787 | 787 |
munin config. |
| 788 |
[
|
|
| 789 |
{ 'type' = 'installed',
|
|
| 788 |
[ |
|
| 789 |
{ 'type' = 'installed',
|
|
| 790 | 790 |
'sort_by' = ['label', 'archive'], |
| 791 | 791 |
'show_ext' = ['origin', 'site'], |
| 792 | 792 |
}, |
| ... | ... | |
| 816 | 816 |
configPart['show_ext'][m.group('optNumber')] = os.getenv(var)
|
| 817 | 817 |
else: |
| 818 | 818 |
print >> sys.stderr, "configuration option %r was ignored" % (var) |
| 819 |
# we have now dicts for 'sort_by' and 'show_ext' keys
|
|
| 819 |
# we have now dicts for 'sort_by' and 'show_ext' keys |
|
| 820 | 820 |
# changing them to lists |
| 821 | 821 |
for graphConfig in config.itervalues(): |
| 822 | 822 |
graphConfig['sort_by'] = [val for key, val in sorted(graphConfig['sort_by'].items())] |
| ... | ... | |
| 839 | 839 |
"Graph must be sorted by anything" |
| 840 | 840 |
raise EnvironmentConfigBroken("Environment Config broken")
|
| 841 | 841 |
# check for valid options for sort_by |
| 842 |
unusableOptions = set(graph['sort_by']) - PackageStat.viewSet
|
|
| 843 |
if unusableOptions:
|
|
| 842 |
unusableOptions = set(graph['sort_by']) - PackageStat.viewSet |
|
| 843 |
if unusableOptions: |
|
| 844 | 844 |
print >> sys.stderr, \ |
| 845 | 845 |
"%r are not valid options for 'sort_by'" % (unusableOptions) |
| 846 | 846 |
raise EnvironmentConfigBroken("Environment Config broken")
|
| 847 | 847 |
# check for valid options for sort_by |
| 848 |
unusableOptions = set(graph['show_ext']) - PackageStat.viewSet
|
|
| 848 |
unusableOptions = set(graph['show_ext']) - PackageStat.viewSet |
|
| 849 | 849 |
if unusableOptions: |
| 850 | 850 |
print >> sys.stderr, \ |
| 851 | 851 |
"%r are not valid options for 'show_ext'" % (x) |
| plugins/arangodb/arangodb_ | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/python |
| 2 | 2 |
|
| 3 | 3 |
""" |
| 4 |
Plugin to monitor ArangoDB servers. It works with the new server statistics
|
|
| 4 |
Plugin to monitor ArangoDB servers. It works with the new server statistics |
|
| 5 | 5 |
interface of ArangoDB 1.3. Not every value seems senseful, but there are |
| 6 | 6 |
nice graphs generated... |
| 7 | 7 |
|
| ... | ... | |
| 30 | 30 |
Links possible: |
| 31 | 31 |
arangodb_conn HTTP client connections |
| 32 | 32 |
arangodb_time_total Total request/queue/connection time |
| 33 |
arangodb_bytes_total Total sent/received bytes
|
|
| 33 |
arangodb_bytes_total Total sent/received bytes |
|
| 34 | 34 |
|
| 35 | 35 |
|
| 36 | 36 |
Configuration: |
| 37 | 37 |
- No configuration required. Just enable the admin interface of ArangoDB. |
| 38 | 38 |
|
| 39 |
Thanks to the authors of other Python munin plugins. I've used some of
|
|
| 40 |
them as inspiring example.
|
|
| 39 |
Thanks to the authors of other Python munin plugins. I've used some of |
|
| 40 |
them as inspiring example. |
|
| 41 | 41 |
|
| 42 | 42 |
Possible todos: |
| 43 | 43 |
- support of munin-like configuration parameters |
| 44 | 44 |
- add more statistics |
| 45 |
|
|
| 45 |
|
|
| 46 | 46 |
""" |
| 47 | 47 |
|
| 48 | 48 |
from os.path import basename |
| ... | ... | |
| 57 | 57 |
|
| 58 | 58 |
def getServerStatus(group): |
| 59 | 59 |
raw = urllib2.urlopen( "http://127.0.0.1:8529/_admin/statistics" ).read() |
| 60 |
|
|
| 60 |
|
|
| 61 | 61 |
return json.loads( raw )[group] |
| 62 | 62 |
|
| 63 | 63 |
def doData(plugin_name): |
| ... | ... | |
| 66 | 66 |
|
| 67 | 67 |
elif plugin_name== 'arangodb_time_total': |
| 68 | 68 |
data = getServerStatus('client')
|
| 69 |
timeTotal = data['totalTime']['sum']
|
|
| 70 |
timeConnection = data['connectionTime']['sum']
|
|
| 71 |
timeRequest = data['requestTime']['sum']
|
|
| 72 |
timeQueue = data['queueTime']['sum']
|
|
| 73 |
|
|
| 69 |
timeTotal = data['totalTime']['sum'] |
|
| 70 |
timeConnection = data['connectionTime']['sum'] |
|
| 71 |
timeRequest = data['requestTime']['sum'] |
|
| 72 |
timeQueue = data['queueTime']['sum'] |
|
| 73 |
|
|
| 74 | 74 |
print "total.value " + str(int(round(timeTotal))) |
| 75 | 75 |
print "connection.value " + str(int(round(timeConnection))) |
| 76 | 76 |
print "request.value " + str(int(round(timeRequest))) |
| 77 | 77 |
print "queue.value " + str(int(round(timeQueue))) |
| 78 |
|
|
| 78 |
|
|
| 79 | 79 |
elif plugin_name== 'arangodb_bytes_total': |
| 80 | 80 |
data = getServerStatus('client')
|
| 81 | 81 |
bytesReceived = data['bytesReceived']['sum'] |
| 82 | 82 |
bytesSent = data['bytesSent']['sum'] |
| 83 | 83 |
print "received.value " + str(int(round(bytesReceived))) |
| 84 | 84 |
print "sent.value " + str(int(round(bytesSent))) |
| 85 |
|
|
| 85 |
|
|
| 86 | 86 |
else: |
| 87 | 87 |
pass |
| 88 |
|
|
| 88 |
|
|
| 89 | 89 |
def doConfig(plugin_name): |
| 90 | 90 |
if plugin_name == 'arangodb_conn': |
| 91 | 91 |
print "graph_title ArangoDB current connections" |
| ... | ... | |
| 103 | 103 |
print "connection.label connection" |
| 104 | 104 |
print "request.label request" |
| 105 | 105 |
print "queue.label queue" |
| 106 |
|
|
| 106 |
|
|
| 107 | 107 |
elif plugin_name == 'arangodb_bytes_total': |
| 108 | 108 |
print "graph_title ArangoDB total bytes" |
| 109 | 109 |
print "graph_args --base 1024" |
| ... | ... | |
| 125 | 125 |
|
| 126 | 126 |
else: |
| 127 | 127 |
pass |
| 128 |
|
|
| 128 |
|
|
| 129 | 129 |
|
| 130 | 130 |
|
| 131 | 131 |
plugin_name = basename(sys.argv[0]) |
| plugins/aris/aris_players | ||
|---|---|---|
| 18 | 18 |
# Parameters: |
| 19 | 19 |
# |
| 20 | 20 |
# config (required) |
| 21 |
#
|
|
| 21 |
# |
|
| 22 | 22 |
# |
| 23 | 23 |
#%# family=manual |
| 24 | 24 |
|
| plugins/assp/assp-envelope-recipient-statistics | ||
|---|---|---|
| 73 | 73 |
# =============== THE GET ==================== |
| 74 | 74 |
if( $ARGV[0] eq "" ){
|
| 75 | 75 |
my $agent = LWP::UserAgent->new(); |
| 76 |
$agent->agent("$agentname");
|
|
| 76 |
$agent->agent("$agentname");
|
|
| 77 | 77 |
$response = $agent->get( $url ); |
| 78 | 78 |
&response_error() unless $response->is_success; |
| 79 | 79 |
@content = split( /\n/, $response->content ); |
| 80 | 80 |
|
| 81 | 81 |
my $line = ""; |
| 82 |
my $count = $index{from};
|
|
| 82 |
my $count = $index{from};
|
|
| 83 | 83 |
my $label; |
| 84 | 84 |
my( $key, $value, $last ); |
| 85 | 85 |
while( 1 ){
|
| plugins/assp/assp-general-runtime-information | ||
|---|---|---|
| 12 | 12 |
|
| 13 | 13 |
use strict; |
| 14 | 14 |
use warnings; |
| 15 |
use File::Basename;
|
|
| 15 |
use File::Basename; |
|
| 16 | 16 |
use LWP; |
| 17 | 17 |
use Mail::Sendmail; |
| 18 | 18 |
|
| ... | ... | |
| 53 | 53 |
# =============== THE GET ==================== |
| 54 | 54 |
if( $ARGV[0] eq "" ){
|
| 55 | 55 |
my $agent = LWP::UserAgent->new(); |
| 56 |
$agent->agent("$agentname");
|
|
| 56 |
$agent->agent("$agentname");
|
|
| 57 | 57 |
$response = $agent->get( $url ); |
| 58 | 58 |
&response_error() unless $response->is_success; |
| 59 | 59 |
@content = split( /\n/, $response->content ); |
| 60 |
|
|
| 60 |
|
|
| 61 | 61 |
my $line = ""; |
| 62 | 62 |
my $count = $index{from};
|
| 63 | 63 |
my $label; |
| plugins/assp/assp-message-statistics | ||
|---|---|---|
| 17 | 17 |
use Mail::Sendmail; |
| 18 | 18 |
|
| 19 | 19 |
# -------------------------- DEBUG VARS --------------------------------- |
| 20 |
my $DEBUG = 0; # for debugging purpose
|
|
| 21 |
my $EMAILDEBUG = 0; # for email debugging
|
|
| 22 |
my $pluginname = &basename( "$0" ); # get the basename of the plugin
|
|
| 23 |
my @to = qw( webmaster@bguel.info ); # the list of admins receivced messages on an
|
|
| 24 |
my $from = "$pluginname-at-host\@guel.info"; # the host from where it comes
|
|
| 25 |
my $muninnodename = "mail.guel.info"; # the Node from where it comes
|
|
| 26 |
my $smtp = "mail.guel.info"; # the smtp relay to send the mail
|
|
| 20 |
my $DEBUG = 0; # for debugging purpose |
|
| 21 |
my $EMAILDEBUG = 0; # for email debugging |
|
| 22 |
my $pluginname = &basename( "$0" ); # get the basename of the plugin |
|
| 23 |
my @to = qw( webmaster@bguel.info ); # the list of admins receivced messages on an
|
|
| 24 |
my $from = "$pluginname-at-host\@guel.info"; # the host from where it comes |
|
| 25 |
my $muninnodename = "mail.guel.info"; # the Node from where it comes |
|
| 26 |
my $smtp = "mail.guel.info"; # the smtp relay to send the mail |
|
| 27 | 27 |
|
| 28 | 28 |
# ------------------------- GLOBAL VARS --------------------------------- |
| 29 |
my $version = "1.0"; # UA Version
|
|
| 30 |
my $agentname = "$pluginname Munin Plugin V$version"; # UA String
|
|
| 31 |
my $url = "http://localhost:55553/"; # (defaults to localhost)
|
|
| 32 |
my $response = 0; # the server output
|
|
| 33 |
my @content = (); # the content we're retrive from $response
|
|
| 29 |
my $version = "1.0"; # UA Version |
|
| 30 |
my $agentname = "$pluginname Munin Plugin V$version"; # UA String |
|
| 31 |
my $url = "http://localhost:55553/"; # (defaults to localhost) |
|
| 32 |
my $response = 0; # the server output |
|
| 33 |
my @content = (); # the content we're retrive from $response |
|
| 34 | 34 |
my %index = ( # for Version 2 |
| 35 |
'from' => 66, # <-- index frame from ( a tweak for other ASSP Versions )
|
|
| 36 |
'to' => 100 # <-- index frame to ( "" )
|
|
| 35 |
'from' => 66, # <-- index frame from ( a tweak for other ASSP Versions ) |
|
| 36 |
'to' => 100 # <-- index frame to ( "" ) |
|
| 37 | 37 |
); |
| 38 | 38 |
|
| 39 | 39 |
|
| ... | ... | |
| 85 | 85 |
# =============== THE GET ==================== |
| 86 | 86 |
if( $ARGV[0] eq "" ){
|
| 87 | 87 |
my $agent = LWP::UserAgent->new(); |
| 88 |
$agent->agent("$agentname");
|
|
| 88 |
$agent->agent("$agentname");
|
|
| 89 | 89 |
$response = $agent->get( $url ); |
| 90 | 90 |
&response_error() unless $response->is_success; |
| 91 | 91 |
@content = split( /\n/, $response->content ); |
| 92 | 92 |
|
| 93 | 93 |
my $line = ""; |
| 94 |
my $count = $index{from};
|
|
| 94 |
my $count = $index{from};
|
|
| 95 | 95 |
my $label; |
| 96 | 96 |
my( $key, $value, $last ); |
| 97 | 97 |
while( 1 ){
|
| plugins/assp/assp-smtp-connection-statistics | ||
|---|---|---|
| 63 | 63 |
# =============== THE GET ==================== |
| 64 | 64 |
if( $ARGV[0] eq "" ){
|
| 65 | 65 |
my $agent = LWP::UserAgent->new(); |
| 66 |
$agent->agent("$agentname");
|
|
| 66 |
$agent->agent("$agentname");
|
|
| 67 | 67 |
$response = $agent->get( $url ); |
| 68 | 68 |
&response_error() unless $response->is_success; |
| 69 | 69 |
@content = split( /\n/, $response->content ); |
| 70 | 70 |
|
| 71 | 71 |
my $line = ""; |
| 72 |
my $count = $index{from};
|
|
| 72 |
my $count = $index{from};
|
|
| 73 | 73 |
my $label; |
| 74 | 74 |
my( $key, $value, $last ); |
| 75 | 75 |
while( 1 ){
|
| plugins/assp/assp-smtp-handler-statistics | ||
|---|---|---|
| 12 | 12 |
|
| 13 | 13 |
use strict; |
| 14 | 14 |
use warnings; |
| 15 |
use File::Basename;
|
|
| 15 |
use File::Basename; |
|
| 16 | 16 |
use LWP; |
| 17 | 17 |
use Mail::Sendmail; |
| 18 | 18 |
|
| ... | ... | |
| 53 | 53 |
# =============== THE GET ==================== |
Formats disponibles : Unified diff