Module: check_mk
Branch: master
Commit: 73c5f8a9806b1032abce97c6298d26dd24407a87
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=73c5f8a9806b10…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 25 12:50:30 2013 +0100
openvpn_clients: new check for OpenVPN connections
---
ChangeLog | 1 +
agents/check_mk_agent.linux | 6 ++
checkman/openvpn_clients | 27 +++++++++++
checks/openvpn_clients | 70 ++++++++++++++++++++++++++++
pnp-templates/check_mk-openvpn_clients.php | 45 ++++++++++++++++++
web/plugins/perfometer/check_mk.py | 10 ++++
6 files changed, 159 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 33d673e..f5c11d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
systems to retrieve monitoring information for this or other machines.
* sap.dialog: Monitors SAP dialog statistics like the response time
* sap.value: Simply processes information provided by SAP to Nagios
+ * openvpn_clients: new check for OpenVPN connections
BI:
* Integrated availability computing, including nifty time warp feature
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 27dc5d9..c5ebbfe 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -350,6 +350,12 @@ if type VBoxControl > /dev/null 2>&1 ; then
[ ${PIPESTATUS[0]} = 0 ] || echo "ERROR"
fi
+# OpenVPN Clients. Currently we assume that the configuration # is in
+# /etc/openvpn. We might find a safer way to find the configuration later.
+if [ -e /etc/openvpn/openvpn-status.log ] ; then
+ echo '<<<openvpn_clients:sep(44)>>>'
+ sed -n -e '/CLIENT LIST/,/ROUTING TABLE/p' <
/etc/openvpn/openvpn-status.log | sed -e 1,3d -e '$d'
+fi
if type ntpq > /dev/null 2>&1 ; then
echo '<<<ntp>>>'
diff --git a/checkman/openvpn_clients b/checkman/openvpn_clients
new file mode 100644
index 0000000..a44489e
--- /dev/null
+++ b/checkman/openvpn_clients
@@ -0,0 +1,27 @@
+title: Check status of OpenVPN client connection
+agents: linux
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check uses the status file created by OpenVPN in order
+ to check the state of the client connections and also to measure
+ the inbound and outbound traffic. The traffic is measured raw -
+ i.e. including keepalive packages and headers - not just the payload.
+
+ Currently the linux agent is expecting the status file at
+ {/etc/openvpn/openvpn-status.log}. You can specify the path where
+ OpenVPN should create this file with the directive {status =} in you
+ {openvpn.conf}.
+
+item:
+ The name of the OpenVPN connection (first column in the status file).
+
+perfdata:
+ Two variables: the number of bytes per second inbound and outbound traffic.
+ Note: the check output, PNP template and Perf-O-Meter convert this to MBit/sec.
+
+inventory:
+ One service per active connection will be created. Please use
+ {ignored_services} if you want to restrict this.
+
diff --git a/checks/openvpn_clients b/checks/openvpn_clients
new file mode 100644
index 0000000..26eb2d2
--- /dev/null
+++ b/checks/openvpn_clients
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk 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 in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Example output from agent:
+# <<<openvpn_clients:sep(44)>>>
+# wilhelmshilfe-hups1,84.161.206.33:58371,11267978,8134524,Sun Mar 10 14:02:27 2013
+# wilhelmshilfe-hups365,84.161.206.33:59737,924198,809268,Sun Mar 10 13:59:14 2013
+# wilhelmshilfe-bartenbach-redu,78.43.52.102:40411,492987861,516066364,Sun Mar 10
03:55:01 2013
+# wilhelmshilfe-hups3,84.161.206.33:58512,8224815,6189879,Sun Mar 10 11:32:40 2013
+# wilhelmshilfe-heiningen,46.5.209.251:3412,461581486,496901007,Fri Mar 8 10:02:38 2013
+# wilhelmshilfe-hups5,84.161.206.33:60319,721646,336190,Sun Mar 10 14:23:30 2013
+# wilhelmshilfe-suessen,92.198.38.212:3077,857194558,646128778,Fri Mar 8 10:02:38 2013
+# wilhelmshilfe-hups6,84.161.206.33:61410,3204103,2793366,Sun Mar 10 11:59:13 2013
+# wilhelmshilfe-gw-fau1,217.92.99.180:55683,109253134,96735180,Sun Mar 10 10:11:44 2013
+# wilhelmshilfe-bendig,78.47.146.190:34475,5787319,19395097,Sat Mar 9 10:02:52 2013
+# wilhelmshilfe-ursenwang,46.223.206.6:47299,747919254,922426625,Fri Mar 8 10:02:38
2013
+# vpn-wilhelmshilfe.access.lihas.de,79.204.249.30:59046,12596972,31933023,Sun Mar 10
09:32:22 2013
+# wilhelmshilfe-karlshof,92.198.38.214:3078,810996228,716994592,Fri Mar 8 10:02:39 2013
+
+def inventory_openvpn_clients(info):
+ return [ (l[0], None) for l in info ]
+
+def check_openvpn_clients(item, _no_params, info):
+ for line in info:
+ if line[0] == item:
+ infos = [ "Channel is up" ]
+ perfdata = []
+ name, address, inbytes, outbytes, date = line
+ this_time = time.time()
+ for what, val in [
+ ( "in", int(inbytes) ),
+ ( "out", int(outbytes) )]:
+ countername = "openvpn_clients.%s.%s" % (item, what)
+ timedif, bytes_per_sec = get_counter(countername, this_time, val)
+ infos.append("%s: %s/sec" % (what,
get_bytes_human_readable(bytes_per_sec)))
+ perfdata.append((what, bytes_per_sec))
+ return 0, "OK - " + ", ".join(infos), perfdata
+
+ return 3, "UNKNOWN - Client connection not found"
+
+check_info["openvpn_clients"] = {
+ "check_function" : check_openvpn_clients,
+ "inventory_function" : inventory_openvpn_clients,
+ "service_description" : "OpenVPN Client %s",
+ "has_perfdata" : True,
+}
+
diff --git a/pnp-templates/check_mk-openvpn_clients.php
b/pnp-templates/check_mk-openvpn_clients.php
new file mode 100644
index 0000000..8b6feff
--- /dev/null
+++ b/pnp-templates/check_mk-openvpn_clients.php
@@ -0,0 +1,45 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk 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 in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+$parts = explode("_",$servicedesc);
+$channel = $parts[2];
+
+$opt[1] = "--vertical-label \"MBit per secound\" -X0 -l0 --title
\"VPN-Traffic (raw) $hostname / $channel\" ";
+
+$def[1] = "DEF:in=$RRDFILE[1]:$DS[1]:MAX " ;
+$def[1] .= "DEF:out=$RRDFILE[2]:$DS[2]:MAX " ;
+$def[1] .= "CDEF:mb_out=out,131072,/ " ;
+$def[1] .= "CDEF:mb_out_n=mb_out,-1,* " ;
+$def[1] .= "CDEF:mb_in=in,131072,/ " ;
+$def[1] .= "AREA:mb_in#30d050:\"Inbound \" " ;
+$def[1] .= "GPRINT:mb_in:LAST:\"%6.2lf MBit/s last\" " ;
+$def[1] .= "GPRINT:mb_in:AVERAGE:\"%6.2lf MBit/s avg\" " ;
+$def[1] .= "GPRINT:mb_in:MAX:\"%6.2lf MBit/s max\\n\" ";
+$def[1] .= "AREA:mb_out_n#0060c0:\"Outbound \" " ;
+$def[1] .= "GPRINT:mb_out:LAST:\"%6.2lf MBit/s last\" " ;
+$def[1] .= "GPRINT:mb_out:AVERAGE:\"%6.2lf MBit/s avg\" " ;
+$def[1] .= "GPRINT:mb_out:MAX:\"%6.2lf MBit/s max\\n\" " ;
+?>
+
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index b0ca714..a8ea017 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -397,6 +397,16 @@ perfometers["check_mk-winperf_phydisk"] =
perfometer_check_mk_diskstat
perfometers["check_mk-hpux_lunstats"] = perfometer_check_mk_diskstat
perfometers["check_mk-mysql.innodb_io"] = perfometer_check_mk_diskstat
+def perfometer_in_out_mb_per_sec(row, check_command, perf_data):
+ read_mbit = float(perf_data[0][1]) / 131072
+ write_mbit = float(perf_data[1][1]) / 131072
+
+ text = "%-.2fMb/s %-.2fMb/s" % (read_mbit, write_mbit)
+
+ return text, perfometer_logarithmic_dual(
+ read_mbit, "#30d050", write_mbit, "#0060c0", 100, 10)
+perfometers["check_mk-openvpn_clients"] = perfometer_in_out_mb_per_sec
+
def perfometer_check_mk_printer_supply(row, check_command, perf_data):
left = savefloat(perf_data[0][1])