1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

Plugin-Gallery: Better 2nd level headings

This commit is contained in:
dipohl 2017-02-24 03:13:08 +01:00
parent 3a6fdce80f
commit ae4e85ab60
13 changed files with 11 additions and 13 deletions

44
plugins/vpn/dar_vpnd Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/env perl
# -*- perl -*-
=head1 NAME
dar_vpnd a Plugin for displaying VPN Stats for the Darwin (MacOS) vpnd Service.
=head1 INTERPRETATION
The Plugin displays the number of active VPN connections.
=head1 CONFIGURATION
No Configuration necessary!
=head1 AUTHOR
Philipp Haussleiter <philipp@haussleiter.de> (email)
=head1 LICENSE
GPLv2
=cut
# MAIN
use warnings;
use strict;
my $cmd = "ps -ef | awk '/[p]ppd/ {print substr(\$NF,2);}' | wc -l";
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_category network\n";
print "graph_args --base 1024 -r --lower-limit 0\n";
print "graph_title Number of VPN Connections\n";
print "graph_vlabel VPN Connections\n";
print "graph_info The Graph shows the Number of VPN Connections\n";
print "connections.label Number of VPN Connections\n";
print "connections.type GAUGE\n";
} else {
my $output = `$cmd`;
print "connections.value $output";
}

82
plugins/vpn/openvpn_as_mtime Executable file
View file

@ -0,0 +1,82 @@
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
openvpn_as_time -Indicate the medium time of the logged users.
=head1 CONFIGURATION
Require jsonpipe software:
https://github.com/dvxhouse/jsonpipe
[openvpn_*]
user root
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
SUM=0
NOW=`date +%s`
# Script folder
D_BIN="/usr/local/openvpn_as/scripts"
# List with users time
LIST1=`$D_BIN/sacli VPNStatus | tr '/' - | jsonpipe | grep "/openvpn_[0-9]/client_list/[0-9]/6" | tr -d '"' | awk '{print $2} '`
# Count users listed
TOTU=`$D_BIN/sacli VPNStatus | tr '/' - | jsonpipe | grep "/openvpn_[0-9]/client_list/[0-9]/6" | tr -d '"' | awk '{print $2} ' | wc -l`
if [ "$1" = "config" ]; then
echo 'graph_title OpenVPN Users medium time'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Time in minutes'
echo 'graph_scale no'
echo 'graph_category network'
echo 'graph_info Indicate the medium time of the logged users.'
echo "time.label Users"
echo "time.type GAUGE"
echo "time.min 0"
exit 0
fi
# Sum all times (times are the time request minus epoch date at now)
for i in $LIST1; do
SUM=`expr $SUM + $((NOW - $i))`
done
# If TOTU is 0, change to 1 for avoid problem in the division
if [ "$TOTU" = "0" ]; then
TOTU=1
fi
# Total is total time between number of users between 60 for give it in minutes
echo "time.value $(($(($SUM / $TOTU)) / 60))"

89
plugins/vpn/openvpn_as_traffic Executable file
View file

@ -0,0 +1,89 @@
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
openvpn_as_traffic -OpenVPN traffic
=head1 CONFIGURATION
Require jsonpipe software:
https://github.com/dvxhouse/jsonpipe
[openvpn_as*]
user root
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
# Script folder
D_BIN="/usr/local/openvpn_as/scripts"
SUM1=0
SUM2=0
NOW=`date +%s`
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title OpenVPN traffic"
echo 'graph_args --base 1000'
echo 'graph_vlabel Bytes in (-) / out (+)'
echo 'graph_category network'
echo "graph_info OpenVPN traffic"
echo "down.label Bytes"
echo "down.type DERIVE"
echo "down.graph no"
echo "down.cdef down,8,*"
echo "down.min 0"
echo "up.label Bytes"
echo "up.type DERIVE"
echo "up.negative down"
echo "up.cdef up,8,*"
echo "up.info Bytes"
echo "up.min 0"
exit 0
fi
# List users values, bytes sent
LIST1=`$D_BIN/sacli VPNStatus | tr '/' - | jsonpipe | grep "/openvpn_[0-9]/client_list/[0-9]/4" | tr -d '"' | awk '{print $2} '`
# Sum list
for i in $LIST1; do
SUM1=`expr $SUM1 + $i`
done
# List users values, bytes received
LIST2=`$D_BIN/sacli VPNStatus | tr '/' - | jsonpipe | grep "/openvpn_[0-9]/client_list/[0-9]/3" | tr -d '"' | awk '{print $2} '`
# Sum list
for i in $LIST2; do
SUM2=`expr $SUM2 + $i`
done
echo "down.value $SUM1"
echo "up.value $SUM2"

