Module: check_mk
Branch: master
Commit: ad17a36dc01d1f8fbe99f702258809bd0d63270a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ad17a36dc01d1f…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Wed Mar 26 14:50:06 2014 +0100
innovaphone_licenses: New Check to monitor licens usage on innovaphone devices
---
agents/special/agent_innovaphone | 15 ++++++++++-
checkman/innovaphone_licenses | 19 ++++++++++++++
checks/innovaphone_licenses | 51 ++++++++++++++++++++++++++++++++++++++
3 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/agents/special/agent_innovaphone b/agents/special/agent_innovaphone
index 0654d53..c635d43 100755
--- a/agents/special/agent_innovaphone
+++ b/agents/special/agent_innovaphone
@@ -34,6 +34,7 @@ def get_pri_channel(channel_name):
link = data.get('link')
physical = data.get('physical')
if link != "Up" or physical != "Up":
+ print "%s %s %s 0 0 0" % ( channel_name, link, physical )
return
idle = 0
total = 0
@@ -42,8 +43,17 @@ def get_pri_channel(channel_name):
idle += 1
total += 1
total -= 1
- print "%s %s %s" % (channel_name, idle, total)
+ print "%s %s %s %s %s" % ( channel_name, link, physical, idle, total)
+def get_licenses():
+ address = "http://%s/PBX0/ADMIN/mod_cmd_login.xml" % server
+ data = etree.parse(get_url(address)).getroot()
+ for child in data.findall('lic'):
+ if child.get('name') == "Port":
+ count = child.get('count')
+ used = child.get('used')
+ print count, used
+ break
base_url = "/LOG0/CNT/mod_cmd.xml?cmd=xml-counts"
@@ -66,3 +76,6 @@ for what in [ "CPU", "MEM", "TEMP"]:
print "<<<%schannels>>>" % s_prefix
for channel in range(1,5):
get_pri_channel('PRI'+str(channel))
+
+print "<<<%slicenses>>>" % s_prefix
+get_licenses()
diff --git a/checkman/innovaphone_licenses b/checkman/innovaphone_licenses
new file mode 100644
index 0000000..507aed1
--- /dev/null
+++ b/checkman/innovaphone_licenses
@@ -0,0 +1,19 @@
+title: Innovaphone Gateway: Port licenses
+agents: special
+catalog: hw/network/tel
+license: GPL
+distribution: check_mk
+description:
+ This Check monitors the total number of used port licenses.
+
+inventory:
+ One check will be created
+
+perfdata:
+ The license usage, together with it's warn and crit levels
+
+[parameters]
+warning (int): The percentage of used licenses that triggers
+ a WARNING state
+critical (int): The percentage of used licenses that triggers
+ a CRITICAL state
diff --git a/checks/innovaphone_licenses b/checks/innovaphone_licenses
new file mode 100644
index 0000000..e4b79bc
--- /dev/null
+++ b/checks/innovaphone_licenses
@@ -0,0 +1,51 @@
+#!/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.
+
+innovaphone_licenses_default_levels = ( 90.0, 95.0 )
+
+def inventory_innovaphone_licenses(info):
+ return [ ( None, 'innovaphone_licenses_default_levels') ]
+
+def check_innovaphone_licenses(_no_item, params, info):
+ total, used = map(savefloat, info[0])
+ perc_used = ( used/ 100 ) * total
+ warn, crit = params
+ message = "Used %.0f/%.0f Licences (%.0f%%)" % ( used, total, perc_used)
+ levels = "Warning/ Critical at (%s/%s)" % ( warn, crit )
+ perf = [ ('licenses', used, None, None, total ) ]
+ if perc_used > crit:
+ return 2, message + levels, perf
+ if perc_used > warn:
+ return 1, message + levels, perf
+ return 0, message, perf
+
+check_info["innovaphone_licenses"] = {
+ "check_function" : check_innovaphone_licenses,
+ "inventory_function" : inventory_innovaphone_licenses,
+ "service_description" : "Licenses",
+ "has_perfdata" : True,
+}
+