/usr/share/munin/plugins/openvpn is in munin-plugins-extra 2.0.19-3ubuntu0.3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #!/usr/bin/perl
# -*- perl -*-
=head1 NAME
openvpn - Plugin to monitor number of users connected to openvpn server
=head1 USAGE
To use this plugin, add the following text to your openvpn server
configuration file:
status /var/log/openvpn.status
status-version 1
If you change the path to the status file, remember to change
env.statusfile in the plugin configuration to match the new path.
=head1 CONFIGURATION
This script uses the following configuration variables
[openvpn]
env.statusfile <path to status log file>
=head2 DEFAULT CONFIGURATION
The default configuration is
[openvpn]
env.statusfile /var/log/openvpn.status
=head1 AUTHOR
Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
=head1 LICENSE
Gnu GPLv2
=begin comment
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
If you improve this script please send your version to my email address
with the copyright notice upgrade with your name.
=end comment
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=autoconf
=cut
use strict;
my $statuslogfile = $ENV{'statusfile'} || '/var/log/openvpn.status';
my $users = 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 0;
}
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 users\n";
print "graph_category network\n";
print "graph_info This graph shows the numbers of users connected to openvpn server.\n";
print "users.label users\n";
print "users.info The number of users 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) {
$users = $users + 1;
}
if(/^Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since$/) {
$flagu = 1;
}
}
close(IN);
}
print "users.value " . $users."\n";
|