Skip to content

Commit

Permalink
7894 seh_ports: new check which allows to monitor dongle ports of SEH…
Browse files Browse the repository at this point in the history
… dongle server devices

This check supports monitoring of dongle ports of SEH dongle server devices. It detects connected ports along with their connections and warns the user should one dongle be removed

CMK-1958

Change-Id: Idefcee20bb11b24f667ce66c5f25280a34f15faa
  • Loading branch information
Wontek Hong authored and mo-ki committed Jul 12, 2019
1 parent 032af83 commit 8555ed1
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .werks/7894
@@ -0,0 +1,10 @@
Title: seh_ports: new check which allows to monitor dongle ports of SEH dongle server devices
Level: 1
Component: checks
Compatible: compat
Edition: cre
Version: 1.7.0i1
Date: 1562672513
Class: feature

This check supports monitoring of dongle ports of SEH dongle server devices. It detects connected ports along with their connections and warns the user should one dongle be removed
14 changes: 14 additions & 0 deletions checkman/seh_ports
@@ -0,0 +1,14 @@
title: SEH myUTN: Ports
agents: snmp
catalog: hw/network/seh
license: GPL
distribution: check_mk
description:
This check monitors the state of the ports of the SEH myUTN dongle server devices.
In addition, it also warns the user should the state of a previously connected port change.

item:
The port number.

inventory:
One item per detected device.
68 changes: 68 additions & 0 deletions checks/seh_ports
@@ -0,0 +1,68 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2017 mk@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-
# tails. 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 parse_seh_ports(info):
parsed = {}
for oid_end, tag, status, port_number in info[0]:
oid_index = oid_end.split('.')[0]
if tag != u"":
parsed.setdefault(oid_index, {}).update(tag=tag)
if port_number != "0":
parsed.setdefault(port_number, {}).update(status=status)
return parsed


def inventory_seh_ports(parsed):
for key, port in parsed.iteritems():
yield key, {"status_at_discovery": port.get("status")}


@get_parsed_item_data
def check_seh_ports(item, params, data):
for key in ("tag", "status"):
if key in data:
yield 0, "%s: %s" % (key.title(), data[key])

if params.get("status_at_discovery") != data.get("status"):
yield 1, "Status during discovery: %s" % (params.get("status_at_discovery") or "unknown")


check_info['seh_ports'] = {
"parse_function": parse_seh_ports,
"inventory_function": inventory_seh_ports,
"check_function": check_seh_ports,
"service_description": "Port %s",
"snmp_info": [(
".1.3.6.1.4.1.1229.2.50.2.1",
[
OID_END,
"10", #PortTag
"26", #Connection status
"27", #UTN slot number
])],
"snmp_scan_function": lambda oid: '.1.3.6.1.4.1.1229.1.1' in oid(".1.3.6.1.2.1.1.2.0"),
}
1 change: 1 addition & 0 deletions cmk/utils/man_pages.py
Expand Up @@ -137,6 +137,7 @@
"safenet" : "SafeNet",
"salesforce" : "Salesforce",
"symantec" : "Symantec",
"seh" : "SEH",
"servertech" : "Server Technology",
"siemens" : "Siemens",
"sophos" : "Sophos",
Expand Down
102 changes: 102 additions & 0 deletions tests/unit/checks/generictests/datasets/seh_ports_regression.py
@@ -0,0 +1,102 @@
# -*- encoding: utf-8
# yapf: disable

checkname = 'seh_ports'

