1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 02:18:08 +00:00

move singleton plugins to the network directory

This commit is contained in:
Kenyon Ralph 2012-02-29 15:44:07 -08:00
parent 992d1c8d5c
commit d055f33780
2 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,52 @@
#!/usr/bin/perl
use strict;
my $magic = `echo -e "show name;message\nprint type: nsr device" |nsradmin -i -`;
# name: /dev/nst0;
# message: "writing at 57 MB/s, 4063 GB";
#
# name: /dev/nst1;
# message: "reading, data ";
my %hash = ();
while ($magic =~ m! name: (\S+?);\s+message: "(.+?)";!sg) {
my ($dev,$mess) = ($1,$2);
$hash{$dev} ||= {};
$mess =~ m!writing at (\d+) (.?B)/s!;
if ($2 eq 'B') {
$hash{$dev}->{writing} = $1+0;
}
elsif ($2 eq 'KB') {
$hash{$dev}->{writing} = $1*1024;
}
elsif ($2 eq 'MB') {
$hash{$dev}->{writing} = $1*1024*1024;
}
elsif ($2 eq 'GB') {
$hash{$dev}->{writing} = $1*1024*1024*1024;
}
}
if ($ARGV[0] eq "config") {
print <<_EOM;
graph_title NSR Device write speed (bytes/s)
graph_args -l 0 --base 1000
graph_vlabel bytes/s
graph_category Networker
graph_info Shows how much writing each device is doing.
_EOM
foreach my $d (sort keys %hash) {
my ($l) = ($d =~ m!([A-Za-z0-9]+)$!);
print "$l.label $d\n"
# print $l.warning ??\n";
# print "$l.critical ??\n";
}
}
else {
foreach my $d (sort keys %hash) {
my ($l) = ($d =~ m!([A-Za-z0-9]+)$!);
print "$l.value ".$hash{$d}->{writing}."\n";
}
}

89
plugins/network/openvpn_multi Executable file
View file

@ -0,0 +1,89 @@
#!/bin/sh
#
# Plugin Configuration
# [openvpn_multi]
# user root
# env.statusfile /var/log/openvpn.status
# env.userlist user1 user2 ...
#
#
# No error handling/mapping for ${userlist} => ${statusfile}
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf suggest
if [ "$1" = "autoconf" ]; then
if [ -f ${statusfile} ]; then
echo yes
exit 0
else
echo "no (${statusfile} not found)"
exit 1
fi
fi
if [ "$1" = "suggest" ]; then
echo "Configure a status file..."
exit 0
fi
FieldAttrib () {
echo "${USER}_in.label ${USER} Received"
echo "${USER}_in.type DERIVE"
echo "${USER}_in.min 0"
echo "${USER}_in.graph no"
echo "${USER}_in.cdef ${USER}_in,1,*"
echo "${USER}_out.label ${USER} Bps"
echo "${USER}_out.type DERIVE"
echo "${USER}_out.min 0"
echo "${USER}_out.negative ${USER}_in"
echo "${USER}_out.cdef ${USER}_out,1,*"
}
GetValues () {
if grep -q ^$USER $statusfile; then
awk -F , '/^'"$USER"'/ {print $1"_in.value "$3 "\n"$1"_out.value "$4}' $statusfile
else
echo "${USER}_in.value -1"
echo "${USER}_out.value -1"
fi
}
# Setup config
if [ "$1" = "config" ]; then
echo "graph_title Root Graph of Openvpn Traffic by CN"
echo "graph_args --base 1024 --lower-limit 0"
echo "graph_vlabel Bytes Out (-) / In (+) per \${graph_period}"
echo "graph_category openvpn"
echo "graph_info This graph shows the bandwidth usage in Bytes/s. It prepulates the graph lines from a list of user CN's in the plugin conf file, this must correlate with the values in the ${statusfile} log file."
for USER in $userlist
do
FieldAttrib
done
for USER in $userlist
do
echo "multigraph openvpn_multi.${USER}"
echo "graph_title ${USER} sub-graph"
echo "graph_category openvpn"
echo "graph_info This graph shows the bandwidth usage in bytes/s. It prepulates the graph lines from a list of user CN's in the plugin conf file, this must correlate with the values in the ${statusfile} log file."
FieldAttrib
done
exit 0
fi;
# Get .values for root graph
for USER in $userlist
do
GetValues
done
# Get .values for sub-graphs
for USER in $userlist
do
echo "multigraph openvpn_multi.${USER}"
GetValues
done