2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge branch 'master' of git://github.com/munin-monitoring/contrib

This commit is contained in:
Artem Sheremet 2012-02-28 02:28:27 +03:00
commit 23eac3fd95
16 changed files with 1038 additions and 168 deletions

View File

@ -1,168 +0,0 @@
#!/bin/sh
#
# Munin Plugin
# to count logins to your dovecot mailserver
#
# Created by Dominik Schulz <lkml@ds.gauner.org>
# http://developer.gauner.org/munin/
# Contributions by:
# - Stephane Enten <tuf@delyth.net>
# Modified by Fabián Sellés Rosa <fabian.sellesrosa@alum.uca.es>
# and Arturo Blanco Paramio <mad@madito.es>
# cleaned up and adapted for dovecot 1.2.6 for Ubuntu 10.4
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# Config variables:
#
# logfile - Where to find the syslog file
#
# Add the following line to a file in /etc/munin/plugin-conf.d:
# env.logfile /var/log/your/logfile.log
#
# Magic markers (optional - used by munin-config and installation scripts):
#
#%# family=auto
#%# capabilities=autoconf
######################
# Configuration
######################
STAT_FILE=/var/lib/munin/plugin-state/plugin-dovecot.state
EXPR_BIN=/usr/bin/expr
LOGFILE=${logfile:-/var/log/dovecot-info.log}
######################
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Logins en Dovecot'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel Contadores de Login'
echo 'graph_total total'
echo 'graph_category Correo'
echo 'login_total.label Total Logins'
echo 'login_total.min 1'
echo 'login_tls.label TLS Logins'
echo 'login_tls.min 1'
echo 'login_ssl.label SSL Logins'
echo 'login_ssl.label SSL Logins'
echo 'login_imap.label IMAP Logins'
echo 'login_pop3.label POP3 Logins'
echo 'connected.label Connected Users'
exit 0
fi
#############################
# Initialization
#############################
if [ ! -r $STAT_FILE ]; then
echo "TOTAL=0" > $STAT_FILE
echo "TLS=0" >> $STAT_FILE
echo "SSL=0" >> $STAT_FILE
echo "IMAP=0" >> $STAT_FILE
echo "POP3=0" >> $STAT_FILE
fi
#############################
######################
# Total Logins
######################
NEW_TOTAL=$(egrep '*Login' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
OLD_TOTAL=$(grep TOTAL $STAT_FILE | cut -f2 -d '=')
TOTAL=$(($NEW_TOTAL - $OLD_TOTAL))
LOGINVALUE=0
if [ $TOTAL -gt 0 ]; then
LOGINVALUE=$TOTAL
fi
######################
# Connected Users
######################
DISCONNECTS=$(egrep '*Disconnected' $LOGFILE | sort | wc -l)
CONNECTS=$(egrep '.*Login' $LOGFILE | sort | wc -l)
DISCON=$(($CONNECTS - $DISCONNECTS))
if [ $DISCON -lt 0 ]; then
DISCON=0
fi
######################
# TLS Logins
######################
NEW_TLS=$(egrep '.*Login.*TLS' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
OLD_TLS=$(grep TLS $STAT_FILE | cut -f2 -d '=')
TLS=$(($NEW_TLS - $OLD_TLS))
TLSVALUE=0
if [ $TLS -gt 0 ]; then
TLSVALUE=$TLS
fi
echo -n
######################
# SSL Logins
######################
NEW_SSL=$(egrep '.*Login.*SSL' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
OLD_SSL=$(grep SSL $STAT_FILE | cut -f2 -d '=')
SSL=$(($NEW_SSL - $OLD_SSL))
SSLVALUE=0
if [ $SSL -gt 0 ]; then
SSLVALUE=$SSL
fi
######################
# IMAP Logins
######################
NEW_IMAP=$(egrep '.*imap.*Login' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
OLD_IMAP=$(grep IMAP $STAT_FILE | cut -f2 -d '=')
IMAP=$(($NEW_IMAP - $OLD_IMAP))
IMAPVALUE=0
if [ $IMAP -gt 0 ]; then
IMAPVALUE=$IMAP
fi
######################
# POP3 Logins
######################
NEW_POP3=$(egrep '.*pop3.*Login' $LOGFILE | grep "`date '+%Y-%m-%d'`" | sort | wc -l)
OLD_POP3=$(grep POP3 $STAT_FILE | cut -f2 -d '=')
POP3=$(($NEW_POP3 - $OLD_POP3))
POP3VALUE=0
if [ $POP3 -gt 0 ]; then
POP3VALUE=$POP3
fi
#######################
# echo the new values
######################
echo "login_total.value $LOGINVALUE"
echo "connected.value $DISCON"
echo "login_tls.value $TLSVALUE"
echo "login_ssl.value $SSLVALUE "
echo "login_imap.value $IMAPVALUE"
echo "login_pop3.value $POP3VALUE "
######################
# Save the new values
######################
echo "TOTAL=$NEW_TOTAL" > $STAT_FILE
echo "TLS=$NEW_TLS" >> $STAT_FILE
echo "SSL=$NEW_SSL" >> $STAT_FILE
echo "IMAP=$NEW_IMAP" >> $STAT_FILE
echo "POP3=$NEW_POP3" >> $STAT_FILE

285
plugins/djabberd/djabberd_ Normal file
View File

@ -0,0 +1,285 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2012 Dominik Schulz <dominik.schulz@gauner.org>
#
# 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; version 2 dated June,
# 1991.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Script to monitor DJabberd servers.
# Mostly an adaptation of Guillaume Blairon's mogliefsd_activity script.
#
# Usage:
# ln -s /usr/share/munin/plugins/djabberd_ \
# /etc/munin/plugins/djabberd_{connections,memory,latency,counters}
#
# Configuration variables:
#
# host (default: '127.0.0.1')
# port (default: '5200')
#
# Parameters:
#
# config (required)
# autoconf (optional - only used by munin-config)
#
#%# family=auto
#%# capabilities=autoconf
use strict;
use warnings;
use IO::Socket;
my $djabberd_host = $ENV{host} || "127.0.0.1";
my $djabberd_port = $ENV{port} || 5200;
my $mode = undef;
my $mode_name = undef;
# mapping mode to command from which we get the information
my $mode_ref = {
'connections' => {
'cmd' => 'stats',
'title' => 'DJabberd Connections',
'vlabel' => 'connections',
'fields' => {
'connections' => {
'key' => 'connections',
'label' => 'Connections',
'description' => 'Number of current connections',
'draw' => 'LINE1',
'type' => 'GAUGE',
},
'users' => {
'key' => 'users',
'label' => 'Users',
'description' => 'Number of connected users',
'draw' => 'LINE1',
'type' => 'GAUGE',
},
},
},
'memory' => {
'cmd' => 'stats',
'title' => 'DJabberd Memory Statistics',
'vlabel' => 'Bytes',
'fields' => {
'mem_total' => {
'key' => 'mem_total',
'label' => '',
'description' => 'Total memory used by DJabberd',
'draw' => 'LINE1',
'type' => 'GAUGE',
'filter' => \&kb2bytes,
},
'mem_connections' => {
'key' => 'mem_connections',
'label' => '',
'description' => 'Memory used for handling connections',
'draw' => 'LINE1',
'type' => 'GAUGE',
'filter' => \&kb2bytes,
},
'mem_per_connection' => {
'key' => 'mem_per_connection',
'label' => '',
'description' => 'Memory used per connection',
'draw' => 'LINE1',
'type' => 'GAUGE',
'filter' => \&kb2bytes,
},
}
},
'latency' => {
'cmd' => 'latency',
'title' => 'DJabberd Latency Statistics',
'vlabel' => 'reqs.',
'fields' => {
'dotzerozerozerofive' => {
'key' => '-0.0005',
'label' => 'lt. 0.0005',
'description' => 'Requests handled in lt. 0.0005s',
'draw' => 'AREA',
'type' => 'COUNTER',
},
'dotzerozeroone' => {
'key' => '-0.001',
'label' => 'lt. 0.001',
'description' => 'Requests handled int lt. 0.001s',
'draw' => 'STACK',
'type' => 'COUNTER',
},
'dotzerozerotwo' => {
'key' => '-0.002',
'label' => 'lt. 0.002',
'description' => 'Requests handled int lt. 0.002s',
'draw' => 'STACK',
'type' => 'COUNTER',
},
'dotzerozerofive' => {
'key' => '-0.005',
'label' => 'lt. 0.005',
'description' => 'Requests handled int lt. 0.005s',
'draw' => 'STACK',
'type' => 'COUNTER',
},
'dotzeroone' => {
'key' => '-0.01',
'label' => 'lt. 0.01',
'description' => 'Requests handled int lt. 0.01s',
'draw' => 'STACK',
'type' => 'COUNTER',
},
'dotzerotwo' => {
'key' => '-0.02',
'label' => 'lt. 0.02',
'description' => 'Requests handled int lt. 0.02s',
'draw' => 'STACK',
'type' => 'COUNTER',
},
}
},
'counters' => {
'cmd' => 'counters',
'title' => 'DJabberd Counters',
'vlabel' => 'msgs.',
'fields' => {
'clientin_djabberd_iq' => { 'key' => 'ClientIn:DJabberd::IQ', 'type' => 'COUNTER', },
'clientin_djabberd_message' => { 'key' => 'ClientIn:DJabberd::Message', 'type' => 'COUNTER', },
'clientin_djabberd_presence' => { 'key' => 'ClientIn:DJabberd::Presence', 'type' => 'COUNTER', },
'clientin_djabberd_stanza_sasl' => { 'key' => 'ClientIn:DJabberd::Stanza::SASL', 'type' => 'COUNTER', },
'clientin_djabberd_stanza_starttls' => { 'key' => 'ClientIn:DJabberd::Stanza::StartTLS', 'type' => 'COUNTER', },
'iniq_get_info_query' => { 'key' => 'InIQ:get-{http://jabber.org/protocol/disco#info}query', 'type' => 'COUNTER', },
'iniq_get_items_query' => { 'key' => 'InIQ:get-{http://jabber.org/protocol/disco#items}query', 'type' => 'COUNTER', },
'iniq_get_roster_query' => { 'key' => 'InIQ:get-{jabber:iq:roster}query', 'type' => 'COUNTER', },
'iniq_get_bind' => { 'key' => 'InIQ:set-{urn:ietf:params:xml:ns:xmpp-bind}bind', 'type' => 'COUNTER', },
'iniq_get_session' => { 'key' => 'InIQ:set-{urn:ietf:params:xml:ns:xmpp-session}session', 'type' => 'COUNTER', },
'serverin_djabberd_stanza_dialback_result' => { 'key' => 'ServerIn:DJabberd::Stanza::DialbackResult', 'type' => 'COUNTER', },
'serverin_djabberd_stanza_dialback_verify' => { 'key' => 'ServerIn:DJabberd::Stanza::DialbackVerify', 'type' => 'COUNTER', },
'auth_success' => { 'key' => 'auth_success', 'type' => 'COUNTER', },
'c2s_message' => { 'key' => 'c2s-Message', 'type' => 'COUNTER', },
'c2s_presence' => { 'key' => 'c2s-Presence', 'type' => 'COUNTER', },
'connect' => { 'key' => 'connect', 'type' => 'COUNTER', },
'deliver_local' => { 'key' => 'deliver_local', 'type' => 'COUNTER', },
'deliver_s2s' => { 'key' => 'deliver_s2s', 'type' => 'COUNTER', },
'disconnect' => { 'key' => 'disconnect', 'type' => 'COUNTER', },
},
},
};
if ( $0 =~ m/djabberd_(.*)$/ && $mode_ref->{$1} ) {
$mode_name = $1;
$mode = $mode_ref->{$mode_name};
}
else {
print STDERR "ERROR: Unknown mode '$mode'. Exiting.\n";
exit -1;
}
if ( $ARGV[0] && $ARGV[0] eq 'suggest' ) {
print join( "\n", keys %$mode_ref );
exit 0;
}
elsif ( $ARGV[0] && $ARGV[0] eq "autoconf" ) {
my $result_ref = &query_djabberd( $djabberd_host, $djabberd_port, $mode );
if ($result_ref) {
print "yes\n";
}
else {
print "no\n";
}
exit 0;
}
elsif ( $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_title " . $mode->{'title'} . "\n";
print "graph_vlabel " . $mode->{'vlabel'} . "\n";
print "graph_args -l 0\n";
print "graph_category DJabberd\n";
foreach my $field_name ( keys %{ $mode->{'fields'} } ) {
my $label = $mode->{'fields'}->{$field_name}->{'label'} || $field_name;
my $desc = $mode->{'fields'}->{$field_name}->{'description'} || $mode->{'fields'}->{$field_name}->{'key'};
my $draw = $mode->{'fields'}->{$field_name}->{'draw'} || 'LINE1';
my $type = $mode->{'fields'}->{$field_name}->{'type'} || 'COUNTER';
print $field_name. '.label ' . $label . "\n";
print $field_name. '.description ' . $desc . "\n";
print $field_name. '.draw ' . $draw . "\n";
print $field_name. '.type ' . $type . "\n";
}
exit 0;
}
else {
my $result_ref = &query_djabberd( $djabberd_host, $djabberd_port, $mode );
foreach my $field_name ( keys %{ $mode->{'fields'} } ) {
my $key = $mode->{'fields'}->{$field_name}->{'key'};
if ( defined( $result_ref->{$key} ) ) { # check for definedness, may well be zero (false for perl)
my $value = $result_ref->{$key};
# if there is a filter defined for this key apply it now
if ( exists( $mode->{'fields'}->{$field_name}->{'filter'} ) && ref( $mode->{'fields'}->{$field_name}->{'filter'} ) eq 'CODE' ) {
$value = &{ $mode->{'fields'}->{$field_name}->{'filter'} }($value);
}
print $field_name. ".value " . $value . "\n";
}
}
}
sub query_djabberd {
my ( $host, $port, $mode ) = @_;
my $conn = IO::Socket::INET::->new(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => 5,
) or die($!);
my $request = $mode->{'cmd'} . "\n";
$conn->syswrite( $request, length($request) );
my @lines = ();
while ( my $line = $conn->getline() ) {
if ( $line =~ /^\./ ) {
last;
}
push( @lines, $line );
}
close($conn);
my $result_ref = {};
foreach my $line (@lines) {
my ( $key, $value, $unit ) = split /\s+/, $line;
if ( $key && $value ) {
$result_ref->{$key} = $value;
}
}
return $result_ref;
}
# transform kb => bytes
sub kb2bytes {
my $num = shift;
if ( $num && $num =~ m/^\d+$/ ) {
$num *= 1024;
}
return $num;
}

220
plugins/mail/imap_bandwidth Executable file
View File

@ -0,0 +1,220 @@
#!/bin/sh
#
# Revision 1.1 2012/02/26 03:43:27
# Improved labels
#
# Revision 1.0 2012/02/25 21:31:16
# Initial release
#
: <<=cut
=head1 NAME
imap_bandwidth - Munin plugin to measure the current bandwidth of one or more remote IMAP servers.
=head1 APPLICABLE SYSTEMS
Any Linux system with the package "isync" (or "mbsync") installed.
=head1 CONFIGURATION
This configuration section shows a usable example for two imap servers:
[imap_bandwidth]
env.imap_servers internal=imap-internal.example.org external=imap.example.org
env.cert_file /etc/munin-imap-cert.pem
env.username foo_user
env.password secret
env.transfer_volume_kbyte 100
env.use_ssl yes
Both "use_ssl" and "transfer_volume_kbyte" are optional and default to the above
values.
All other parameters are required.
Generate the certificate file by running "mbsync-get-cert imap.example.org".
"imap_servers" is a space-separated list of key=value combinations. "key" is
used as a label in munin graphs. "value" is the full hostname or IP of the IMAP
server. All IMAP servers need to share the same authentication database (i.e.
accept the same username/password).
Reduce the "transfer_volume_kbyte" parameter if you need to minimize traffic.
Maybe you need to specify the "timeout" setting for this plugin if it takes
longer than munin's default timeout.
=head1 INTERPRETATION
The plugin simply shows the average bandwidth during one IMAP upload and one
IMAP download of a file containg random bytes.
You need to be aware that this measurement obviously increases the load on
your IMAP servers for the duration of the measurement.
You also need to be aware of the safety implications imposed by storing
sensitive information (username and password combinations) on your monitoring
server in plaintext.
=head1 VERSION
Version 1.0
=head1 BUGS
None known
Set the environment variable DEBUG=1 if you need to investigate problems.
=head1 AUTHOR
Lars Kruse <devel@sumpfralle.de>
=head1 LICENSE
GPLv3 or higher
=cut
set -eu
#%# family=auto
#%# capabilities=autoconf
TRANSFER_SIZE=${transfer_volume_kbyte:-100}
USE_SSL=${use_ssl:-yes}
IMAP_USERNAME=${username}
IMAP_PASSWORD=${password}
CERT_FILE=${cert_file}
# example value:
# internal=imap-internal.example.org external=imap.example.org
SERVERS="$imap_servers"
if test -n "${DEBUG:-}"; then
TRANSFER_SIZE=20
set -x
fi
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
if ( which mbsync >/dev/null 2>&1 ); then
echo yes
exit 0
else
echo "no (could not run \"mbsync\")"
exit 0
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title IMAP bandwidth'
echo 'graph_vlabel to (+) / from (-) server [bit/s]'
echo 'graph_category network'
for item in $SERVERS; do
key="$(echo "$item" | cut -f 1 -d =)"
clean_name="$(clean_fieldname "$key")"
echo "download_${clean_name}.graph no"
echo "download_${clean_name}.label download"
echo "upload_${clean_name}.label $key"
echo "upload_${clean_name}.negative download_${clean_name}"
done
exit 0
fi
create_dummy_file() {
dd if=/dev/urandom "of=$DUMMY_FILENAME" bs=1K count=${TRANSFER_SIZE} 2>/dev/null
}
is_dummy_file_missing() {
test ! -e "$DUMMY_FILENAME"
}
remove_mail_files() {
get_mail_files | while read fname; do rm "$fname"; done
}
get_mail_files() {
find "$MAILDIR" -type f | grep -v "/\."
}
# run the synchronization
run_sync() {
if test -n "${DEBUG:-}"; then
echo yes | mbsync --config "$SYNCRC" sync || true
else
echo yes | mbsync --config "$SYNCRC" sync >/dev/null 2>/dev/null || true
fi
}
# run the synchronization and determine the duration of this operation
speed_sync() {
start=$(date +%s%N)
run_sync
end=$(date +%s%N)
# did we wrap a minute?
test "$end" -lt "$start" && end=$((end + 60 * 1000000000))
delay=$((end - start))
# use "bit" multiplier
echo "$((8 * TRANSFER_SIZE * 1024 * 1000000000 / delay))"
}
for item in $SERVERS; do
key="$(echo "$item" | cut -f 1 -d =)"
host="$(echo "$item" | cut -f 2- -d =)"
clean_name="$(clean_fieldname "$key")"
MAILDIR="$(mktemp -d)"
# this file needs to include a dot at the beginning - otherwise it gets cleaned up ...
SYNCRC="$MAILDIR/.mbsyncrc"
SYNC_STATE_FILE_PREFIX="$MAILDIR/.syncstate-"
cat - >"$SYNCRC" <<- EOF
SyncState $SYNC_STATE_FILE_PREFIX
Expunge Both
MaildirStore local
Path $MAILDIR
Inbox $MAILDIR
IMAPStore remote
Host $host
UseIMAPS $USE_SSL
User $IMAP_USERNAME
Pass $IMAP_PASSWORD
CertificateFile $CERT_FILE
Channel sync
Master :local:
Slave :remote:
EOF
mkdir "$MAILDIR/new" "$MAILDIR/tmp" "$MAILDIR/cur"
DUMMY_FILENAME="$MAILDIR/new/$(date +%N)"
# download all existing files
run_sync
# remove all local files -> to be purged remotely later
remove_mail_files
# create dummy file for upload
create_dummy_file "$MAILDIR"
output="upload_${clean_name}.value $(speed_sync)"
is_dummy_file_missing && echo "$output" || echo >&2 "upload failed"
# remove local file
remove_mail_files "$MAILDIR"
# persuade mbsync that we have never seen the dummy file ...
rm "$SYNC_STATE_FILE_PREFIX"*
output="download_${clean_name}.value $(speed_sync)"
get_mail_files | grep -q . && echo "$output" || echo >&2 "download failed"
# remove the new file from the imap server
remove_mail_files
run_sync
# clean up
rm -r "$MAILDIR"
done

View File

@ -810,6 +810,9 @@ sub fetch_stats {
while (my $line = <$s>) {
if ($line =~ /STAT\s(.+?)\s(.*)/) {
my ($skey,$svalue) = ($1,$2);
if ($skey eq 'evictions') {
$skey = 'evictions_active';
}
$stats{$skey} = $svalue;
}
last if $line =~ /^END/;

View File

@ -0,0 +1,88 @@
#!/usr/bin/perl -w
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=cut
use strict;
use Munin::Plugin;
use Munin::Plugin::SNMP;
my $DEBUG=$ENV{'MUNIN_DEBUG'};
# This is the snmpwalk:
# snAgentTempSensorDescr.1.1 = STRING: "Line module 1, sensor 1 temperature"
# snAgentTempSensorDescr.1.2 = STRING: "Line module 1, sensor 2 temperature"
# snAgentTempSensorDescr.1.3 = STRING: "Line module 1, sensor 3 temperature"
# snAgentTempSensorDescr.1.4 = STRING: "Line module 1, sensor 4 temperature"
# snAgentTempSensorDescr.2.1 = STRING: "Line module 2, sensor 1 temperature"
# snAgentTempSensorDescr.2.2 = STRING: "Line module 2, sensor 2 temperature"
# snAgentTempSensorDescr.2.3 = STRING: "Line module 2, sensor 3 temperature"
# snAgentTempSensorDescr.2.4 = STRING: "Line module 2, sensor 4 temperature"
# snAgentTempSensorDescr.3.1 = STRING: "Active management module temperature"
# snAgentTempSensorDescr.3.2 = STRING: "Active management module temperature"
# snAgentTempValue.1.1 = INTEGER: 100
# snAgentTempValue.1.2 = INTEGER: 106
# snAgentTempValue.1.3 = INTEGER: 82
# snAgentTempValue.1.4 = INTEGER: 72
# snAgentTempValue.2.1 = INTEGER: 74
# snAgentTempValue.2.2 = INTEGER: 102
# snAgentTempValue.2.3 = INTEGER: 70
# snAgentTempValue.2.4 = INTEGER: 74
# snAgentTempValue.3.1 = INTEGER: 78
# snAgentTempValue.3.2 = INTEGER: 84
my $brcdIp = '1.3.6.1.4.1.1991';
my $snAgentTempTable = "$brcdIp.1.1.2.13.1";
my $snAgentTempSensorDescr = "$snAgentTempTable.1.3";
my $snAgentTempValue = "$snAgentTempTable.1.4";
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "index $snAgentTempTable.1.3.\n";
print "require $snAgentTempSensorDescr. [1-9]\n";
print "require $snAgentTempValue. [1-9]\n";
exit 0;
}
my $module = 0;
if ($Munin::Plugin::me =~ /_module_(\d+)$/) {
$module = $1;
} else {
die "Could not determine module number from ".$Munin::Plugin::me."\n";
}
my ($session,$error);
$session = Munin::Plugin::SNMP->session(-translate => [ -nosuchinstance => undef ]);
my $sensor = 1;
if ($ARGV[0] and $ARGV[0] eq "config") {
my ($host,undef,$version) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title Module $module
graph_args --base 1000 --lower-limit 0
graph_vlabel °C
graph_category system
graph_scale no\n";
my $descr = undef;
while (defined ($descr = $session->get_single("$snAgentTempSensorDescr.$module.$sensor"))) {
print "sensor$sensor.label $descr\n";
$sensor ++;
}
exit 0;
}
my $value = undef;
while (defined ($value = $session->get_single("$snAgentTempValue.$module.$sensor"))) {
$value /= 2;
print "sensor$sensor.value $value\n";
$sensor++;
}
# vim:ft=perl

8
plugins/rackspace/README Normal file
View File

@ -0,0 +1,8 @@
======================================================================================
These plugins are made to monitor RackSpace Cloudfiles storage usage and files
count.
======================================================================================
Andrey Kozhokaru
andrey@kozhokaru.com

View File

@ -0,0 +1,70 @@
#!/usr/bin/php
# Author Andrey Kozhokaru <andrey@kozhokaru.com>
# Plugin to monitor Rackspace File count
#
# Parameters:
#
# config (required)
#
#
#%# family=manual
<?php
$x_auth_user='###NAME';
$x_auth_key='###KEY';
$api_url='https://auth.api.rackspacecloud.com/v1.0/';
function SplitTwice($content,$first,$second) {
$s1=split($first,$content);
$splitted=split($second,$s1[1]);
return trim($splitted[0]);
}
if ($argv[1]=='config'){
print "graph_title Rackspace CDN files count\n";
print "graph_vlabel Files Count\n";
print "graph_category rackspace\n";
print "count.label files count\n";
print "graph_args --base 1000\n";
exit;
}
$header_auth = array("X-Auth-User:$x_auth_user","X-Auth-Key:$x_auth_key");
//Authentication
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_auth);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$data = curl_exec($ch);
curl_close($ch);
$cdn_url= SplitTwice($data,'X-Storage-Url: ','Cache');
$token= SplitTwice ($data,'X-Auth-Token:','X-Storage-Token:');
$header_cdn = array ("X-Auth-Token:$token");
//Get data
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, $cdn_url);
curl_setopt($ch1, CURLOPT_HEADER, true);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header_cdn);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, 30);
$data1 = curl_exec($ch1);
curl_close($ch1);
$objects_count = SplitTwice($data1,'X-Account-Object-Count:','X-Account-Bytes-Used:');
$objects_bytes_used = SplitTwice ($data1,'X-Account-Bytes-Used:','X-Account-Container-Count:');
echo 'count.value '.$objects_count;
?>

View File

@ -0,0 +1,67 @@
#!/usr/bin/php
# Author Andrey Kozhokaru <andrey@kozhokaru.com>
# Plugin to monitor Rackspace CloudFile storage usage
#
# Parameters:
#
# config (required)
#
#
#%# family=manual
<?php
$x_auth_user='###NAME';
$x_auth_key='###KEY';
$api_url='https://auth.api.rackspacecloud.com/v1.0/';
function SplitTwice($content,$first,$second) {
$s1=split($first,$content);
$splitted=split($second,$s1[1]);
return trim($splitted[0]);
}
if ($argv[1]=='config'){
print "graph_title Rackspace CDN storage usage\n";
print "graph_vlabel CDN storage usage\n";
print "graph_category rackspace\n";
print "usage.label storage usage\n";
print "graph_args --base 1024\n";
exit;
}
$header_auth = array("X-Auth-User:$x_auth_user","X-Auth-Key:$x_auth_key");
//Authenticate
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_auth);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$data = curl_exec($ch);
curl_close($ch);
$cdn_url= SplitTwice($data,'X-Storage-Url: ','Cache');
$token= SplitTwice ($data,'X-Auth-Token:','X-Storage-Token:');
$header_cdn = array ("X-Auth-Token:$token");
//Get data
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, $cdn_url);
curl_setopt($ch1, CURLOPT_HEADER, true);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header_cdn);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, 30);
$data1 = curl_exec($ch1);
curl_close($ch1);
$objects_bytes_used = SplitTwice ($data1,'X-Account-Bytes-Used:','X-Account-Container-Count:');
echo 'usage.value '.$objects_bytes_used;
?>

