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

92 lines
2.4 KiB
Plaintext
Raw Normal View History

2007-01-17 16:16:12 +01:00
#!/usr/bin/perl
#
# Copyright (C) 2005-2007 Rodolphe Quiedeville <rodolphe@quiedeville.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.
#
# If you improve this script please send your version to my email address
# with the copyright notice upgrade with your name.
#
# Munin's plugin to monitor number of clients connected to openvpn server
#
# Usage: copy or link into /etc/munin/plugins
#
# Parameters:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# $Log$
# Revision 1.2 2007/01/17 15:57:19 rodo
# Correct family
#
# Revision 1.1 2005/10/11 14:12:19 Rodolphe Quiedeville
#
# Magic markers (optinal - used by munin-config and some installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf
use strict;
my $statuslogfile = "/etc/openvpn/openvpn-status.log";
my $clients = 0;
if($ARGV[0] and $ARGV[0] eq "autoconf" ) {
if(-f $statuslogfile) {
if(-r $statuslogfile) {
print "yes\n";
exit 0;
} else {
print "no (logfile not readable)\n";
}
} else {
print "no (logfile not found)\n";
}
exit 1;
}
if ($ARGV[0] and $ARGV[0] eq "config" ){
print "graph_title OpenVpn\n";
print "graph_args --base 1000 -l 0\n";
print "graph_scale yes\n";
print "graph_vlabel clients\n";
print "graph_category network\n";
print "graph_info This graph shows the numbers of clients connected to openvpn server.\n";
print "clients.label clients\n";
print "clients.info The number of clients connected to openvpn server\n";
exit 0;
}
if (-f "$statuslogfile") {
open(IN, "$statuslogfile") or exit 4;
my $flagu = 0;
while(<IN>) {
if(/^ROUTING TABLE$/) {
$flagu = 0;
}
if ($flagu) {
$clients = $clients + 1;
}
if(/^Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since$/) {
$flagu = 1;
}
}
close(IN);
}
print "clients.value " . $clients."\n";