info = [[[u'2.0', u'20848_Ent_GNSMART2', u'010.099.005.209', u'15'],
[u'3.0', u'20673_GNSMART1_Daten', u'010.028.103.077', u'4'],
[u'4.0', u'20557_Ent_SSR-Post', u'010.028.103.076', u'5'],
[u'5.0', u'20676_Postprocessing', u'010.028.103.075', u'6'],
[u'6.0', u'20675_Postprocessing', u'SAPOS-Admin (010.099.005.208)', u'7'],
[u'7.0', u'20785_Ent_GNSMART2', u'010.099.005.111', u'8'],
[u'8.0', u'20786_Ent_GNSMART2', u'010.099.005.202', u'12'],
[u'9.0', u'20737_GNSMART1_Vernetzung_NI', u'010.028.103.078', u'10'],
[u'10.0', u'20119_Postprocessing', u'ent.westphal (010.028.130.016)', u'20'],
[u'12.0', u'20672_GNSMART1_Vernetzung_NI', u'SAPOS-Admin (010.099.005.205)', u'3'],
[u'13.0', u'20674_GNSMART1_alles', u'010.099.005.102', u'14'],
[u'14.0', u'20414_SSR-Post', u'010.099.005.112', u'19'],
[u'15.0', u'20833_GNSMART1_Vernetzung_DE', u'010.099.005.207', u'16'],
[u'16.0', u'20606_GNSMART1_PE-Client', u'SAPOS-Admin (010.099.005.204)', u'17'],
[u'17.0', u'20387_GNSMART1_Daten', u'SAPOS-Admin (010.099.005.206)', u'18'],
[u'18.0', u'20600_GNSMART1_RxTools', u'-', u'0'],
[u'19.0', u'20837_Ent_GNSMART2', u'Available', u'2'],
[u'20.0', u'Test', u'SAPOS-Admin (010.099.005.203)', u'9'],
[u'21.0', u'', u'010.099.005.114', u'13']]]

discovery = {
'': [
(u'10', {
'status_at_discovery': u'010.028.103.078'
}),
(u'12', {
'status_at_discovery': u'010.099.005.202'
}),
(u'13', {
'status_at_discovery': u'010.099.005.114'
}),
(u'14', {
'status_at_discovery': u'010.099.005.102'
}),
(u'15', {
'status_at_discovery': u'010.099.005.209'
}),
(u'16', {
'status_at_discovery': u'010.099.005.207'
}),
(u'17', {
'status_at_discovery': u'SAPOS-Admin (010.099.005.204)'
}),
(u'18', {
'status_at_discovery': u'SAPOS-Admin (010.099.005.206)'
}),
(u'19', {
'status_at_discovery': u'010.099.005.112'
}),
(u'2', {
'status_at_discovery': u'Available'
}),
(u'20', {
'status_at_discovery': u'ent.westphal (010.028.130.016)'
}),
(u'3', {
'status_at_discovery': u'SAPOS-Admin (010.099.005.205)'
}),
(u'4', {
'status_at_discovery': u'010.028.103.077'
}),
(u'5', {
'status_at_discovery': u'010.028.103.076'
}),
(u'6', {
'status_at_discovery': u'010.028.103.075'
}),
(u'7', {
'status_at_discovery': u'SAPOS-Admin (010.099.005.208)'
}),
(u'8', {
'status_at_discovery': u'010.099.005.111'
}),
(u'9', {
'status_at_discovery': u'SAPOS-Admin (010.099.005.203)'
}),
]
}

checks = {
'': [
(u'8', {'status_at_discovery': u'010.099.005.111'}, [
(0, u'Tag: 20786_Ent_GNSMART2', []),
(0, u'Status: 010.099.005.111', []),
]),
(u'9', {'status_at_discovery': u'Available'}, [
(0, u'Tag: 20737_GNSMART1_Vernetzung_NI', []),
(0, u'Status: SAPOS-Admin (010.099.005.203)', []),
(1, u'Status during discovery: Available', []),
]),
(u'9', {'status_at_discovery': None}, [
(0, u'Tag: 20737_GNSMART1_Vernetzung_NI', []),
(0, u'Status: SAPOS-Admin (010.099.005.203)', []),
(1, u'Status during discovery: unknown', []),
]),
]
}

0 comments on commit 8555ed1

Please sign in to comment.