mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 09:57:09 +00:00
More housecleaning.
Collapse some categories; remove duplicates; move plugins in where they belong, remove files that are not really plugins at all.
This commit is contained in:
parent
4e3ef5b93e
commit
0a1524f27f
45 changed files with 0 additions and 1337 deletions
39
plugins/network/bgpd
Executable file
39
plugins/network/bgpd
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
# bgpd.sh
|
||||
#
|
||||
#
|
||||
# Created by spleen.
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title bgp pfxs'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel PfxRcvd'
|
||||
echo 'graph_category System'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_info show ip bgp summary'
|
||||
mfs=0
|
||||
/usr/local/bin/vtysh -c "sh ip bgp su" | /usr/bin/awk '{ if (( $2 == "4" ) || ( $2 == "6")) print $1 }' | while read i; do
|
||||
case $i in
|
||||
*) name=`echo $i | /usr/bin/awk '{ gsub("[^a-zA-Z0-9_]", root_, $1); print $1 }'` ;;
|
||||
esac
|
||||
dn=`echo $i | sed 's/_/ /g'`
|
||||
echo "$name.label $dn"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/local/bin/vtysh -c "sh ip bgp su" | /usr/bin/awk '{ if (( $2 == "4" ) || ( $2 == "6")) print $1,$10 }' | while read i; do
|
||||
case $i in
|
||||
*) name=`echo $i | /usr/bin/awk '{ gsub("[^a-zA-Z0-9_]", root_, $1); print $1 }'` ;;
|
||||
esac
|
||||
dn=`echo $i | awk '{print $2}'`
|
||||
echo "$name.value $dn"
|
||||
done
|
||||
|
86
plugins/network/ddclient
Executable file
86
plugins/network/ddclient
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
# Munin plugin to show changing the ip address by ddclient.
|
||||
# The base frame is copied from the proftp plugin
|
||||
#
|
||||
##########################################################################################
|
||||
# Folgende Eintraege in der Datei /etc/munin/plugin-conf.d/munin-node nicht vergessen ! #
|
||||
# Don't forget to add following lines to the file /etc/munin/plugin-conf.d/munin-node #
|
||||
# [quota] #
|
||||
# user root #
|
||||
##########################################################################################
|
||||
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and installation
|
||||
# scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
MAXLABEL=20
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title IP Wechsel'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel täglicher IP Wechsel'
|
||||
echo 'graph_category IP'
|
||||
echo 'ip_change.label IP Wechsel'
|
||||
echo 'graph_info Jeder IP-Wechsel der von DDCLIENT festgestellt wird erzeugt einen Wert von 1'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# Beginn des modifizierten Skriptes - Beginning of the modified script #
|
||||
################################################################################
|
||||
|
||||
|
||||
# Nur fuer Testzwecke kann das - For testing only you can
|
||||
# Zeitfenster vergroessert werden resize the reference periode
|
||||
if [ "${1//[^[:digit:]]}" != "" ]; then
|
||||
factor=${1//[^[:digit:]]}
|
||||
else
|
||||
factor=1
|
||||
fi
|
||||
|
||||
# Aktuelle Zeit in Sekunden (C-Format) - now in seconds (c-format)
|
||||
Timestamp=$(date +%s)
|
||||
|
||||
# Zeitfenster in Sekunden - time slot in seconds
|
||||
let Timeslot=60*30*$factor
|
||||
|
||||
# Referenzzeitpunkt berechnen - calculate the reference periode
|
||||
let Ref_Timestamp=Timestamp-Timeslot
|
||||
|
||||
# Zeitstempel der letzten Aktualisierung - timestampe of the last update
|
||||
Last_update=$(grep -i 'last update' /var/cache/ddclient/ddclient.cache)
|
||||
Last_update=${Last_update##*\(}
|
||||
Last_update=${Last_update%%\)}
|
||||
|
||||
# Ausgabe für Munin - output for munin
|
||||
if [ "$Last_update" -gt "$Ref_Timestamp" ]; then
|
||||
echo "ip_change.value 1"
|
||||
else
|
||||
echo "ip_change.value 0"
|
||||
fi
|
||||
|
||||
# Nur zum Testen - for testing ony
|
||||
if [ "$factor" -gt 1 ]; then
|
||||
echo "======================== Nur fuer Testzwecke ======================"
|
||||
echo "Timestamp :" $Timestamp $(date -d "1970-01-01 UTC + $Timestamp seconds")
|
||||
echo "Ref_Timestamp:" $Ref_Timestamp $(date -d "1970-01-01 UTC + $Ref_Timestamp seconds")
|
||||
echo "Zeitfenster :" $((Timeslot/60)) Minuten
|
||||
echo "Last_update :" $Last_update $(date -d "1970-01-01 UTC + $Last_update seconds")
|
||||
echo "======================== for testing only ======================"
|
||||
fi
|
|
@ -1,106 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Plugin to monitor BGP table summary statistics on a cisco router.
|
||||
#
|
||||
# Original Author: Peter Holzleitner
|
||||
#
|
||||
# Revision 1.1 2010/10/14 19:19
|
||||
#
|
||||
# Configuration variables:
|
||||
#
|
||||
# iosuser - username (default "")
|
||||
# iospass - password (default "")
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
#
|
||||
# Magic markers (optional - only used by munin-config and some
|
||||
# installation scripts):
|
||||
#%# family=auto
|
||||
|
||||
|
||||
use Net::Telnet::Cisco;
|
||||
use Sys::Syslog;
|
||||
|
||||
|
||||
if ($0 =~ /^(?:|.*\/)cisco_bgp_([^_]+)$/) {
|
||||
$host = $1;
|
||||
}
|
||||
|
||||
($^O eq "linux" || $^O eq "openbsd") && Sys::Syslog::setlogsock('unix');
|
||||
openlog('munin.bgp', 'cons,pid', 'daemon');
|
||||
|
||||
|
||||
my @BGP_nbr;
|
||||
my @BGP_pfx;
|
||||
my $tot_pfx;
|
||||
my $iosuser = $ENV{iosuser} || "";
|
||||
my $iospass = $ENV{iospass} || "";
|
||||
|
||||
&fetch_bgpstats($host, $iosuser, $iospass);
|
||||
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "host_name $host\n";
|
||||
print "graph_args --base 1024 -l 0 --vertical-label Prefixes\n";
|
||||
print "graph_title BGP Neighbour Statistics\n";
|
||||
print "graph_category network\n";
|
||||
print "graph_info This graph shows the number of BGP prefixes received by neighbour.\n";
|
||||
|
||||
my($n, $i); $n = scalar @BGP_nbr; $i = 0;
|
||||
while($n--) {
|
||||
my $neigh = $BGP_nbr[$i++];
|
||||
print "n$i.label $neigh\n";
|
||||
}
|
||||
|
||||
# print "total.label Total\n";
|
||||
# print "total.info Total number of prefixes in the BGP table\n";
|
||||
|
||||
} else {
|
||||
|
||||
my($n, $i); $n = scalar @BGP_nbr; $i = 0;
|
||||
while($n--) {
|
||||
my $pfx = $BGP_pfx[$i++];
|
||||
print "n$i.value $pfx\n";
|
||||
}
|
||||
# print "total.value $tot_pfx\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub fetch_bgpstats
|
||||
{
|
||||
my $hostname = shift;
|
||||
my $username = shift;
|
||||
my $password = shift;
|
||||
my $session = Net::Telnet::Cisco->new(Host => $host);
|
||||
|
||||
$session->login($username, $password);
|
||||
$session->cmd('terminal length 200');
|
||||
$session->cmd('terminal width 200');
|
||||
my @output = $session->cmd('show ip bgp summary');
|
||||
|
||||
# example output of router
|
||||
# ------------------------
|
||||
# [...]
|
||||
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
|
||||
# 11.111.11.111 4 98765 12403694 509571 308911893 0 0 1d23h 329193
|
||||
# 122.122.122.122 4 1234 13242856 383827 308911879 0 0 00:08:22 330761
|
||||
|
||||
foreach(@output) {
|
||||
chomp; s/\r//g;
|
||||
$tot_pfx = $1 if /^BGP activity (\d+)\/(\d+) prefixes/;
|
||||
syslog('debug', "$hostname: $_\n");
|
||||
|
||||
next unless /^(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+[0-9a-z:]+\s+(\d+)/;
|
||||
my ($neigh, $as, $pfx) = ($1, $2, $3);
|
||||
syslog('debug', "$neigh (AS $as)");
|
||||
push @BGP_nbr, "$neigh (AS $as)";
|
||||
push @BGP_pfx, $pfx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# vim:syntax=perl:ts=8
|
185
plugins/network/dns/dnsresponse_
Executable file
185
plugins/network/dns/dnsresponse_
Executable file
|
@ -0,0 +1,185 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dnsresponse - Plugin to monitor DNS resolution times.
|
||||
"Poor man's smokeping" :)
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any unix system.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The following shows the default configuration.
|
||||
|
||||
[dnsresponse_*]
|
||||
env.site www.google.com
|
||||
env.times 20
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
The plugin shows the average and median times taken to resolve a site.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf,suggest
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
$Id: dnsresponse_ 61 2009-04-14 09:11:00Z stsimb $
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (c) 2009 by Sotiris Tsimbonis.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $DEBUG=0;
|
||||
my $site = exists $ENV{'site'} ? $ENV{'site'} : "www.google.com";
|
||||
my $times = exists $ENV{'times'} ? $ENV{'times'} : "20";
|
||||
my $resconf="/etc/resolv.conf";
|
||||
|
||||
use File::Basename;
|
||||
my $basename=basename($0);
|
||||
my $scriptname;
|
||||
my $dnsip;
|
||||
($scriptname, $dnsip) = split("_", $basename);
|
||||
print "DBG: target dns ip $dnsip\n" if ($DEBUG>0);
|
||||
|
||||
if ( defined $ARGV[0] and $ARGV[0] eq "config" ) {
|
||||
print "graph_title $dnsip DNS response time\n";
|
||||
print "graph_vlabel milliseconds\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_category Other\n";
|
||||
print "graph_info Time taken by $dnsip to resolve $site $times times.\n";
|
||||
#my @val = ("min", "avg", "median", "max");
|
||||
my @val = ("avg", "median", "stddev");
|
||||
my $value;
|
||||
foreach $value ( @val ) {
|
||||
if ($value eq "stddev") {
|
||||
print "$value.info Standard deviation (variance).\n";
|
||||
} else {
|
||||
print "$value.info $value time taken by $dnsip to resolve $site $times times.\n";
|
||||
}
|
||||
print "$value.label $value\n";
|
||||
# print "$value.type DERIVE\n";
|
||||
# print "$value.min 0\n";
|
||||
# print "$value.warning 100\n";
|
||||
# print "$value.critical 600\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
||||
my $ret;
|
||||
if (! eval "require Net::DNS;") { $ret .= "Net::DNS not found. "; }
|
||||
if (! eval "require Time::HiRes;") { $ret .= "Time::HiRes not found. "; }
|
||||
if (! -s $resconf) { $ret .= "$resconf not found. "; }
|
||||
if ($ret) {
|
||||
print "no ($ret)\n";
|
||||
exit 1;
|
||||
} else {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $ARGV[0] and $ARGV[0] eq "suggest" ) {
|
||||
if (-s $resconf) {
|
||||
open (FILE, "< $resconf") || die "Could not open $resconf: $!\n";
|
||||
my $line;
|
||||
while ($line = <FILE>) {
|
||||
if ($line =~ /^nameserver/) {
|
||||
my $ns; my $ip;
|
||||
($ns, $ip) = split(" ", $line);
|
||||
print "$ip\n";
|
||||
}
|
||||
}
|
||||
exit 0;
|
||||
} else {
|
||||
print "ERROR reading $resconf\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
use Time::HiRes qw ( gettimeofday tv_interval );
|
||||
use Net::DNS;
|
||||
|
||||
my $res = Net::DNS::Resolver->new(
|
||||
nameservers => [$dnsip],
|
||||
recurse => 1,
|
||||
debug => $DEBUG,
|
||||
);
|
||||
|
||||
my $i;
|
||||
my @restimes;
|
||||
for ($i=1; $i<=$times; $i++) {
|
||||
my $t0 = [gettimeofday];
|
||||
my $answer = $res->send($site);
|
||||
my $elapsed = tv_interval ($t0);
|
||||
push(@restimes, $elapsed);
|
||||
print "DBG: count $i elapsed $elapsed\n" if ($DEBUG>0);
|
||||
}
|
||||
|
||||
|
||||
@restimes=sort(@restimes);
|
||||
|
||||
#my $min=$restimes[0]*1000;
|
||||
my $average=mean(@restimes)*1000;
|
||||
my $median=median(@restimes)*1000;
|
||||
my $stddev=std_dev_ref_sum(@restimes)*1000;
|
||||
#my $max=$restimes[$times-1]*1000;
|
||||
|
||||
#print "min.value $min\n";
|
||||
print "avg.value $average\n";
|
||||
print "median.value $median\n";
|
||||
print "stddev.value $stddev\n";
|
||||
#print "max.value $max\n";
|
||||
|
||||
sub mean {
|
||||
my $result;
|
||||
foreach (@_) { $result += $_ }
|
||||
return $result / @_;
|
||||
}
|
||||
|
||||
sub median {
|
||||
my @ar = @_;
|
||||
my $elements = scalar(@ar);
|
||||
return $ar[(int($elements-1)/2)];
|
||||
# if ($elements % 2) {
|
||||
# return $ar[($elements-1)/2];
|
||||
# } else {
|
||||
# return ($ar[($elements-1)/2-0.5]+$ar[($elements-1)/2+0.5])/2;
|
||||
# }
|
||||
}
|
||||
|
||||
# Standard Deviance function from http://www.linuxjournal.com/article/6540
|
||||
sub std_dev_ref_sum {
|
||||
my @ar = @_;
|
||||
my $elements = scalar @ar;
|
||||
my $sum = 0;
|
||||
my $sumsq = 0;
|
||||
|
||||
foreach (@ar) {
|
||||
$sum += $_;
|
||||
$sumsq += ($_ **2);
|
||||
}
|
||||
|
||||
return sqrt( $sumsq/$elements - (($sum/$elements) ** 2));
|
||||
}
|
41
plugins/network/dns/pdns_errors
Executable file
41
plugins/network/dns/pdns_errors
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor PowerDNS performance
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
command="/etc/init.d/pdns dump"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Power DNS errors'
|
||||
echo 'graph_args -l 0 --base 1000'
|
||||
echo 'graph_vlabel numbers of'
|
||||
echo 'graph_category Power DNS'
|
||||
echo 'graph_info This graph shows Power DNS performance on the machine.'
|
||||
echo 'corrupt_packets.label corrupt packets'
|
||||
echo 'corrupt_packets.type DERIVE'
|
||||
echo 'corrupt_packets.min 0'
|
||||
echo 'corrupt_packets.info Number of corrupt packets received'
|
||||
echo 'servfail_packets.label servfail packets'
|
||||
echo 'servfail_packets.type DERIVE'
|
||||
echo 'servfail_packets.min 0'
|
||||
echo 'servfail_packets.info Number of times a server-failed packet was sent out'
|
||||
echo 'timedout_packets.label timedout packets'
|
||||
echo 'timedout_packets.type DERIVE'
|
||||
echo 'timedout_packets.min 0'
|
||||
echo 'timedout_packets.info Number of packets which weren not answered within timeout set'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | grep corrupt'\|'servfail'\|'timedout | sed 's/-/_/g'
|
34
plugins/network/dns/pdns_latency
Executable file
34
plugins/network/dns/pdns_latency
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor PowerDNS performance
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
command="/etc/init.d/pdns show"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Power DNS latency'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel usec'
|
||||
echo 'graph_category Power DNS'
|
||||
echo 'graph_info This graph shows Power DNS latency on the machine.'
|
||||
echo 'latency.label latency'
|
||||
echo 'latency.info Average number of microseconds needed to answer a question'
|
||||
echo 'latency.type GAUGE'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
echo "latency.value $($command latency | awk -F= '{print $2}')"
|
35
plugins/network/dns/pdns_qsize
Executable file
35
plugins/network/dns/pdns_qsize
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor PowerDNS performance
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
command="/etc/init.d/pdns show"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Power DNS database queue'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel number of waiting queries'
|
||||
echo 'graph_category Power DNS'
|
||||
echo 'graph_info This graph shows Power DNS database performance on the machine.'
|
||||
echo 'qsize.label qsize'
|
||||
echo 'qsize.info Number of questions waiting for database attention'
|
||||
echo 'qsize.type GAUGE'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
echo "qsize.value $($command qsize_q | awk -F= '{print $2}')"
|
||||
|
53
plugins/network/dns/pdns_queries
Executable file
53
plugins/network/dns/pdns_queries
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor PowerDNS performance
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
command="/etc/init.d/pdns dump"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Power DNS queries'
|
||||
echo 'graph_args -l 0 --base 1000'
|
||||
echo 'graph_vlabel numbers of'
|
||||
echo 'graph_category Power DNS'
|
||||
echo 'graph_info This graph shows Power DNS performance on the machine.'
|
||||
echo 'recursing_answers.label recursing answers'
|
||||
echo 'recursing_answers.type DERIVE'
|
||||
echo 'recursing_answers.min 0'
|
||||
echo 'recursing_answers.info Number of recursive answers sent out'
|
||||
echo 'recursing_questions.label recursing queries'
|
||||
echo 'recursing_questions.type DERIVE'
|
||||
echo 'recursing_questions.min 0'
|
||||
echo 'recursing_questions.info Number of queries sent to recursor'
|
||||
echo 'tcp_answers.label tcp answers'
|
||||
echo 'tcp_answers.type DERIVE'
|
||||
echo 'tcp_answers.min 0'
|
||||
echo 'tcp_answers.info Number of answers sent out over TCP'
|
||||
echo 'tcp_queries.label tcp queries'
|
||||
echo 'tcp_queries.type DERIVE'
|
||||
echo 'tcp_queries.min 0'
|
||||
echo 'tcp_queries.info Number of TCP queries received'
|
||||
echo 'udp_answers.label udp answers'
|
||||
echo 'udp_answers.type DERIVE'
|
||||
echo 'udp_answers.min 0'
|
||||
echo 'udp_answers.info Number of answers sent out over UDP'
|
||||
echo 'udp_queries.label udp queries'
|
||||
echo 'udp_queries.type DERIVE'
|
||||
echo 'udp_queries.min 0'
|
||||
echo 'udp_queries.info Number of UDP queries received'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | grep udp-'\|'recursing'\|'tcp | sed 's/-/_/g'
|
48
plugins/network/dns/pdns_rel
Executable file
48
plugins/network/dns/pdns_rel
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to monitor PowerDNS performance
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
command="/etc/init.d/pdns show"
|
||||
state_file=/var/lib/munin/plugin-state/pdns_rel.state
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Power DNS Packet Cache Performance'
|
||||
echo 'graph_args -l 0 --upper-limit 100 --base 1000'
|
||||
echo 'graph_vlabel %'
|
||||
echo 'graph_category Power DNS'
|
||||
echo 'graph_info This graph shows the Power DNS packet cache performance on the machine.'
|
||||
echo 'packetcache_hitrate.label packet cache hitrate'
|
||||
echo 'packetcache_hitrate.type GAUGE'
|
||||
echo 'packetcache_hitrate.min 0'
|
||||
echo 'packetcache_hitrate.max 100'
|
||||
echo 'packetcache_hitrate.info Hits on the packets cache'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
hits=$($command packetcache-hit | awk -F= '{print $2}')
|
||||
queries=$($command udp-queries | awk -F= '{print $2}')
|
||||
old_hits=$(cat $state_file | head -n1)
|
||||
old_queries=$(cat $state_file | tail -n1)
|
||||
|
||||
if [ -f $state_file ] && [ $(ls -l --time-style=+%s $state_file | awk '{print $6}') -gt $(date --date="7 minutes ago" +%s) ] ; then
|
||||
d_hits=$(($hits - $old_hits))
|
||||
d_queries=$(($queries - $old_queries))
|
||||
if [ $d_queries -gt 0 ] ; then
|
||||
echo packetcache_hitrate.value $(( $d_hits * 100 / $d_queries ))
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $hits > $state_file
|
||||
echo $queries >> $state_file
|
44
plugins/network/hostsdeny
Executable file
44
plugins/network/hostsdeny
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor the number of hosts in /etc/hosts.deny
|
||||
# that are deined access to sshd
|
||||
#
|
||||
# Based on denyhosts plugin by tjansson (2009)
|
||||
#
|
||||
# Copyright (C) 2009 Kåre Hartvig Jensen (kaare.hartvig.jensen@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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -r "$LOG" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Hosts denied sshd access in /etc/hosts.deny'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel Hosts denied '
|
||||
echo 'graph_category system'
|
||||
echo 'HostsDenied.label Hosts denied'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo HostsDenied.value `cat /etc/hosts.deny | grep sshd | wc -l`
|
77
plugins/network/nfsv4
Executable file
77
plugins/network/nfsv4
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin created by Alexandre Dupouy, with the assistance of Mike Fedyk and Richard Dumais
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.9.2.2 2008/03/06 20:00:00 nerux
|
||||
# Modify script for nfsv4
|
||||
#
|
||||
# Revision 1.9.2.1 2005/03/16 13:45:45 ilmari
|
||||
# Fix autoconf for linux/{nfsd,nfs_client}.
|
||||
#
|
||||
# Revision 1.9 2004/12/10 10:47:49 jimmyo
|
||||
# Change name from ${scale} to ${graph_period}, to be more consistent.
|
||||
#
|
||||
# Revision 1.8 2004/12/09 22:12:56 jimmyo
|
||||
# Added "graph_period" option, to make "graph_sums" usable.
|
||||
#
|
||||
# Revision 1.7 2004/11/21 00:17:12 jimmyo
|
||||
# Changed a lot of plugins so they use DERIVE instead of COUNTER.
|
||||
#
|
||||
# Revision 1.6 2004/10/01 12:32:09 ilmari
|
||||
# complete "rpc" removal
|
||||
#
|
||||
# Revision 1.5 2004/10/01 08:40:50 ilmari
|
||||
# Remove useless 'rpc' field, add total field
|
||||
#
|
||||
# Revision 1.4 2004/05/20 19:02:37 jimmyo
|
||||
# Set categories on a bunch of plugins
|
||||
#
|
||||
# Revision 1.3 2004/05/15 21:33:29 jimmyo
|
||||
# "Upped" som plugins from contrib/manual to manual or auto.
|
||||
#
|
||||
# Revision 1.2 2004/05/06 21:55:18 jimmyo
|
||||
# Added patch to contrib-plugin linux/nfsd, to graph rpc count (Alexandre Dupouy).
|
||||
#
|
||||
# Revision 1.1 2004/02/18 18:41:54 jimmyo
|
||||
# Plugin created by Alexandre Dupouy, with the assistance of Mike Fedyk
|
||||
#
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=config
|
||||
|
||||
NFSD=/proc/net/rpc/nfsd
|
||||
|
||||
#proc="getattr setattr lookup access readlink read write create mkdir symlink mknod remove rmdir rename link readdir readdirplus fsstat fsinfo pathconf commit"
|
||||
proc="access close commit create delegpurge delegreturn getattr getfh link lock lockt locku lookup lookup_root nverify open openattr open_conf open_dgrd putfh putpubfh putrootfh read readdir readlink remove rename renew restorefh savefh secinfo setattr setcltid setcltidconf verify write rellockowner"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f "$NFSD" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no $NFSD)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title NFS Server'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel requests / ${graph_period}'
|
||||
echo 'graph_total total'
|
||||
echo 'graph_category NFS'
|
||||
for a in $proc ; do echo "$a.label $a" ; echo "$a.type DERIVE"; echo "$a.min 0"; done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
i=6;
|
||||
|
||||
for a in $proc; do
|
||||
echo -n "$a.value "
|
||||
grep proc4ops $NFSD \
|
||||
| cut -f $i -d ' ' \
|
||||
| awk '{print $1}'
|
||||
i=$(expr $i + 1)
|
||||
done
|
27
plugins/network/quagga_routes
Executable file
27
plugins/network/quagga_routes
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title quagga routes'
|
||||
echo 'graph_args -l 0'
|
||||
echo 'graph_vlabel routes'
|
||||
echo 'graph_category System'
|
||||
echo 'graph_scale no'
|
||||
/usr/local/bin/vtysh -e "sh ip ro sum" | awk '
|
||||
/connected/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/static/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/ebgp/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/ibgp/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/ospf/ {print $1 ".label " $1 "\n" $1 ".draw AREASTACK"}
|
||||
/Totals/ {print $1 ".label " $1 "\n" $1 ".draw LINE1"}
|
||||
'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/local/bin/vtysh -e "sh ip ro sum" | awk '
|
||||
/connected/ {print $1 ".value "$2}
|
||||
/static/ {print $1 ".value "$2}
|
||||
/ebgp/ {print $1 ".value "$2}
|
||||
/ibgp/ {print $1 ".value "$2}
|
||||
/ospf/ {print $1 ".value "$2}
|
||||
/Totals/ {print $1 ".value "$2}
|
||||
'
|
86
plugins/network/sshd_invalid_countries
Executable file
86
plugins/network/sshd_invalid_countries
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
# Plugin to monitor the number of invalid access to sshd per country
|
||||
#
|
||||
# Require read permitions for SYSLOG
|
||||
# ref) ls -l /var/log/secure
|
||||
# Require PEAR library Net_GeoIP
|
||||
# ref) http://pear.php.net/package/Net_GeoIP/redirected
|
||||
# Require GeoIP-database to find out the geolocation from ip or host
|
||||
# ref) http://www.maxmind.com/app/geoip_country
|
||||
#
|
||||
# Parameters:
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2010/12/23 23:55:01 hirata yoshiyuki
|
||||
# released.
|
||||
#
|
||||
# Magick markers (optional):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
# config example for /etc/munin/plugin-conf.d/munin-node
|
||||
#[sshd_invalid_countries]
|
||||
#user root
|
||||
#group root
|
||||
#env.logfile /var/log/secure
|
||||
#env.geoip /home/you/GeoIP.dat
|
||||
#env.peardir /usr/share/pear/
|
||||
|
||||
require (isset($_SERVER['peardir']) && $_SERVER['peardir'] != '' ? $_SERVER['peardir'] : '') . 'Net/GeoIP.php';
|
||||
|
||||
define('SYSLOG', isset($_SERVER['syslog']) && $_SERVER['syslog'] != '' ? $_SERVER['syslog'] : '/var/log/secure');
|
||||
define('GEOIP_DB', isset($_SERVER['geoip']) && $_SERVER['geoip'] != '' ? $_SERVER['geoip'] : 'GeoIP.dat');
|
||||
define('AWK_CMD', 'awk \'/sshd\[.*Did not receive identification string/{print $12} ' .
|
||||
'/sshd\[.*Failed password for (root|ROOT)/{print $11} ' .
|
||||
'/sshd\[.*Invalid user/{print $10}a\' < ' . SYSLOG);
|
||||
|
||||
if (isset($argv[1]) && $argv[1] == 'autoconf') {
|
||||
$fh = @fopen(SYSLOG, 'r');
|
||||
if ($fh) {
|
||||
echo "yes\n";
|
||||
fclose($fh);
|
||||
exit(0);
|
||||
} else {
|
||||
echo "no\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (isset($argv[1]) && $argv[1] == 'config') {
|
||||
echo 'graph_title SSHD invalid countries from ' . SYSLOG . "\n";
|
||||
echo 'graph_args --base 1000 -l 0' . "\n";
|
||||
echo 'graph_vlabel number of invalid access per country' . "\n";
|
||||
echo 'graph_category system' . "\n";
|
||||
echo 'graph_info This graph shows the countries of invalid access to sshd.' . "\n";
|
||||
foreach (get_sshd_invalid_countries() as $country => $cnt) {
|
||||
echo $country . '.label ' . $country . "\n";
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
foreach (get_sshd_invalid_countries() as $country => $cnt) {
|
||||
echo $country . '.value ' . $cnt . "\n";
|
||||
}
|
||||
|
||||
function get_sshd_invalid_countries() {
|
||||
$countries = array();
|
||||
exec(AWK_CMD, $wholeips, $ret);
|
||||
|
||||
if ($ret != 0) return $countries;
|
||||
|
||||
$uniqueips = array_count_values($wholeips);
|
||||
$GeoIP = Net_GeoIP::getInstance(GEOIP_DB);
|
||||
foreach ($uniqueips as $ip => $cnt) {
|
||||
try {
|
||||
$country = $GeoIP->lookupCountryName($ip);
|
||||
$countries[$country] = isset($countries[$country]) ? $countries[$country] + $cnt : $cnt;
|
||||
} catch (Exception $e) {
|
||||
$countries['Unknown'] = isset($countries['Unknown']) ? $countries['Unknown'] + $cnt : $cnt;
|
||||
}
|
||||
}
|
||||
ksort($countries);
|
||||
|
||||
return $countries;
|
||||
}
|
80
plugins/network/sshd_invalid_countries_ruby
Executable file
80
plugins/network/sshd_invalid_countries_ruby
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/usr/local/bin/ruby
|
||||
# Plugin to monitor the number of invalid access to sshd per country
|
||||
#
|
||||
# Require read permitions for SYSLOG
|
||||
# ref) ls -l /var/log/secure
|
||||
# Require geoip rubygem
|
||||
# ref) http://geoip.rubyforge.org/
|
||||
# Require GeoIP-database for searching ip or host for the country
|
||||
# ref) http://www.maxmind.com/app/geoip_country
|
||||
#
|
||||
# Parameters:
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2010/12/25 11:56:12 hirata yoshiyuki
|
||||
# released.
|
||||
#
|
||||
# Magick markers (optional):
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
# config example for /etc/munin/plugin-conf.d/munin-node
|
||||
#[sshd_invalid_countries_ruby]
|
||||
#user root
|
||||
#group root
|
||||
#env.logfile /var/log/secure
|
||||
#env.geoip /home/you/GeoIP.dat
|
||||
#env.loadpath /usr/local/lib/ruby/gems/1.9.1/gems/geoip-0.8.8/lib/
|
||||
|
||||
require (ENV['loadpath'] || '') + 'geoip'
|
||||
|
||||
SYSLOG = ENV['syslog'] || '/var/log/secure'
|
||||
GEOIP_DB = ENV['geoip'] || '/var/www/conf/bbs/GeoIP.dat'
|
||||
AWK_CMD = 'awk \'/sshd\[.*Did not receive identification string/{print $12} ' +
|
||||
'/sshd\[.*Failed password for (root|ROOT)/{print $11} ' +
|
||||
'/sshd\[.*Invalid user/{print $10}a\' < ' + SYSLOG
|
||||
|
||||
def getInvalids
|
||||
c={}
|
||||
wholeips = `#{AWK_CMD}`.split("\n")
|
||||
uniqueips = wholeips.inject({}) do |hash, key|
|
||||
hash.include?(key) ? hash[key] += 1 : hash[key] = 1;
|
||||
hash
|
||||
end
|
||||
geoip = GeoIP.new(GEOIP_DB)
|
||||
uniqueips.each do |ip,cnt|
|
||||
begin
|
||||
country = geoip.country(ip)[5]
|
||||
c[country] = c[country] ? c[country] + cnt : cnt
|
||||
rescue
|
||||
c['Unknown'] = c['Unknown'] ? c['Unknown'] + cnt : cnt
|
||||
end
|
||||
end
|
||||
c = c.to_a.sort {|a,b| a[0] <=> b[0]}
|
||||
c
|
||||
end
|
||||
|
||||
case ARGV[0]
|
||||
when 'autoconf'
|
||||
begin
|
||||
fh = open(SYSLOG, 'r')
|
||||
rescue
|
||||
puts 'no'
|
||||
exit 1
|
||||
else
|
||||
puts 'yes'
|
||||
exit 0
|
||||
end
|
||||
when 'config'
|
||||
puts 'graph_title SSHD invalid countries from ' + SYSLOG
|
||||
puts 'graph_args --base 1000 -l 0'
|
||||
puts 'graph_vlabel number of invalid access per country'
|
||||
puts 'graph_category system'
|
||||
puts 'graph_info This graph shows the countries of invalid access to sshd.'
|
||||
getInvalids.each {|k,v| puts k + '.label ' + k}
|
||||
exit 0
|
||||
else
|
||||
getInvalids.each {|k,v| puts k + '.value ' + v.to_s}
|
||||
end
|
119
plugins/network/tor/tor-connections
Executable file
119
plugins/network/tor/tor-connections
Executable file
|
@ -0,0 +1,119 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
$cookiepath = "/etc/tor/control_auth_cookie";
|
||||
$controlport = 9051;
|
||||
|
||||
|
||||
// Nothing to change down here...
|
||||
|
||||
$cmd = $argv['1'];
|
||||
|
||||
$cookie = file_get_contents($cookiepath);
|
||||
|
||||
|
||||
if ($cmd == "config") {
|
||||
|
||||
print "graph_title Connections\n";
|
||||
print "graph_args -l 0 --base 1000\n";
|
||||
print "graph_vlabel connections\n";
|
||||
print "graph_category Tor\n";
|
||||
print "graph_info This graph shows the number of Tor OR connections.\n";
|
||||
print "graph_period second\n";
|
||||
|
||||
print "new.label new\n";
|
||||
print "new.type GAUGE\n";
|
||||
print "new.max 50000\n";
|
||||
print "new.min 0\n";
|
||||
|
||||
print "launched.label launched\n";
|
||||
print "launched.type GAUGE\n";
|
||||
print "launched.max 50000\n";
|
||||
print "launched.min 0\n";
|
||||
|
||||
print "connected.label connected\n";
|
||||
print "connected.type GAUGE\n";
|
||||
print "connected.max 50000\n";
|
||||
print "connected.min 0\n";
|
||||
|
||||
print "failed.label failed\n";
|
||||
print "failed.type GAUGE\n";
|
||||
print "failed.max 50000\n";
|
||||
print "failed.min 0\n";
|
||||
|
||||
print "closed.label closed\n";
|
||||
print "closed.type GAUGE\n";
|
||||
print "closed.max 50000\n";
|
||||
print "closed.min 0\n";
|
||||
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
} elseif ($cmd == "autoconf") {
|
||||
|
||||
$socket = fsockopen("tcp://127.0.0.1", $controlport);
|
||||
fputs($socket, "AUTHENTICATE \"".$cookie."\"\n");
|
||||
|
||||
$buffer = fgets($socket, 1024);
|
||||
if (ereg("250", $buffer)) echo "Yes";
|
||||
else echo "No (".trim($buffer).")";
|
||||
|
||||
fclose($socket);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$socket = fsockopen("tcp://127.0.0.1", $controlport);
|
||||
|
||||
fputs($socket, "AUTHENTICATE \"".$cookie."\"\n");
|
||||
|
||||
$buffer .= fgets($socket, 4096);
|
||||
|
||||
if (!ereg("250", $buffer)) {
|
||||
echo "Unable to connect to Tor ControlPort (".$buffer.")";
|
||||
fclose($socket);
|
||||
exit;
|
||||
} else {
|
||||
|
||||
$buffer = fputs($socket, "GETINFO orconn-status\n");
|
||||
|
||||
$buffer = fgets($socket, 1024);
|
||||
$buffer = fgets($socket, 1024);
|
||||
|
||||
while (strlen($buffer) > 3) {
|
||||
|
||||
$bits = explode(" ", $buffer);
|
||||
|
||||
$connections[trim($bits['1'])]++;
|
||||
|
||||
$buffer = fgets($socket, 1024);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!empty($connections['NEW'])) echo "new.value ".$connections['NEW']."\n";
|
||||
else echo "new.value 0\n";
|
||||
|
||||
if (!empty($connections['LAUNCHED'])) echo "launched.value ".$connections['LAUNCHED']."\n";
|
||||
else echo "launched.value 0\n";
|
||||
|
||||
if (!empty($connections['CONNECTED'])) echo "connected.value ".$connections['CONNECTED']."\n";
|
||||
else echo "connected.value 0\n";
|
||||
|
||||
if (!empty($connections['FAILED'])) echo "failed.value ".$connections['FAILED']."\n";
|
||||
else echo "failed.value 0\n";
|
||||
|
||||
if (!empty($connections['CLOSED'])) echo "closed.value ".$connections['CLOSED']."\n";
|
||||
else echo "closed.value 0\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
fclose($socket);
|
||||
|
||||
?>
|
||||
|
76
plugins/network/tor/tor-traffic
Executable file
76
plugins/network/tor/tor-traffic
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
$cookiepath = "/etc/tor/control_auth_cookie";
|
||||
$controlport = 9051;
|
||||
|
||||
|
||||
// Nothing to change down here...
|
||||
|
||||
$cmd = $argv['1'];
|
||||
|
||||
$cookie = file_get_contents($cookiepath);
|
||||
|
||||
|
||||
if ($cmd == "config") {
|
||||
|
||||
echo "graph_title Traffic\n";
|
||||
echo "graph_args --base 1000 \n";
|
||||
echo "graph_vlabel bits in (-) / out (+) per ${graph_period}\n";
|
||||
echo "graph_category Tor\n";
|
||||
|
||||
echo "down.label Download\n";
|
||||
echo "down.type GAUGE\n";
|
||||
|
||||
echo "up.label Upload\n";
|
||||
echo "up.type GAUGE\n";
|
||||
|
||||
exit;
|
||||
|
||||
} elseif ($cmd == "autoconf") {
|
||||
|
||||
$socket = fsockopen("tcp://127.0.0.1", $controlport);
|
||||
fputs($socket, "AUTHENTICATE \"".$cookie."\"\n");
|
||||
|
||||
$buffer = fgets($socket, 1024);
|
||||
if (ereg("250", $buffer)) echo "Yes";
|
||||
else echo "No (".trim($buffer).")";
|
||||
|
||||
fclose($socket);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$socket = fsockopen("tcp://127.0.0.1", $controlport);
|
||||
|
||||
fputs($socket, "AUTHENTICATE \"".$cookie."\"\n");
|
||||
|
||||
$buffer .= fgets($socket, 4096);
|
||||
|
||||
if (!ereg("250", $buffer)) {
|
||||
echo "Unable to connect to Tor ControlPort (".$buffer.")";
|
||||
fclose($socket);
|
||||
exit;
|
||||
} else {
|
||||
|
||||
fputs($socket, "SETEVENTS bw\n");
|
||||
|
||||
$buffer = fgets($socket, 1024);
|
||||
|
||||
$buffer = fgets($socket, 1024);
|
||||
|
||||
$bits = explode(" ", $buffer);
|
||||
|
||||
echo "down.value ".($bits['2'] / 1024)."\n";
|
||||
|
||||
echo "up.value ".($bits['3'] / 1024)."\n";
|
||||
|
||||
}
|
||||
|
||||
fclose($socket);
|
||||
|
||||
?>
|
||||
|
151
plugins/network/tor/tor_routers
Executable file
151
plugins/network/tor/tor_routers
Executable file
|
@ -0,0 +1,151 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Munin plugin to monitor Tor routers
|
||||
#
|
||||
# Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>, based on a plugin by Ge van Geldorp <ge@gse.nl>
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# host - Change which host to graph (default localhost)
|
||||
# port - Change which port to connect to (default 9051)
|
||||
# password - Plain-text control channel password (see torrc
|
||||
# HashedControlPassword parameter)
|
||||
# cookiefile - Name of the file containing the control channel cookie
|
||||
# (see torrc CookieAuthentication parameter)
|
||||
#
|
||||
# Using HashedControlPassword authentication has the problem that you must
|
||||
# include the plain-text password in the munin config file. To have any
|
||||
# effect, that file shouldn't be world-readable.
|
||||
# If you're using CookieAuthentication, you should run this plugin as a user
|
||||
# which has read access to the tor datafiles. Also note that bugs in versions
|
||||
# upto and including 0.1.1.20 prevent CookieAuthentication from working.
|
||||
#
|
||||
# Usage: place in /etc/munin/node.d/ (or link it there using ln -s)
|
||||
#
|
||||
# Parameters understood:
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#
|
||||
# Magic markers - optional - used by installation scripts and
|
||||
# munin-config:
|
||||
#
|
||||
#%# family=contrib
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
use IO::Socket::INET;
|
||||
|
||||
# Config
|
||||
our $address = $ENV{host} || "localhost"; # Default: localhost
|
||||
our $port = $ENV{port} || 9051; # Default: 9051
|
||||
|
||||
# Don't edit below this line
|
||||
|
||||
sub Authenticate
|
||||
{
|
||||
my ($socket) = @_;
|
||||
my $authline = "AUTHENTICATE";
|
||||
if (defined($ENV{cookiefile})) {
|
||||
if (open(COOKIE, "<$ENV{cookiefile}")) {
|
||||
binmode COOKIE;
|
||||
my $cookie;
|
||||
$authline .= " ";
|
||||
while (read(COOKIE, $cookie, 32)) {
|
||||
foreach my $byte (unpack "C*", $cookie) {
|
||||
$authline .= sprintf "%02x", $byte;
|
||||
}
|
||||
}
|
||||
close COOKIE;
|
||||
}
|
||||
} elsif (defined($ENV{password})) {
|
||||
$authline .= ' "' . $ENV{password} . '"';
|
||||
}
|
||||
print $socket "$authline\r\n";
|
||||
my $replyline = <$socket>;
|
||||
if (substr($replyline, 0, 1) != '2') {
|
||||
$replyline =~ s/\s*$//;
|
||||
return "Failed to authenticate: $replyline";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
|
||||
# Try to connect to the daemon
|
||||
my $socket = IO::Socket::INET->new("$address:$port")
|
||||
or my $failed = 1;
|
||||
|
||||
if ($failed) {
|
||||
print "no (failed to connect to $address port $port)\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $msg = Authenticate($socket);
|
||||
if (defined($msg)) {
|
||||
print $socket "QUIT\r\n";
|
||||
close($socket);
|
||||
print "no ($msg)\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
print $socket "QUIT\r\n";
|
||||
close($socket);
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($ARGV[0] and $ARGV[0] eq "config") {
|
||||
print "graph_title Routers\n";
|
||||
print "graph_args -l 0\n";
|
||||
print "graph_vlabel routers\n";
|
||||
print "graph_category Tor\n";
|
||||
print "graph_info This graph shows the number of known Tor ORs.\n";
|
||||
|
||||
print "ors.label routers\n";
|
||||
print "ors.type GAUGE\n";
|
||||
print "ors.info The number of known Tor ORs (onion routers)\n";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $socket = IO::Socket::INET->new("$address:$port")
|
||||
or die("Couldn't connect to $address port $port: $!");
|
||||
|
||||
my $msg = Authenticate($socket);
|
||||
if (defined($msg)) {
|
||||
print $socket "QUIT\r\n";
|
||||
close($socket);
|
||||
die "$msg\n";
|
||||
}
|
||||
|
||||
print $socket "GETINFO ns/all\r\n";
|
||||
my $replyline = <$socket>;
|
||||
if (substr($replyline, 0, 1) != '2') {
|
||||
print $socket "QUIT\r\n";
|
||||
close($socket);
|
||||
$replyline =~ s/\s*$//;
|
||||
die "Failed to get orconn-status info: $replyline\n";
|
||||
}
|
||||
|
||||
my $count;
|
||||
while (! (($replyline = <$socket>) =~ /^\.\s*$/)) {
|
||||
my @reply = split(/\s+/, $replyline);
|
||||
$count++ if $reply[0] eq 'r';
|
||||
}
|
||||
$replyline = <$socket>;
|
||||
if (substr($replyline, 0, 1) != '2') {
|
||||
print $socket "QUIT\r\n";
|
||||
close($socket);
|
||||
$replyline =~ s/\s*$//;
|
||||
die "Failed to authenticate: $replyline\n";
|
||||
}
|
||||
|
||||
print $socket "QUIT\r\n";
|
||||
close($socket);
|
||||
|
||||
print "ors.value $count\n";
|
||||
|
||||
exit 0;
|
||||
|
||||
# vim:syntax=perl
|
Loading…
Add table
Add a link
Reference in a new issue