91
plugins/vpn/openvpn_as_ttime Executable file
View file

@ -0,0 +1,91 @@
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
openvpn_as_time -Indicate user logged time.
=head1 CONFIGURATION
Require jsonpipe software:
https://github.com/dvxhouse/jsonpipe
[openvpn_*]
user root
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
SUM=0
COUNT=1
NOW=`date +%s`
# Script folder
D_BIN="/usr/local/openvpn_as/scripts"
# List with users time
LIST1=`$D_BIN/sacli VPNStatus | tr '/' - | jsonpipe | grep "/openvpn_[0-9]/client_list/[0-9]/6" | tr -d '"' | awk '{print $2} '`
# List with users names
LIST2=`$D_BIN/sacli VPNStatus | tr '/' - | jsonpipe | grep "/openvpn_[0-9]/client_list/[0-9]/0" | tr -d '"' | awk '{print $2} '`
if [ "$1" = "config" ]; then
echo 'graph_title OpenVPN User logged time'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Time in minutes'
echo 'graph_scale no'
echo 'graph_category network'
echo 'graph_info Indicate the user logged time.'
# If none, print 0
if [ -z $LIST1 ]; then
LIST1=$NOW
LIST2="none"
fi
for i in $LIST1; do
NAME=`echo $LIST2 | cut -d " " -f $COUNT`
echo "$NAME.label User $NAME"
echo "$NAME.type GAUGE"
echo "$NAME.min 0"
COUNT=$((COUNT + 1))
done
exit 0
fi
# If none, print 0
if [ -z $LIST1 ]; then
LIST1=$NOW
LIST2="none"
fi
# Print values
for i in $LIST1; do
NAME=`echo $LIST2 | cut -d " " -f $COUNT`
echo "$NAME.value $(($((NOW - $i)) / 60))"
COUNT=$((COUNT + 1))
done

80
plugins/vpn/openvpn_as_users Executable file
View file

@ -0,0 +1,80 @@
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
openvpn_as_users -Indicate the number of users and the license limit
=head1 CONFIGURATION
[openvpn_*]
user root
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
# Script folder
D_BIN="/usr/local/openvpn_as/scripts"
# Number of clients
VAL1=`$D_BIN/sacli VPNSummary | grep clients | awk '{print $2}'`
# Limit of clients by license
VAL2=`$D_BIN/liman info | grep -o "[0-9]*"`
# Warn value
WARN=80
if [ "$1" = "config" ]; then
echo 'graph_title OpenVPN Users'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Users'
echo 'graph_scale no'
echo 'graph_category network'
echo 'graph_info Indicate the number of vpn users and the license limit.'
echo "users.label Users"
echo "users.type GAUGE"
echo "users.draw AREA"
echo "users.min 0"
echo "users.warning $((VAL2 * $WARN / 100))"
echo "users.critical $VAL2"
echo "limit.label Limit"
echo "limit.type GAUGE"
echo "limit.min 0"
exit 0
fi
echo "users.value $VAL1"
echo "limit.value $VAL2"

180
plugins/vpn/openvpn_multi Executable file
View file

