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

openvpn as plugins

This commit is contained in:
rfrail3 2012-10-09 10:59:38 +02:00
parent d189784ce2
commit 8410e921e1
4 changed files with 342 additions and 0 deletions

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 OpenVPN'
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 -eq 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))"

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 OpenVPN'
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"

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 OpenVPN'
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

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 OpenVPN'
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"