[checkmk-commits] Check_MK Git: check_mk: #0197 check_uniserv: New Check for Uniserv Data Management Services

Bastian Kuhn bk at mathias-kettner.de
Tue Aug 5 13:51:46 CEST 2014


Module: check_mk
Branch: master
Commit: 478842395b5586c1e6ccee40c51bea0e3dcfce46
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=478842395b5586c1e6ccee40c51bea0e3dcfce46

Author: Bastian Kuhn <bk at mathias-kettner.de>
Date:   Tue Aug  5 13:51:39 2014 +0200

#0197 check_uniserv: New Check for Uniserv Data Management Services

This check uses a tcp connect to monitor the Uniserv Service.
Uniserv ( http://www.uniserv.com/ ) is a Data Management Service who offers
diffrent services like Address Checks, Banking Data Checks etc.

---

 .werks/197                                |   13 ++++++
 ChangeLog                                 |    1 +
 checkman/check_uniserv                    |   16 +++++++
 checks/check_uniserv                      |   63 +++++++++++++++++++++++++++
 doc/treasures/active_checks/check_uniserv |   67 +++++++++++++++++++++++++++++
 web/plugins/wato/active_checks.py         |   38 ++++++++++++++++
 6 files changed, 198 insertions(+)

diff --git a/.werks/197 b/.werks/197
new file mode 100644
index 0000000..2334331
--- /dev/null
+++ b/.werks/197
@@ -0,0 +1,13 @@
+Title: check_uniserv: New Check for Uniserv Data Management Services
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1407239445
+Class: feature
+
+This check uses a tcp connect to monitor the Uniserv Service.
+Uniserv ( http://www.uniserv.com/ ) is a Data Management Service who offers
+diffrent services like Address Checks, Banking Data Checks etc.
+
+
diff --git a/ChangeLog b/ChangeLog
index 5626a53..ae3c049 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
     * 0193 docsis_cm_status: New Check Status Check for Cable Modems with Docsis MIB.
     * 1070 printer_input/printer_output: New checks to monitor input/output sub-units of printers...
     * 0196 esx_vsphere_hostsystem: New subcheck for maintenance mode...
+    * 0197 check_uniserv: New Check for Uniserv Data Management Services...
     * 1051 FIX: tcp_conn_stats: fix missing performance data...
     * 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
     * 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/checkman/check_uniserv b/checkman/check_uniserv
new file mode 100644
index 0000000..d1b59d8
--- /dev/null
+++ b/checkman/check_uniserv
@@ -0,0 +1,16 @@
+title: Uniserv Service
+agents: active
+catalog: agentless
+license: GPL
+distribution: check_mk
+description:
+ This check uses a tcp connect to monitor the Uniserv Service.
+ Uniserv ( http://www.uniserv.com/ ) is a Data Management Service who offers
+ diffrent services like Address Checks, Banking Data Checks etc.
+
+ Whith this active check it is possible to querie one address and the response from
+ uniserv against a regex, or you can simply try to receive the version number from uniserv to make
+ sure that the service is reachable.
+
+ This check can be configured by Wato.
+
diff --git a/checks/check_uniserv b/checks/check_uniserv
new file mode 100644
index 0000000..013dc33
--- /dev/null
+++ b/checks/check_uniserv
@@ -0,0 +1,63 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# |             ____ _               _        __  __ _  __           |
+# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
+# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
+# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
+# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
+# |                                                                  |
+# | Copyright Mathias Kettner 2013             mk at 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.
+
+def check_uniserv_arguments(params):
+    args = " $HOSTADDRESS$"
+    args += " " + str(params['port'])
+    args += " " + quote_shell_string(params['service'])
+    if type(params['job']) == tuple:
+        job = params['job'][0]
+    else:
+        job = params['job']
+    if job == "version":
+        args += " VERSION" 
+    else:
+        address = params['job'][1]
+        args += " ADDRESS" 
+        args += " " + quote_shell_string(address['street'])
+        args += " " + str(address['street_no'])
+        args += " " + quote_shell_string(address['city'])
+        args += " " + quote_shell_string(address['search_regex'])
+
+    return args
+
+def check_uniserv_desc(params):
+    if type(params['job']) == tuple:
+        job = params['job'][0]
+    else:
+        job = params['job']
+    if job == "version":
+        return "Version"
+    else:
+        return "Address " + params['job'][1]['city']
+
+
+active_check_info['uniserv'] = {
+    "command_line"        : '$USER1$/check_uniserv $ARG1$',
+    "argument_function"   : check_uniserv_arguments,
+    "service_description" : check_uniserv_desc,
+}
+
diff --git a/doc/treasures/active_checks/check_uniserv b/doc/treasures/active_checks/check_uniserv
new file mode 100755
index 0000000..fd3e867
--- /dev/null
+++ b/doc/treasures/active_checks/check_uniserv
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+import socket, sys
+BUFFER_SIZE = 1024
+try:
+    HOST        = sys.argv[1]
+    TCP_PORT    = int(sys.argv[2])
+    SERVICE     = sys.argv[3]
+    JOB         = sys.argv[4]
+    if JOB == "ADDRESS":
+        STREET      = sys.argv[5]
+        STREET_NR   = sys.argv[6]
+        CITY        = sys.argv[7]
+        REGEX       = sys.argv[8]
+except:
+    print " Usage: client_uniserv.py HOSTNAME PORT SERVICE (VERSION|ADDRESS STREET NR CITY SEARCH_REGEX) "
+    sys.exit(3)
+
+def parse_response(data):
+    info = dict([ x.split('=') for x in data.split(";") ][:-1])
+    if info['type'] == '1':
+        print "Invalid response: " % str(info)
+        sys.exit(3)
+    return info
+
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.connect((HOST, TCP_PORT))
+
+sendstring = "open:service="+SERVICE+";servicehost="+HOST+"\n"
+s.send(sendstring)
+
+data = parse_response(s.recv(BUFFER_SIZE))
+if not data.get('session'):
+    print "Error getting SID. Response was: " + str(data)
+    sys.exit(3)
+sid = data.get('session')
+
+if JOB == "VERSION":
+    sendstring = "version:session="+sid+"\n"
+    s.send(sendstring)
+    data = parse_response(s.recv(BUFFER_SIZE))
+    state = 0
+    infotext = "Version is " + data['version_str']
+elif JOB == "ADDRESS":
+    import re
+    sendstring = "exec:session=%s;request_type=check_address;in_str=%s;in_hno=%s;in_city=%s\n" % \
+    ( sid, STREET, STREET_NR, CITY )
+    s.send(sendstring)
+    data = parse_response(s.recv(BUFFER_SIZE))	
+	
+    sendstring = "fetch:session="+sid+";out_zip=?;out_city=?\n"
+    s.send(sendstring)
+    data = parse_response(s.recv(BUFFER_SIZE))
+	
+    state = 0
+    infotext = "Address is %s %s" % ( data['out_zip'], data['out_city'])
+    if not re.match( REGEX, data['out_city']):
+        infotext += " But excpects %s" % REGEX
+        state = 2
+else:
+    state = 3
+    infotext = "JOB not known"
+
+s.send("close:session="+sid+"\n")
+s.close()
+
+print infotext
+sys.exit(state)
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 18273dd..be4ee0c 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -475,6 +475,44 @@ register_rule(group,
     match = 'all'
 )
 
+register_rule(group,
+    "active_checks:uniserv", Dictionary(
+        title = _("Check uniserv service"), optional_keys = False, elements = [
+            ("port",
+                Integer( title = _("Port") )),
+            ("service",
+                TextAscii( title = _("Service String"),
+                           help = _("Enter here the uniserve service name. (Has nothting to do with service description)")
+            )),
+            ("job", 
+                CascadingDropdown(
+                    title = _("Mode of the Check"), 
+                    help = _("Choose if you just want to query the version number,"
+                             " or if you want to check the response to a address querie"),
+                    choices = [
+                        ("version", _("Check for Version")),
+                        ("address", _("Check for a Address"),
+                            Dictionary(
+                                title = _("Address Check mode"), 
+                                optional_keys = False,
+                                elements = [
+                                    ( "street",
+                                        TextAscii( title = _("Street name"))),
+                                    ( "street_no",
+                                        Integer( title = _("Street number"))),
+                                    ( "city",
+                                        TextAscii( title = _("City name"))),
+                                    ( "search_regex",
+                                        TextAscii( title = _("Check City against Regex"),
+                                        help = _( "The City name from the response will be checked against "
+                                                  "the regular expression specified here"),
+                                        )),
+                                ]
+                        )),
+                    ]
+                )),
+
+        ]))
 
 register_rule(group,
     "active_checks:http",



More information about the checkmk-commits mailing list