@ -0,0 +1,180 @@
#!/usr/bin/perl -w
=head1 NAME
openvpn_multi - Plugin for monitoring OpenVPN users traffic
=head1 CONFIGURATION
[openvpn_multi]
user root
env.statusfile /var/log/openvpn.status
=head1 AUTHOR
Copyright 2013 Pierre Schweitzer <pierre@reactos.org>
=head1 LICENSE
GNU GPL v2 or any later version
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
use strict;
use Munin::Common::Defaults;
use Munin::Plugin;
my $statusfile = ($ENV{'statusfile'} || '/var/log/openvpn.status');
sub config {
open FILE, $statusfile or die $!;
print "multigraph openvpn_users\n";
print "graph_title OpenVPN traffic\n";
print "graph_args --base 1024 --lower-limit 0\n";
print "graph_vlabel Bytes Out (-) / In (+) per \${graph_period}\n";
print "graph_category network\n";
print "in.label recv\n";
print "in.type DERIVE\n";
print "in.min 0\n";
print "in.graph no\n";
print "in.cdef in,1,*\n";
print "out.label Bps\n";
print "out.type DERIVE\n";
print "out.min 0\n";
print "out.negative in\n";
print "out.cdef out,1,*\n";
while (<FILE>) {
next if ($_ =~ /CLIENT LIST/ || $_ =~ /Updated/ || $_ =~ /Common Name/);
last if ($_ =~ /ROUTING TABLE/);
# client,IP:port,in,out,D M N hour Y
my @values = split(',', $_);
my $name = $values[0];
my $fieldname = clean_fieldname($name);
print "multigraph openvpn_users.$fieldname\n";
print "graph_title OpenVPN traffic for $name\n";
print "graph_args --base 1024 --lower-limit 0\n";
print "graph_vlabel Bytes Out (-) / In (+) per \${graph_period}\n";
print "graph_category network\n";
print "in.label recv\n";
print "in.type DERIVE\n";
print "in.min 0\n";
print "in.graph no\n";
print "in.cdef in,1,*\n";
print "out.label Bps\n";
print "out.type DERIVE\n";
print "out.min 0\n";
print "out.negative in\n";
print "out.cdef out,1,*\n";
}
close FILE;
exit 0;
}
sub autoconf {
if (-e $statusfile) {
print "yes\n";
exit 0;
} else {
print "no\n";
exit 1;
}
}
sub report {
my %in;
my %out;
my $tot_in = 0;
my $tot_out = 0;
my %previous_state = restore_state();
my %new_state;
open FILE, $statusfile or die $!;
while (<FILE>) {
next if ($_ =~ /CLIENT LIST/ || $_ =~ /Updated/ || $_ =~ /Common Name/);
last if ($_ =~ /ROUTING TABLE/);
# client,IP:port,in,out,D M N hour Y
my @values = split(',', $_);
my $name = $values[0];
my $in = 0;
my $out = 0;
if (exists $previous_state{$name."_in"} && exists $previous_state{$name."_out"}) {
my $old_in = $previous_state{$name."_in"};
my $old_out = $previous_state{$name."_out"};
if ($old_in <= $values[2] && $old_out <= $values[3]) {
$in = $values[2] - $old_in;
$out = $values[3] - $old_out;
}
}
$in{$name} = $in;
$out{$name} = $out;
$tot_in += $in;
$tot_out += $out;
$new_state{$name."_in"} = $values[2];
$new_state{$name."_out"} = $values[3];
}
close FILE;
print "multigraph openvpn_users\n";
if (exists $previous_state{"total.in"} && exists $previous_state{"total.out"}) {
my $old_tot_in = $previous_state{"total.in"};
my $old_tot_out = $previous_state{"total.out"};
if ($old_tot_in <= $tot_in && $old_tot_out <= $tot_out) {
print "in.value $tot_in\n";
print "out.value $tot_out\n";
} else {
print "in.value 0\n";
print "out.value 0\n";
}
} else {
print "in.value 0\n";
print "out.value 0\n";
}
$new_state{"total.in"} = $tot_in;
$new_state{"total.out"} = $tot_out;
save_state(%new_state);
for my $name (keys %in) {
my $in = $in{$name};
my $out = $out{$name};
my $fieldname = clean_fieldname($name);
print "multigraph openvpn_users.$fieldname\n";
print "in.value $in\n";
print "out.value $out\n";
}
exit 0;
}
if ($ARGV[0]) {
my $arg = $ARGV[0];
my %funcs = (
config => \&config,
autoconf => \&autoconf,
);
if (exists $funcs{$arg}) {
$funcs{$arg}->();
} else {
die "Unknown argument '$arg'\n";
}
} else {
report();
}