297
plugins/zfs/zfs_stats_ Executable file
View File

@ -0,0 +1,297 @@
#!/bin/sh
# ZFS statistics for FreeBSD
# Author: David Bjornsson <dabb@lolnet.is>
#
# Description:
# This is a rewrite of the zfs-stats-for-freebsd
# scripts by patpro. Rather then pulling the
# information from the zfs-stats utility, it
# pulls it straight from sysctl.
#
# Tested on FreeBSD 9.0-RELEASE
#
# Usage: zfs_stats_FUNCTION
#
# Available functions:
# efficiency - ARC efficiency
# cachehitlist - Cache hit by cache list
# cachehitdtype - Cache hit by data type
# dmuprefetch - DMU prefetch
# utilization - ARC size breakdown
# l2utilization - L2ARC size breakdown
# l2efficiency - L2ARC efficiency
#
#%# family=auto
FUNCTION=$(basename $0 | cut -d_ -f3)
PAGESIZE=`/sbin/sysctl -n vm.stats.vm.v_page_size`
MEMSIZE=`/sbin/sysctl -n vm.stats.vm.v_page_count`
MEMMAX=`echo 'scale=2;' $PAGESIZE*$MEMSIZE | /usr/bin/bc -q`
BC='/usr/bin/bc -q'
SYS='/sbin/sysctl -n'
#
# Sysctl macros
#
ARC_HITS=`$SYS kstat.zfs.misc.arcstats.hits`
ARC_MISSES=`$SYS kstat.zfs.misc.arcstats.misses`
DEMAND_DATA_HITS=`$SYS kstat.zfs.misc.arcstats.demand_data_hits`
DEMAND_DATA_MISSES=`$SYS kstat.zfs.misc.arcstats.demand_data_misses`
DEMAND_METADATA_HITS=`$SYS kstat.zfs.misc.arcstats.demand_metadata_hits`
DEMAND_METADATA_MISSES=`$SYS kstat.zfs.misc.arcstats.demand_metadata_misses`
MFU_GHOST_HITS=`$SYS kstat.zfs.misc.arcstats.mfu_ghost_hits`
MFU_HITS=`$SYS kstat.zfs.misc.arcstats.mfu_hits`
MRU_GHOST_HITS=`$SYS kstat.zfs.misc.arcstats.mru_ghost_hits`
MRU_HITS=`$SYS kstat.zfs.misc.arcstats.mru_hits`
PREFETCH_DATA_HITS=`$SYS kstat.zfs.misc.arcstats.prefetch_data_hits`
PREFETCH_DATA_MISSES=`$SYS kstat.zfs.misc.arcstats.prefetch_data_misses`
PREFETCH_METADATA_HITS=`$SYS kstat.zfs.misc.arcstats.prefetch_metadata_hits`
PREFETCH_METADATA_MISSES=`$SYS kstat.zfs.misc.arcstats.prefetch_metadata_misses`
DMU_HITS=`$SYS kstat.zfs.misc.zfetchstats.hits`
DMU_MISSES=`$SYS kstat.zfs.misc.zfetchstats.misses`
SIZE=`$SYS kstat.zfs.misc.arcstats.size`
MRU_SIZE=`$SYS kstat.zfs.misc.arcstats.p`
MAX_SIZE=`$SYS kstat.zfs.misc.arcstats.c_max`
MIN_SIZE=`$SYS kstat.zfs.misc.arcstats.c_min`
TARGET_SIZE=`$SYS kstat.zfs.misc.arcstats.c`
L2_SIZE=`$SYS kstat.zfs.misc.arcstats.l2_size`
L2_HDR_SIZE=`$SYS kstat.zfs.misc.arcstats.l2_hdr_size`
L2_HITS=`$SYS kstat.zfs.misc.arcstats.l2_hits`
L2_MISSES=`$SYS kstat.zfs.misc.arcstats.l2_misses`
#
# Calculation macros
#
ANON_HITS=`echo "$ARC_HITS-($MFU_HITS+$MRU_HITS+$MFU_GHOST_HITS+$MRU_GHOST_HITS)" | $BC`
ARC_ACCESSES_TOTAL=`echo "$ARC_HITS+$ARC_MISSES" | $BC`
DEMAND_DATA_TOTAL=`echo "$DEMAND_DATA_HITS+$DEMAND_DATA_MISSES" | $BC`
PREFETCH_DATA_TOTAL=`echo "$PREFETCH_DATA_HITS+$PREFETCH_DATA_MISSES" | $BC`
REAL_HITS=`echo "$MFU_HITS+$MRU_HITS" | $BC`
CACHE_HIT_RATIO_PERC=`echo "scale=2 ; (100*$ARC_HITS/$ARC_ACCESSES_TOTAL)" | $BC`
CACHE_MISS_RATIO_PERC=`echo "scale=2 ; (100*$ARC_MISSES/$ARC_ACCESSES_TOTAL)" | $BC`
ACTUAL_HIT_RATIO_PERC=`echo "scale=2 ; (100*$REAL_HITS/$ARC_ACCESSES_TOTAL)" | $BC`
DATA_DEMAND_EFFICIENCY_PERC=`echo "scale=2 ; (100*$DEMAND_DATA_HITS/$DEMAND_DATA_TOTAL)" | $BC`
DATA_PREFETCH_EFFICENCY_PERC=`echo "scale=2 ; (100*$PREFETCH_DATA_HITS/$PREFETCH_DATA_TOTAL)" | $BC`
ANONYMOUSLY_USED_PERC=`echo "scale=2 ; (100*$ANON_HITS/$ARC_HITS)" | $BC`
MOST_RECENTLY_USED_PERC=`echo "scale=2 ; (100*$MRU_HITS/$ARC_HITS)" | $BC`
MOST_FREQUENTLY_USED_PERC=`echo "scale=2 ; (100*$MFU_HITS/$ARC_HITS)" | $BC`
MOST_RECENTLY_USED_GHOST_PERC=`echo "scale=2 ; (100*$MRU_GHOST_HITS/$ARC_HITS)" | $BC`
MOST_FREQUENTLY_USED_GHOST_PERC=`echo "scale=2 ; (100*$MFU_GHOST_HITS/$ARC_HITS)" | $BC`
DEMAND_DATA_HIT_PERC=`echo "scale=2 ; (100*$DEMAND_DATA_HITS/$ARC_HITS)" | $BC`
DEMAND_DATA_MISS_PERC=`echo "scale=2 ; (100*$DEMAND_DATA_MISSES/$ARC_MISSES)" | $BC`
PREFETCH_DATA_HIT_PERC=`echo "scale=2 ; (100*$PREFETCH_DATA_HITS/$ARC_HITS)" | $BC`
PREFETCH_DATA_MISS_PERC=`echo "scale=2 ; (100*$PREFETCH_DATA_MISSES/$ARC_MISSES)" | $BC`
DEMAND_METADATA_HIT_PERC=`echo "scale=2 ; (100*$DEMAND_METADATA_HITS/$ARC_HITS)" | $BC`
DEMAND_METADATA_MISS_PERC=`echo "scale=2 ; (100*$DEMAND_METADATA_MISSES/$ARC_MISSES)" | $BC`
PREFETCH_METADATA_HIT_PERC=`echo "scale=2 ; (100*$PREFETCH_METADATA_HITS/$ARC_HITS)" | $BC`
PREFETCH_METADATA_MISSES_PERC=`echo "scale=2 ; (100*$PREFETCH_METADATA_MISSES/$ARC_MISSES)" | $BC`
DMU_TOTAL=`echo "$DMU_HITS+$DMU_MISSES" | $BC`
DMU_HITS_PERC=`echo "scale=2 ; (100*$DMU_HITS/$DMU_TOTAL)" | $BC`
DMU_MISSES_PERC=`echo "scale=2 ; (100*$DMU_MISSES/$DMU_TOTAL)" | $BC`
if [ $SIZE -gt $TARGET_SIZE ]; then
MFU_SIZE=`echo "$SIZE-$MRU_SIZE" | $BC`
else
MFU_SIZE=`echo "$TARGET_SIZE-$MRU_SIZE" | $BC`
fi
L2_ACCESSES_TOTAL=`echo "$L2_HITS+$L2_MISSES" | $BC`
L2_HIT_RATIO_PERC=`echo "scale=2 ; (100*$L2_HITS/$L2_ACCESSES_TOTAL)" | $BC`
L2_MISS_RATIO_PERC=`echo "scale=2 ; (100*$L2_MISSES/$L2_ACCESSES_TOTAL)" | $BC`
efficiency() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS ARC Efficiency'
echo 'graph_args -u 100'
echo 'graph_vlabel %'
echo 'graph_info This graph shows the ARC Efficiency'
echo 'hits.label Hit Ratio'
echo 'misses.label Miss Ratio'
echo 'actual_hits.label Actual Hit Ratio'
echo 'data_demand_efficiency.label Data Demand Efficiency'
echo 'data_prefetch_efficiency.label Data Prefetch Efficiency'
exit 0
else
echo 'hits.value ' $CACHE_HIT_RATIO_PERC
echo 'misses.value ' $CACHE_MISS_RATIO_PERC
echo 'actual_hits.value ' $ACTUAL_HIT_RATIO_PERC
echo 'data_demand_efficiency.value ' $DATA_DEMAND_EFFICIENCY_PERC
echo 'data_prefetch_efficiency.value ' $DATA_PREFETCH_EFFICENCY_PERC
fi
}
cachehitlist() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS ARC Efficiency: Cache hits by cache list'
echo 'graph_args -u 100'
echo 'graph_vlabel %'
echo 'graph_info This graph shows the ARC Efficiency'
echo 'cache_list_anon.label Anonymously Used'
echo 'cache_list_most_rec.label Most Recently Used'
echo 'cache_list_most_freq.label Most Frequently Used'
echo 'cache_list_most_rec_ghost.label Most Recently Used Ghost'
echo 'cache_list_most_freq_ghost.label Most Frequently Used Ghost'
exit 0
else
echo 'cache_list_anon.value ' $ANONYMOUSLY_USED_PERC
echo 'cache_list_most_rec.value ' $MOST_RECENTLY_USED_PERC
echo 'cache_list_most_freq.value ' $MOST_FREQUENTLY_USED_PERC
echo 'cache_list_most_rec_ghost.value ' $MOST_RECENTLY_USED_GHOST_PERC
echo 'cache_list_most_freq_ghost.value ' $MOST_FREQUENTLY_USED_GHOST_PERC
fi
}
cachehitdtype() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS ARC Efficiency: Cache hits by data type'
echo 'graph_args -u 100'
echo 'graph_vlabel %'
echo 'graph_info This graph shows the ARC Efficiency'
echo 'data_type_demand_hits.label Demand Data Hit Ratio'
echo 'data_type_demand_misses.label Demand Data Miss Ratio'
echo 'data_type_prefetch_hits.label Prefetch Data Hit Ratio'
echo 'data_type_prefetch_misses.label Prefetch Data Miss Ratio'
echo 'data_type_demand_metadata_hits.label Demand Metadata Hit Ratio'
echo 'data_type_demand_metadata_misses.label Demand Metadata Miss Ratio'
echo 'data_type_prefetch_metadata_hits.label Prefetch Metadata Hit Ratio'
echo 'data_type_prefetch_metadata_misses.label Prefetch Metadata Miss Ratio'
exit 0
else
echo 'data_type_demand_hits.value ' $DEMAND_DATA_HIT_PERC
echo 'data_type_demand_misses.value ' $DEMAND_DATA_MISS_PERC
echo 'data_type_prefetch_hits.value ' $PREFETCH_DATA_HIT_PERC
echo 'data_type_prefetch_misses.value ' $PREFETCH_DATA_MISS_PERC
echo 'data_type_demand_metadata_hits.value ' $DEMAND_METADATA_HIT_PERC
echo 'data_type_demand_metadata_misses.value ' $DEMAND_METADATA_MISS_PERC
echo 'data_type_prefetch_metadata_hits.value ' $PREFETCH_METADATA_HIT_PERC
echo 'data_type_prefetch_metadata_misses.value ' $PREFETCH_METADATA_MISSES_PERC
fi
}
dmuprefetch() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS DMU prefetch stats'
echo 'graph_args -u 100'
echo 'graph_vlabel %'
echo 'graph_info This graph shows the DMU prefetch stats'
echo 'hits.label Hit Ratio'
echo 'misses.label Miss Ratio'
exit 0
else
echo 'hits.value ' $DMU_HITS_PERC
echo 'misses.value ' $DMU_MISSES_PERC
fi
}
utilization() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS ARC Size'
echo 'graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit '$MEMMAX
echo 'graph_vlabel Size in MB'
echo 'graph_info This graph shows the ARC Size utilization'
echo 'max_size.label Maximum Size'
echo 'max_size.draw AREA'
echo 'target_size.label Target Size'
echo 'target_size.draw AREA'
echo 'size.label Size'
echo 'size.draw AREA'
echo 'recently_size.label Recently Used Cache Size'
echo 'recently_size.draw AREA'
echo 'frequently_size.label Frequently Used Cache Size'
echo 'frequently_size.draw AREA'
echo 'min_size.label Minimum Size'
echo 'min_size.draw AREA'
exit 0
else
echo 'max_size.value ' $MAX_SIZE
echo 'target_size.value ' $TARGET_SIZE
echo 'size.value ' $SIZE
echo 'recently_size.value ' $MRU_SIZE
echo 'frequently_size.value ' $MFU_SIZE
echo 'min_size.value ' $MIN_SIZE
fi
}
l2utilization() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS L2ARC Size'
echo 'graph_args --base 1024 -r -l 0 --vertical-label Bytes'
echo 'graph_vlabel Size in MB'
echo 'graph_info This graph shows the L2ARC Size utilization'
echo 'size.label Size'
echo 'size.draw AREA'
echo 'hdr_size.label Header Size'
echo 'hdr_size.draw AREA'
exit 0
else
echo 'size.value ' $L2_SIZE
echo 'hdr_size.value ' $L2_HDR_SIZE
fi
}
l2efficiency() {
if [ "$1" = "config" ]; then
echo 'graph_title ZFS L2ARC Efficiency'
echo 'graph_args -u 100'
echo 'graph_vlabel %'
echo 'graph_info This graph shows the L2ARC Efficiency'
echo 'l2_hits.label Hit Ratio'
echo 'l2_misses.label Miss Ratio'
else
echo 'l2_hits.value ' $L2_HIT_RATIO_PERC
echo 'l2_misses.value ' $L2_MISS_RATIO_PERC
fi
}
[ "$1" = "config" ] && echo "graph_category zfs"
case "$FUNCTION" in
efficiency)
efficiency $1
;;
cachehitlist)
cachehitlist $1
;;
cachehitdtype)
cachehitdtype $1
;;
dmuprefetch)
dmuprefetch $1
;;
utilization)
utilization $1
;;
l2utilization)
l2utilization $1
;;
l2efficiency)
l2efficiency $1
;;
esac