Module: check_mk
Branch: master
Commit: 4f74529aca5d5b3decee810e59ec9c2d6b9227b1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4f74529aca5d5b…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Wed Sep 3 18:10:43 2014 +0200
Hivemanager: few improvments
---
agents/special/agent_hivemanager | 58 ++++++++++++++++++++++++
checkman/hivemanager_devices | 20 ++++++++
checks/{agent_hivmanager => agent_hivemanager} | 2 +-
3 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/agents/special/agent_hivemanager b/agents/special/agent_hivemanager
new file mode 100755
index 0000000..b4145cd
--- /dev/null
+++ b/agents/special/agent_hivemanager
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 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.
+
+import sys
+from urllib2 import urlopen
+import urllib2, base64, json
+
+try:
+ user = sys.argv[1]
+ password = sys.argv[2]
+except:
+ print "Usage: agent_hivemanager <USERNAME> <PASSWORD>"
+ sys.exit(2)
+
+def get_url(address):
+ request = urllib2.Request(address)
+ base64string = base64.encodestring('%s:%s' % (user,
password)).replace('\n', '')
+ request.add_header("Authorization", "Basic %s" % base64string)
+ request.add_header("Content-Type", "application/json")
+ try:
+ return urllib2.urlopen(request)
+ except urllib2.HTTPError, e:
+ print e
+ sys.exit(2)
+
+print "<<<check_mk>>>"
+print "Version: 1.2.5"
+print "AgentOs: Hivemanager"
+
+print "<<<hivemanager_devices:sep(124)>>>"
+address = "https://login.hivemanager.ch/hm/api/v1/devices"
+for line in json.loads(get_url(address).read()):
+ if line['upTime'] == '':
+ line['upTime'] = "down"
+ print "|".join(map(str, [ line['hostName'],
line['clients'], line['alarm'], line['connection'],
line['upTime'] ]))
diff --git a/checkman/hivemanager_devices b/checkman/hivemanager_devices
new file mode 100644
index 0000000..8affa8f
--- /dev/null
+++ b/checkman/hivemanager_devices
@@ -0,0 +1,20 @@
+title: Hivemanager Devices
+agents: special
+catalog: hw/network/hivemanager
+license: GPL
+distribution: check_mk
+description:
+ This check connects to a Hivemanager Account and get a list of all connected devices.
+ Then the connection state and the alarm state will be checked. Also it's possible to
set levels for
+ the maximum number of connected clients and for the maximum Uptime of a client.
+ To connect to the Hivemanager a special Datasource
+ Program is used. You can find it under the name <i>Hivemanager</i> in Wato
-> Datasource Programs.
+
+item:
+ The name of the Devices
+
+perfdata:
+ One variable: the current number of clients
+
+inventory:
+ One check for each device will be created
diff --git a/checks/agent_hivmanager b/checks/agent_hivemanager
similarity index 94%
rename from checks/agent_hivmanager
rename to checks/agent_hivemanager
index 801a072..cbdd5f0 100644
--- a/checks/agent_hivmanager
+++ b/checks/agent_hivemanager
@@ -26,6 +26,6 @@
def agent_hivemanager_arguments(params, hostname, ipaddress):
# User, Password
- return "%s %s" % ( params[0], params[1] )
+ return "%s %s" % ( quote_shell_string(params[0]),
quote_shell_string(params[1]) )
special_agent_info['hivemanager'] = agent_hivemanager_arguments