From a5984dd49ac512f05c522279861ca5b87c5be4a4 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Mon, 5 Jan 2015 16:10:14 -0500 Subject: fix path to custom init.pp add custom openvpn module to group graphs --- files/puppet/modules/custom/init.pp | 14 --- files/puppet/modules/custom/manifests/init.pp | 14 +++ .../puppet/modules/custom_munin_node/files/openvpn | 118 +++++++++++++++++++++ .../modules/custom_munin_node/manifests/openvpn.pp | 8 ++ 4 files changed, 140 insertions(+), 14 deletions(-) delete mode 100644 files/puppet/modules/custom/init.pp create mode 100644 files/puppet/modules/custom/manifests/init.pp create mode 100644 files/puppet/modules/custom_munin_node/files/openvpn (limited to 'files/puppet') diff --git a/files/puppet/modules/custom/init.pp b/files/puppet/modules/custom/init.pp deleted file mode 100644 index 74a688b..0000000 --- a/files/puppet/modules/custom/init.pp +++ /dev/null @@ -1,14 +0,0 @@ -# Customization init class -class custom { - include site_config::setup - include site_config::default - - $services = hiera('services', []) - - include custom_munin_node - include custom_shorewall::munin_node - - if member ( $services, 'openvpn') { - include custom_munin_node::openvpn - } -} diff --git a/files/puppet/modules/custom/manifests/init.pp b/files/puppet/modules/custom/manifests/init.pp new file mode 100644 index 0000000..74a688b --- /dev/null +++ b/files/puppet/modules/custom/manifests/init.pp @@ -0,0 +1,14 @@ +# Customization init class +class custom { + include site_config::setup + include site_config::default + + $services = hiera('services', []) + + include custom_munin_node + include custom_shorewall::munin_node + + if member ( $services, 'openvpn') { + include custom_munin_node::openvpn + } +} diff --git a/files/puppet/modules/custom_munin_node/files/openvpn b/files/puppet/modules/custom_munin_node/files/openvpn new file mode 100644 index 0000000..bd7186b --- /dev/null +++ b/files/puppet/modules/custom_munin_node/files/openvpn @@ -0,0 +1,118 @@ +#!/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 + +=head2 DEFAULT CONFIGURATION + +The default configuration is + + [openvpn] + env.statusfile /var/log/openvpn.status + +=head1 AUTHOR + +Copyright (C) 2005 Rodolphe Quiedeville + +=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., 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. + +=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 vpn\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() { + 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"; + diff --git a/files/puppet/modules/custom_munin_node/manifests/openvpn.pp b/files/puppet/modules/custom_munin_node/manifests/openvpn.pp index 84ce219..133fc87 100644 --- a/files/puppet/modules/custom_munin_node/manifests/openvpn.pp +++ b/files/puppet/modules/custom_munin_node/manifests/openvpn.pp @@ -12,6 +12,14 @@ class custom_munin_node::openvpn { group => 0; } + file {'/usr/share/munin/plugins/openvpn': + source => 'puppet:///modules/custom_munin_node/openvpn', + before => Package['munin-plugins-core'], + mode => '0755', + owner => root, + group => 0; + } + file {'/etc/munin/plugins/openvpn': ensure => 'link', target => '/usr/share/munin/plugins/openvpn', -- cgit v1.2.3