2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # Example output from agent:
28 # <<<openvpn_clients:sep(44)>>>
29 # wilhelmshilfe-hups1,84.161.206.33:58371,11267978,8134524,Sun Mar 10 14:02:27 2013
30 # wilhelmshilfe-hups365,84.161.206.33:59737,924198,809268,Sun Mar 10 13:59:14 2013
31 # wilhelmshilfe-bartenbach-redu,78.43.52.102:40411,492987861,516066364,Sun Mar 10 03:55:01 2013
32 # wilhelmshilfe-hups3,84.161.206.33:58512,8224815,6189879,Sun Mar 10 11:32:40 2013
33 # wilhelmshilfe-heiningen,46.5.209.251:3412,461581486,496901007,Fri Mar 8 10:02:38 2013
34 # wilhelmshilfe-hups5,84.161.206.33:60319,721646,336190,Sun Mar 10 14:23:30 2013
35 # wilhelmshilfe-suessen,92.198.38.212:3077,857194558,646128778,Fri Mar 8 10:02:38 2013
36 # wilhelmshilfe-hups6,84.161.206.33:61410,3204103,2793366,Sun Mar 10 11:59:13 2013
37 # wilhelmshilfe-gw-fau1,217.92.99.180:55683,109253134,96735180,Sun Mar 10 10:11:44 2013
38 # wilhelmshilfe-bendig,78.47.146.190:34475,5787319,19395097,Sat Mar 9 10:02:52 2013
39 # wilhelmshilfe-ursenwang,46.223.206.6:47299,747919254,922426625,Fri Mar 8 10:02:38 2013
40 # vpn-wilhelmshilfe.access.lihas.de,79.204.249.30:59046,12596972,31933023,Sun Mar 10 09:32:22 2013
41 # wilhelmshilfe-karlshof,92.198.38.214:3078,810996228,716994592,Fri Mar 8 10:02:39 2013
44 def inventory_openvpn_clients(info
):
45 return [(l
[0], None) for l
in info
]
48 def check_openvpn_clients(item
, _no_params
, info
):
51 infos
= ["Channel is up"]
53 _name
, _address
, inbytes
, outbytes
, _date
= line
54 this_time
= time
.time()
55 for what
, val
in [("in", int(inbytes
)), ("out", int(outbytes
))]:
56 countername
= "openvpn_clients.%s.%s" % (item
, what
)
57 bytes_per_sec
= get_rate(countername
, this_time
, val
)
58 infos
.append("%s: %s/sec" % (what
, get_bytes_human_readable(bytes_per_sec
)))
59 perfdata
.append((what
, bytes_per_sec
))
60 return 0, ", ".join(infos
), perfdata
62 return 3, "Client connection not found"
65 check_info
["openvpn_clients"] = {
66 "check_function": check_openvpn_clients
,
67 "inventory_function": inventory_openvpn_clients
,
68 "service_description": "OpenVPN Client %s",