diff --git a/agent_based/cisco_eigrp_as_info.py b/agent_based/cisco_eigrp_as_info.py new file mode 100644 index 0000000000000000000000000000000000000000..dbb2b158e32c65c8ce9b249bc6691b1a5f2a9ca1 --- /dev/null +++ b/agent_based/cisco_eigrp_as_info.py @@ -0,0 +1,324 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-17-20 +# +# Monitor status of Cisco EIGRP AS info +# +# 2018-02-11: removed unnecessary OIDs +# 2018-08-06: modified scan function +# 2019-10-16: added support for IPv6 and VRFs, added parser function +# +# +# snmpwalk sample +# +# thl@surfbox-ii:~$ snmpwalk -v2c -c router-01 -ObentU simulant .1.3.6.1.4.1.9.9.449.1.2.1.1 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.2.65536.10 = Gauge32: 3 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.3.65536.10 = Counter32: 37436 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.4.65536.10 = Counter32: 32170 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.5.65536.10 = Counter32: 161 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.6.65536.10 = Counter32: 143 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.7.65536.10 = Counter32: 14 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.8.65536.10 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.9.65536.10 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.10.65536.10 = Counter32: 14 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.11.65536.10 = Counter32: 143 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.12.65536.10 = Counter32: 132 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.13.65536.10 = Gauge32: 2 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.14.65536.10 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.15.65536.10 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.16.65536.10 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.17.65536.10 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.18.65536.10 = Hex-STRING: 0A A7 DC FF # can be also in the form of "10.10.10.10" :-( +# .1.3.6.1.4.1.9.9.449.1.2.1.1.19.65536.10 = Counter32: 10 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.20.65536.10 = Counter64: 1 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.21.65536.10 = Counter64: 135 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.22.65536.10 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.2.1.1.23.65536.10 = Gauge32: 0 + +# +# sample info +# [ +# [u'65536.10', u'1', u'7081', u'6637', u'37', u'45', u'0', u'0', u'0', u'0', u'26', u'32', u'2', u'0', u'0', u'0', u'1', u'\n\xa7\xdc\xfd', u'10', u'0'] +# ] +# + +# +from time import time +from dataclasses import dataclass +from typing import Optional, List + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + Result, + check_levels, + State, + SNMPTree, + all_of, + contains, + exists, + OIDEnd, + Metric, + get_rate, + get_value_store, + GetRateError, + IgnoreResultsError, +) +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + +_InetAddressType = {0: 'unknown', + 1: 'ipv4', + 2: 'ipv6', + 3: 'ipv4z', + 4: 'ipv6z', + 16: 'dns', + } + + +def _render_ip_address(bytestring): + return ".".join(["%s" % ord(m) for m in bytestring]) + +########################################################################### +# +# DATA Parser function +# +########################################################################### + + +def parse_cisco_eigrp_as_info(string_table: List[StringTable]): + ASInfoTable = [] + ASTable = {} + ASInfo, VrfInfo = string_table + + for OID_END, cEigrpNbrCount, cEigrpHellosSent, cEigrpHellosRcvd, cEigrpUpdatesSent, cEigrpUpdatesRcvd, cEigrpQueriesSent, \ + cEigrpQueriesRcvd, cEigrpRepliesSent, cEigrpRepliesRcvd, cEigrpAcksSent, cEigrpAcksRcvd, cEigrpInputQHighMark, cEigrpInputQDrops, \ + cEigrpSiaQueriesSent, cEigrpSiaQueriesRcvd, cEigrpAsRouterIdType, cEigrpAsRouterId, cEigrpTopoRoutes, cEigrpXmitPendReplies in ASInfo: + + cEigrpVrfId = int(OID_END.split('.')[0]) + cEigrpAS = OID_END.split('.')[1] + + cEigrpVrfName = '' + for VrfId, VrfName in VrfInfo: + if int(VrfId) == cEigrpVrfId: + cEigrpVrfName = VrfName + if cEigrpVrfId < 100000: + cEigrpAddrFammily = 'IPv4' + else: + cEigrpAddrFammily = 'IPv6' + + if int(cEigrpAsRouterIdType) == 1: + if len(cEigrpAsRouterId) == 4: + cEigrpAsRouterId = _render_ip_address(cEigrpAsRouterId) + + ASInfoTable.append({ + 'cEigrpAS': cEigrpAS, + 'cEigrpVrfName': cEigrpVrfName, + 'cEigrpVrfId': cEigrpVrfId, + 'cEigrpAddrFammily': cEigrpAddrFammily, + 'cEigrpNbrCount': int(cEigrpNbrCount), + 'cEigrpHellosSent': int(cEigrpHellosSent), + 'cEigrpHellosRcvd': int(cEigrpHellosRcvd), + 'cEigrpUpdatesSent': int(cEigrpUpdatesSent), + 'cEigrpUpdatesRcvd': int(cEigrpUpdatesRcvd), + 'cEigrpQueriesSent': int(cEigrpQueriesSent), + 'cEigrpQueriesRcvd': int(cEigrpQueriesRcvd), + 'cEigrpRepliesSent': int(cEigrpRepliesSent), + 'cEigrpRepliesRcvd': int(cEigrpRepliesRcvd), + 'cEigrpAcksSent': int(cEigrpAcksSent), + 'cEigrpAcksRcvd': int(cEigrpAcksRcvd), + 'cEigrpInputQHighMark': int(cEigrpInputQHighMark), + 'cEigrpInputQDrops': int(cEigrpInputQDrops), + 'cEigrpSiaQueriesSent': int(cEigrpSiaQueriesSent), + 'cEigrpSiaQueriesRcvd': int(cEigrpSiaQueriesRcvd), + 'cEigrpAsRouterId': cEigrpAsRouterId, + 'cEigrpTopoRoutes': int(cEigrpTopoRoutes), + 'cEigrpXmitPendReplies': int(cEigrpXmitPendReplies), + }) + + if cEigrpVrfName == 'default' and cEigrpAddrFammily == 'IPv4': + ASTable.update({cEigrpVrfId: {'ServiceText': cEigrpAS, 'cEigrpVrfId': cEigrpVrfId}}) + elif cEigrpVrfName == 'default' and cEigrpAddrFammily == 'IPv6': + ASTable.update({cEigrpVrfId:{'ServiceText': '%s IPv6' % cEigrpAS, 'cEigrpVrfId': cEigrpVrfId}}) + elif cEigrpVrfName != 'default' and cEigrpAddrFammily == 'IPv4': + ASTable.update({cEigrpVrfId:{'ServiceText': '%s VRF %s' % (cEigrpAS, cEigrpVrfName), 'cEigrpVrfId': cEigrpVrfId}}) + elif cEigrpVrfName != 'default' and cEigrpAddrFammily == 'IPv6': + ASTable.update({cEigrpVrfId:{'ServiceText': '%s IPv6 VRF %s' % (cEigrpAS, cEigrpVrfName), 'cEigrpVrfId': cEigrpVrfId}}) + return [ASTable, ASInfoTable] + +########################################################################### +# +# INVENTORY function +# +########################################################################### + + +def discovery_cisco_eigrp_as_info(section) -> DiscoveryResult: + ASTable, ASInfoTable = section + ASTable = dict(ASTable) + for Key in ASTable.keys(): + ServiceText = ASTable.get(Key).get('ServiceText') + yield Service(item=ServiceText) + +########################################################################### +# +# CHECK function +# +########################################################################### + + +def check_cisco_eigrp_as_info(item, params, section) -> CheckResult: + ASTable, ASInfoTable = section + ASTable = dict(ASTable) + + cEigrpVrfId = '' + for Key in ASTable.keys(): + ServiceText = ASTable.get(Key).get('ServiceText') + if ServiceText == item: + cEigrpVrfId = ASTable.get(Key).get('cEigrpVrfId') + + if cEigrpVrfId != '': + for AS in ASInfoTable: + if AS.get('cEigrpVrfId') == cEigrpVrfId: + cEigrpNbrCount = AS.get('cEigrpNbrCount') + cEigrpHellosSent = AS.get('cEigrpHellosSent') + cEigrpHellosRcvd = AS.get('cEigrpHellosRcvd') + cEigrpUpdatesSent = AS.get('cEigrpUpdatesSent') + cEigrpUpdatesRcvd = AS.get('cEigrpUpdatesRcvd') + cEigrpQueriesSent = AS.get('cEigrpQueriesSent') + cEigrpQueriesRcvd = AS.get('cEigrpQueriesRcvd') + cEigrpRepliesSent = AS.get('cEigrpRepliesSent') + cEigrpRepliesRcvd = AS.get('cEigrpRepliesRcvd') + cEigrpAcksSent = AS.get('cEigrpAcksSent') + cEigrpAcksRcvd = AS.get('cEigrpAcksRcvd') + cEigrpInputQHighMark = AS.get('cEigrpInputQHighMark') + cEigrpInputQDrops = AS.get('cEigrpInputQDrops') + cEigrpSiaQueriesSent = AS.get('cEigrpSiaQueriesSent') + cEigrpSiaQueriesRcvd = AS.get('cEigrpSiaQueriesRcvd') + cEigrpAsRouterId = AS.get('cEigrpAsRouterId') + cEigrpTopoRoutes = AS.get('cEigrpTopoRoutes') + cEigrpXmitPendReplies = AS.get('cEigrpXmitPendReplies') + + yield Result( + state=State.OK, + summary=f'Router-ID: {cEigrpAsRouterId}, neighbors: {cEigrpNbrCount}, Routes in topologie table: {cEigrpTopoRoutes}') + + for key, value in [ + ('cEigrpNbrCount', cEigrpNbrCount), + ('cEigrpUpdatesSent', cEigrpUpdatesSent), + ('cEigrpUpdatesRcvd', cEigrpUpdatesRcvd), + ('cEigrpQueriesSent', cEigrpQueriesSent), + ('cEigrpQueriesRcvd', cEigrpQueriesRcvd), + ('cEigrpRepliesSent', cEigrpRepliesSent), + ('cEigrpRepliesRcvd', cEigrpRepliesRcvd), + ('cEigrpAcksSent', cEigrpAcksSent), + ('cEigrpAcksRcvd', cEigrpAcksRcvd), + ('cEigrpInputQHighMark', cEigrpInputQHighMark), + ('cEigrpInputQDrops', cEigrpInputQDrops), + ('cEigrpSiaQueriesSent', cEigrpSiaQueriesSent), + ('cEigrpSiaQueriesRcvd', cEigrpSiaQueriesRcvd), + ('cEigrpTopoRoutes', cEigrpTopoRoutes), + ('cEigrpXmitPendReplies', cEigrpXmitPendReplies), + ]: + yield Metric(name=f'cisco_eigrp_as_info_{key}', value=value) + + now_time = time() + rate_item=item.replace(' ', '_').replace(':', '_') + value_store = get_value_store() + raise_ingore_res = False + + for key, value in [ + ('cEigrpHellosSent', cEigrpHellosSent), + ('cEigrpHellosRcvd', cEigrpHellosRcvd), + + ]: + try: + try: + value = get_rate( + value_store, + f'cisco_eigrp_as_info_{key}.{rate_item}', + now_time, + value, + raise_overflow=False + ) + except GetRateError: + raise_ingore_res = True + value = 0 + yield Metric(name=f'cisco_eigrp_as_info_{key}', value=value, boundaries=(0, None)) + except KeyError: + pass + + if raise_ingore_res: + raise IgnoreResultsError('Initializing counters') + + +########################################################################### +# +# CHECK info +# +########################################################################### + + +register.snmp_section( + name='cisco_eigrp_as_info', + parse_function=parse_cisco_eigrp_as_info, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.2.1.1', # CISCO-TRUSTSEC-MIB::ctsEnvironmentDataObjects + oids=[ + OIDEnd(), # AS number + '2', # cEigrpNbrCount [1] + '3', # cEigrpHellosSent [2] + '4', # cEigrpHellosRcvd [3] + '5', # cEigrpUpdatesSent [4] + '6', # cEigrpUpdatesRcvd [5] + '7', # cEigrpQueriesSent [6] + '8', # cEigrpQueriesRcvd [7] + '9', # cEigrpRepliesSent [8] + '10', # cEigrpRepliesRcvd [9] + '11', # cEigrpAcksSent [10] + '12', # cEigrpAcksRcvd [11] + '13', # cEigrpInputQHighMark [12] + '14', # cEigrpInputQDrops [13] + '15', # cEigrpSiaQueriesSent [14] + '16', # cEigrpSiaQueriesRcvd [15] + '17', # cEigrpAsRouterIdType [16] + '18', # cEigrpAsRouterId [17] + '19', # cEigrpTopoRoutes [18] + '22', # cEigrpXmitPendReplies [19] + # '20', # cEigrpHeadSerial [] + # '21', # cEigrpNextSerial [] + # '23', # cEigrpXmitDummies [] + ] + ), + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.1.1.1', # CISCO-TRUSTSEC-MIB::ctsEnvironmentDataObjects + oids=[ + OIDEnd(), # VRF ID + '2', # cEigrpVpnName + ] + ), + + ], + detect=all_of( + contains('.1.3.6.1.2.1.1.1.0', 'cisco'), # sysDescr + exists('.1.3.6.1.4.1.9.9.449.1.2.1.1.2.*'), # CISCO-EIGRP-MIB::cEigrpNbrCount + )) + +register.check_plugin( + name='cisco_eigrp_as_info', + service_name='EIGRP AS number %s', + discovery_function=discovery_cisco_eigrp_as_info, + check_function=check_cisco_eigrp_as_info, + check_default_parameters={ + }, + check_ruleset_name='cisco_eigrp_as_info', +) diff --git a/agent_based/cisco_eigrp_interface.py b/agent_based/cisco_eigrp_interface.py new file mode 100644 index 0000000000000000000000000000000000000000..fcf25df36023a3f19f9034d1547d152747817ebc --- /dev/null +++ b/agent_based/cisco_eigrp_interface.py @@ -0,0 +1,423 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-17-21 +# +# Monitor status of Cisco EIGRP interface info +# +# 2018-01-23: Th.L.: inventory skip Loopback interface +# 2018-02-11: Th.L.: removed unnecessary OIDs +# 2018-08-06: modified scan function +# 2019-10-14: added support for hamc-sha-256 authentication, md5 moved to warn, none moved to crit +# 2019-10-16: added support for IPv6 and VRFs, added data parser function +# 2019-10-31: changed item from interface long-name to interface short name +# +# snmpwalk sample +# +# OMD[mysite]:~$ snmpwalk -ObentU -v2c -c router-01 simulant .1.3.6.1.4.1.9.9.449.1.5.1.1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.3.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.3.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.3.65536.10.8 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.3.65536.10.9 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.4.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.4.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.4.65536.10.8 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.4.65536.10.9 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.5.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.5.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.5.65536.10.8 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.5.65536.10.9 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.6.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.6.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.6.65536.10.8 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.6.65536.10.9 = Gauge32: 19 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.7.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.7.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.7.65536.10.8 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.7.65536.10.9 = Gauge32: 23 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.8.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.8.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.8.65536.10.8 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.8.65536.10.9 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.9.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.9.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.9.65536.10.8 = Gauge32: 50 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.9.65536.10.9 = Gauge32: 84 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.10.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.10.65536.10.7 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.10.65536.10.8 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.10.65536.10.9 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.11.65536.10.1 = Gauge32: 5 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.11.65536.10.7 = Gauge32: 5 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.11.65536.10.8 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.11.65536.10.9 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.12.65536.10.1 = Counter64: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.12.65536.10.7 = Counter64: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.12.65536.10.8 = Counter64: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.12.65536.10.9 = Counter64: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.13.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.13.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.13.65536.10.8 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.13.65536.10.9 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.14.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.14.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.14.65536.10.8 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.14.65536.10.9 = Counter32: 18 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.15.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.15.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.15.65536.10.8 = Counter32: 64 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.15.65536.10.9 = Counter32: 40 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.16.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.16.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.16.65536.10.8 = Counter32: 66 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.16.65536.10.9 = Counter32: 27 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.17.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.17.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.17.65536.10.8 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.17.65536.10.9 = Counter32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.18.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.18.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.18.65536.10.8 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.18.65536.10.9 = Counter32: 2 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.19.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.19.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.19.65536.10.8 = Counter32: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.19.65536.10.9 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.20.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.20.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.20.65536.10.8 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.20.65536.10.9 = Counter32: 5 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.21.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.21.65536.10.7 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.21.65536.10.8 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.21.65536.10.9 = Counter32: 3 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.22.65536.10.1 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.22.65536.10.7 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.22.65536.10.8 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.22.65536.10.9 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.5.1.1.23.65536.10.1 = "" +# .1.3.6.1.4.1.9.9.449.1.5.1.1.23.65536.10.7 = "" +# .1.3.6.1.4.1.9.9.449.1.5.1.1.23.65536.10.8 = STRING: "KEY-EIGRP-10" +# .1.3.6.1.4.1.9.9.449.1.5.1.1.23.65536.10.9 = STRING: "KEY-EIGRP-10" +# # +# sample info +# [ +# [ +# [u'65536.10.1', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'5', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'1', u''], +# [u'65536.10.7', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'5', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'0', u'1', u''], +# [u'65536.10.8', u'1', u'0', u'0', u'1', u'0', u'0', u'50', u'0', u'1', u'0', u'0', u'0', u'64', u'66', u'0', u'0', u'1', u'0', u'0', u'2', u'KEY-EIGRP-10'], +# [u'65536.10.9', u'1', u'0', u'0', u'19', u'23', u'0', u'84', u'0', u'1', u'0', u'0', u'18', u'40', u'27', u'1', u'2', u'0', u'5', u'3', u'2', u'KEY-EIGRP-10'] +# ], +# [ +# [u'1', u'GigabitEthernet0/0/0'], +# [u'2', u'GigabitEthernet0/0/1'], +# [u'3', u'GigabitEthernet0/0/2'], +# [u'4', u'GigabitEthernet0/0/3'], +# [u'5', u'GigabitEthernet0'], +# [u'6', u'Null0'], +# [u'7', u'Loopback0'], +# [u'8', u'Tunnel10'], +# [u'9', u'Tunnel101'] +# ] +# ] +# + +from time import mktime, gmtime +from dataclasses import dataclass +from typing import Optional, List, Dict + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + Result, + check_levels, + State, + SNMPTree, + all_of, + contains, + exists, + OIDEnd, + Metric, +) +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + + +@dataclass +class EigrpInterface: + cEigrpVrfId: int + cEigrpAS: str + cEigrpVrfName: str + cEigrpIfName: str + cEigrpPeerCount: int + cEigrpXmitReliableQ: int + cEigrpXmitUnreliableQ: int + cEigrpMeanSrtt: int + cEigrpPendingRoutes: int + cEigrpHelloInterval: int + cEigrpUMcasts: int + cEigrpUUcasts: int + cEigrpRUcasts: int + cEigrpMcastExcepts: int + cEigrpCRpkts: int + cEigrpAcksSuppressed: int + cEigrpRetransSent: int + cEigrpOOSrvcd: int + cEigrpAuthMode: str + cEigrpAuthKeyChain: str + + +_InetAddressType = { + 0: 'unknown', + 1: 'ipv4', + 2: 'ipv6', + 3: 'ipv4z', + 4: 'ipv6z', + 16: 'dns', +} + + +def _eigrp_authmode(mode: int) -> str: + name = { + 0: 'unknown', + 1: 'none', + 2: 'md5', + 3: 'hmac-sha-256' + } + return name.get(mode, f'unknown {mode}') + + +def _get_short_if_name(st: str) -> str: + names = { + 'ethernet': 'Eth', + 'fastethernet': 'Fa', + 'gigabitethernet': 'Gi', + 'tengigabitethernet': 'Te', + 'fortygigabitethernet': 'Fo', + 'hundredgigabitethernet': 'Hu', + 'port-channel': 'Po', + 'tunnel': 'Tu', + 'loopback': 'Lo', + } + for item in names.keys(): + if st.lower().startswith(item): + st = st.lower().replace(item, names.get(item)) + return st + +########################################################################### +# +# DATA Parser function +# +########################################################################### + + +def parse_cisco_eigrp_interface(string_table: List[StringTable]) -> Dict[str, EigrpInterface]: + EigrpInterfaces, InterfaceNames, VrfInfo = string_table + EigrpIfTable = {} + + for OID_END, cEigrpPeerCount, cEigrpXmitReliableQ, cEigrpXmitUnreliableQ, cEigrpMeanSrtt, cEigrpPendingRoutes, \ + cEigrpHelloInterval, cEigrpUMcasts, cEigrpRMcasts, cEigrpUUcasts, cEigrpRUcasts, cEigrpMcastExcepts, \ + cEigrpCRpkts, cEigrpAcksSuppressed, cEigrpRetransSent, cEigrpOOSrvcd, cEigrpAuthMode, \ + cEigrpAuthKeyChain in EigrpInterfaces: + + cEigrpVrfId = int(OID_END.split('.')[0]) + cEigrpAS = OID_END.split('.')[1] + cEigrpIfIndex = int(OID_END.split('.')[2]) + cEigrpIfName = '' + for ifindex, ifname, iftype in InterfaceNames: + if int(ifindex) == cEigrpIfIndex: # compare interface index + if not int(iftype) == 24: # skip Loopback interfaces + cEigrpIfName = _get_short_if_name(ifname) + + if cEigrpIfName != '': + cEigrpVrfName = '' + for VrfId, VrfName in VrfInfo: + if int(VrfId) == cEigrpVrfId: + cEigrpVrfName = VrfName + + if cEigrpVrfId < 100000: + cEigrpAddrFammily = 'IPv4' + else: + cEigrpAddrFammily = 'IPv6' + + ServiceText = '' + if cEigrpVrfName == 'default' and cEigrpAddrFammily == 'IPv4': + ServiceText = f'{cEigrpIfName} on AS {cEigrpAS}' + elif cEigrpVrfName == 'default' and cEigrpAddrFammily == 'IPv6': + ServiceText = f'{cEigrpIfName} on AS {cEigrpAS} IPv6' + elif cEigrpVrfName != 'default' and cEigrpAddrFammily == 'IPv4': + ServiceText = f'{cEigrpIfName} on AS {cEigrpAS} VRF {cEigrpVrfName}' + elif cEigrpVrfName != 'default' and cEigrpAddrFammily == 'IPv6': + ServiceText = f'{cEigrpIfName} on AS {cEigrpAS} IPv6 VRF {cEigrpVrfName}' + + EigrpIfTable[ServiceText] = EigrpInterface( + cEigrpVrfId=cEigrpVrfId, + cEigrpAS=cEigrpAS, + cEigrpVrfName=cEigrpVrfName, + cEigrpIfName=cEigrpIfName, + cEigrpPeerCount=int(cEigrpPeerCount), + cEigrpXmitReliableQ=int(cEigrpXmitReliableQ), + cEigrpXmitUnreliableQ=int(cEigrpXmitUnreliableQ), + cEigrpMeanSrtt=int(cEigrpMeanSrtt), + cEigrpPendingRoutes=int(cEigrpPendingRoutes), + cEigrpHelloInterval=int(cEigrpHelloInterval), + cEigrpUMcasts=int(cEigrpUMcasts), + cEigrpUUcasts=int(cEigrpUUcasts), + cEigrpRUcasts=int(cEigrpRUcasts), + cEigrpMcastExcepts=int(cEigrpMcastExcepts), + cEigrpCRpkts=int(cEigrpCRpkts), + cEigrpAcksSuppressed=int(cEigrpAcksSuppressed), + cEigrpRetransSent=int(cEigrpRetransSent), + cEigrpOOSrvcd=int(cEigrpOOSrvcd), + cEigrpAuthMode=_eigrp_authmode(int(cEigrpAuthMode)), + cEigrpAuthKeyChain=cEigrpAuthKeyChain, + ) + + return EigrpIfTable + +########################################################################### +# +# INVENTORY function +# +########################################################################### + + +def discovery_cisco_eigrp_interface(section: Dict[str, EigrpInterface]) -> DiscoveryResult: + for key in section.keys(): + yield Service(item=key) + +########################################################################### +# +# CHECK function +# +########################################################################### + + +def check_cisco_eigrp_interface(item, params, section: Dict[str, EigrpInterface]) -> CheckResult: + try: + eigrp_if = section[item] + except KeyError: + return + + interface_type = 0 + + yield Result(state=State.OK, summary=f'Peer count: {eigrp_if.cEigrpPeerCount}, Hello interval: {eigrp_if.cEigrpHelloInterval}, Auth Mode: {eigrp_if.cEigrpAuthMode}') + + md5_auth_state = params.get('md5_auth_state') + no_auth_state = params.get('no_auth_state') + if interface_type not in params.get('ignore_interfaces_auth'): + if eigrp_if.cEigrpAuthMode in ['md5'] and md5_auth_state != 0: + yield Result(state=State(md5_auth_state), notice='weak authentication set') + # yield Result(state=State.OK, notice=f'you can change the authentication mode to hmac-sha-256 by removing the eigrp authentication') + # yield Result(state=State.OK, notice=f'configuration from the interface and move it to the "router eigrp configuration"') + # yield Result(state=State.OK, notice=f'you need to change to "named mode configuration"') + # yield Result(state=State.OK, notice=f'router eigrp YOUR-EIGRP-NAME') + # yield Result(state=State.OK, notice=f' address-family ipv4 unicast autonomous-system {eigrp_if.cEigrpAS}') + # yield Result(state=State.OK, notice=f' af-interface {eigrp_if.cEigrpIfName}') + # yield Result(state=State.OK, notice=f' authentication mode hmac-sha-256 YOUR-EIGRPKEY') + # yield Result(state=State.OK, notice=f' exit-af-interface') + # yield Result(state=State.OK, notice=f' eigrp YOUR-ROUTER-ID') + # yield Result(state=State.OK, notice=f' network ....') + # yield Result(state=State.OK, notice=f'end') + elif eigrp_if.cEigrpAuthMode == 'none' and no_auth_state != 0: + yield Result(state=State(no_auth_state), notice='no authentication set') + if eigrp_if.cEigrpAuthKeyChain != '': + yield Result(state=State.OK, notice=f'Key chain: {eigrp_if.cEigrpAuthKeyChain}') + + for key, value in [ + ('cEigrpPeerCount', eigrp_if.cEigrpPeerCount), + ('cEigrpXmitReliableQ', eigrp_if.cEigrpXmitReliableQ), + ('cEigrpXmitUnreliableQ', eigrp_if.cEigrpXmitUnreliableQ), + ('cEigrpMeanSrtt', eigrp_if.cEigrpMeanSrtt), + ('cEigrpPendingRoutes', eigrp_if.cEigrpPendingRoutes), + # ('cEigrpRMcasts', eigrp_if.cEigrpRMcasts), + ('cEigrpUMcasts', eigrp_if.cEigrpUMcasts), + ('cEigrpUUcasts', eigrp_if.cEigrpUUcasts), + ('cEigrpRUcasts', eigrp_if.cEigrpRUcasts), + ('cEigrpMcastExcepts', eigrp_if.cEigrpMcastExcepts), + ('cEigrpCRpkts', eigrp_if.cEigrpCRpkts), + ('cEigrpAcksSuppressed', eigrp_if.cEigrpAcksSuppressed), + ('cEigrpRetransSent', eigrp_if.cEigrpRetransSent), + ('cEigrpOOSrvcd', eigrp_if.cEigrpOOSrvcd), + ]: + yield Metric(name=f'cisco_eigrp_interface_{key}', value=value) + + +########################################################################### +# +# CHECK info +# +########################################################################### + + +register.snmp_section( + name='cisco_eigrp_interface', + parse_function=parse_cisco_eigrp_interface, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.5.1.1', # CISCO-TRUSTSEC-MIB::ctsEnvironmentDataObjects + oids=[ + OIDEnd(), # AS number and interface index [0] (u'65536.10.1') + '3', # cEigrpPeerCount [1] + '4', # cEigrpXmitReliableQ [2] + '5', # cEigrpXmitUnreliableQ [3] + '6', # cEigrpMeanSrtt [4] + '10', # cEigrpPendingRoutes [5] + '11', # cEigrpHelloInterval [6] + '13', # cEigrpUMcasts [7] + '14', # cEigrpRMcasts [8] + '15', # cEigrpUUcasts [9] + '16', # cEigrpRUcasts [10] + '17', # cEigrpMcastExcepts [11] + '18', # cEigrpCRpkts [12] + '19', # cEigrpAcksSuppressed [13] + '20', # cEigrpRetransSent [14] + '21', # cEigrpOOSrvcd [15] + '22', # cEigrpAuthMode [16] + '23', # cEigrpAuthKeyChain [17] + # '7', # cEigrpPacingReliable [] + # '8', # cEigrpPacingUnreliable [] + # '9', # cEigrpMFlowTimer [] + # '12', # cEigrpXmitNextSerial [] + ] + ), + SNMPTree( + base='.1.3.6.1.2.1.2.2.1', # + oids=[ + '1', # ifIndex + '2', # ifDescr + '3', # ifType + ] + ), + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.1.1.1', # + oids=[ + OIDEnd(), # VRF ID + '2', # cEigrpVpnName [0] + ] + ), + ], + detect=all_of( + contains('.1.3.6.1.2.1.1.1.0', 'cisco'), # sysDescr + exists('.1.3.6.1.4.1.9.9.449.1.5.1.1.3.*'), # CISCO-EIGRP-MIB::cEigrpPeerCount + )) + +register.check_plugin( + name='cisco_eigrp_interface', + service_name='EIGRP interface %s', + discovery_function=discovery_cisco_eigrp_interface, + check_function=check_cisco_eigrp_interface, + check_default_parameters={ + 'ignore_interfaces_auth': [24, ], # Loopback + 'no_auth_state': 2, + 'md5_auth_state': 1, + }, + check_ruleset_name='cisco_eigrp_interface', +) diff --git a/agent_based/cisco_eigrp_peers.py b/agent_based/cisco_eigrp_peers.py new file mode 100644 index 0000000000000000000000000000000000000000..4183fb412389a5e6c57809716790ae623d96e210 --- /dev/null +++ b/agent_based/cisco_eigrp_peers.py @@ -0,0 +1,361 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-17-20 +# +# Monitor status of Cisco EIGRP peers +# +# 2018-02-11: removed unnecessary OIDs +# 2018-07-26: code cleanup, removed hold time from infotext (it is the actual time, not the configured value) +# 2018-08-06: modified scan function +# 2019-07-01: fixed uptime for peers up for more then 1 year... +# 2019-10-15: added initial support for IPv6, code cleanup (parser function) +# 2019-10-16: added VRF support, fixed ipv4 address rendering +# 2021-08-02: rewritten for CMK 2.0 +# +# ToDo: state_peer_not_found, alias, min_uptime_levels in WATO +# +# snmpwalk sample +# +# thl@surfbox-ii:~$ snmpwalk -v2c -c router-01 -ObentU simulant .1.3.6.1.4.1.9.9.449.1.4.1.1 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.2.65536.10.1 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.2.65536.10.2 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.2.65536.10.3 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.3.65536.10.1 = Hex-STRING: 0A A7 DD 3A # can be also in the form of "10.10.10.10" :-( +# .1.3.6.1.4.1.9.9.449.1.4.1.1.3.65536.10.2 = Hex-STRING: 0A A7 DD 39 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.3.65536.10.3 = Hex-STRING: 0A A7 DD 3C +# .1.3.6.1.4.1.9.9.449.1.4.1.1.4.65536.10.1 = INTEGER: 9 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.4.65536.10.2 = INTEGER: 9 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.4.65536.10.3 = INTEGER: 9 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.5.65536.10.1 = Gauge32: 2 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.5.65536.10.2 = Gauge32: 2 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.5.65536.10.3 = Gauge32: 2 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.6.65536.10.1 = STRING: "01:05:33" +# .1.3.6.1.4.1.9.9.449.1.4.1.1.6.65536.10.2 = STRING: "01:06:06" +# .1.3.6.1.4.1.9.9.449.1.4.1.1.6.65536.10.3 = STRING: "01:05:57" +# .1.3.6.1.4.1.9.9.449.1.4.1.1.7.65536.10.1 = Gauge32: 469 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.7.65536.10.2 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.7.65536.10.3 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.8.65536.10.1 = Gauge32: 2814 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.8.65536.10.2 = Gauge32: 100 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.8.65536.10.3 = Gauge32: 100 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.9.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.9.65536.10.2 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.9.65536.10.3 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.10.65536.10.1 = Gauge32: 30 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.10.65536.10.2 = Gauge32: 33 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.10.65536.10.3 = Gauge32: 24 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.11.65536.10.1 = STRING: "20.0/2.0" +# .1.3.6.1.4.1.9.9.449.1.4.1.1.11.65536.10.2 = STRING: "20.0/2.0" +# .1.3.6.1.4.1.9.9.449.1.4.1.1.11.65536.10.3 = STRING: "20.0/2.0" +# .1.3.6.1.4.1.9.9.449.1.4.1.1.12.65536.10.1 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.12.65536.10.2 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.12.65536.10.3 = Counter32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.13.65536.10.1 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.13.65536.10.2 = Gauge32: 0 +# .1.3.6.1.4.1.9.9.449.1.4.1.1.13.65536.10.3 = Gauge32: 0 +# +# sample info +# [ +# [ +# [u'65536.10.0', u'1', u'\n\xa7\xdd7', u'10', u'2', u'01:05:34', u'1', u'100', u'0', u'147', u'23.0/2.0', u'0', u'0'] +# ], +# [ +# [u'1', u'FastEthernet0', u'6'], +# [u'2', u'FastEthernet1', u'6'], +# [u'3', u'FastEthernet2', u'6'], +# [u'4', u'FastEthernet3', u'6'], +# [u'5', u'FastEthernet4', u'6'], +# [u'6', u'VoIP-Null0', u'1'], +# [u'7', u'Null0', u'1'], +# [u'8', u'Vlan1', u'53'], +# [u'9', u'Loopback0', u'24'], +# [u'10', u'Tunnel100', u'131'] +# ] +# ] +# + +import re +from dataclasses import dataclass +from typing import List, Dict + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + Result, + check_levels, + State, + SNMPTree, + all_of, + contains, + exists, + OIDEnd, + Metric, + render, +) +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + + +@dataclass +class EigrpPeer: + cEigrpPeerAS: str + cEigrpPeerAddr: str + cEigrpUpTimeSeconds: int + cEigrpSrtt: int + cEigrpRto: int + cEigrpPktsEnqueued: int + cEigrpRetrans: int + cEigrpRetries: int + cEigrpHoldTime: int + cEigrpVrfName: str + cEigrpVrfId: int + cEigrpAddrFammily: str + PeerInterface: str + + +_InetAddressType = { + 0: 'unknown', + 1: 'ipv4', + 2: 'ipv6', + 3: 'ipv4z', + 4: 'ipv6z', + 16: 'dns', +} + + +def _render_ip4_address(bytestring: str) -> str: + if len(bytestring) == 4: # byte sting length = 4 bytes + return ".".join(["%s" % ord(m) for m in bytestring]) + elif len(bytestring) >= 7: # ipv4 address > 4 octets + 3 dots + return bytestring + + +def _shorten_ipv6_adress(address: str) -> str: + address = address.split(':') + span = 2 + address = [''.join(address[i:i + span]) for i in range(0, len(address), span)] + for m in range(0, len(address)): + address[m] = re.sub(r'^0{1,3}', r'', address[m]) + address = ':'.join(address) + zeros = ':0:0:0:0:0:0:' + while not zeros == '': + if zeros in address: + address = re.sub(r'%s' % zeros, r'::', address) + zeros = '' + else: + zeros = zeros[:-2] + if address == '0::0': + address = '::' + + return address + + +def _render_ipv6_address(bytestring: str) -> str: + address = ":".join(["%02s" % hex(ord(m))[2:] for m in bytestring]).replace(' ', '0').upper() + address = _shorten_ipv6_adress(address) + + return address + + +def _get_uptime(uptimestr: str) -> int: + uptime_in_sec = 0 + if 'y' in uptimestr and 'w' in uptimestr: + uptimestr = uptimestr.split('y') + uptime_in_sec = int(uptimestr[0]) * 31536000 # 365 * 24 * 3600, one year + uptime_in_sec += int(uptimestr[1][:-1]) * 604800 # 7 * 24 * 3600, one week + if 'w' in uptimestr and 'd' in uptimestr: + uptimestr = uptimestr.split('w') + uptime_in_sec = int(uptimestr[0]) * 604800 # 7 * 24 * 3600, one week + uptime_in_sec += int(uptimestr[1][:-1]) * 86400 # 24 * 3600, on day + elif 'd' in uptimestr and 'h' in uptimestr: + uptimestr = uptimestr.split('d') + uptime_in_sec = int(uptimestr[0]) * 86400 # 24 * 3600, one day + uptime_in_sec += int(uptimestr[1][:-1]) * 3600 + elif ':' in uptimestr: + uptime_in_sec = uptimestr.split(':') + if len(uptime_in_sec) == 3: # [19:20:00] hours:minutes:seconds + uptime_in_sec = (int(uptime_in_sec[0]) * 3600) + (int(uptime_in_sec[1]) * 60) + int(uptime_in_sec[2]) + elif len(uptime_in_sec) == 4: # [10:19:20:00] days(?):hours:minutes:seconds + uptime_in_sec = (int(uptime_in_sec[0]) * 86400) + \ + (int(uptime_in_sec[1]) * 3600) + \ + (int(uptime_in_sec[2]) * 60) + \ + int(uptime_in_sec[3]) + + return uptime_in_sec + +########################################################################### +# +# DATA Parser function +# +########################################################################### + + +def parse_cisco_eigrp_peers(string_table: List[StringTable]) -> Dict[str, EigrpPeer]: + peers, peer_interfaces, VrfInfo = string_table + PeerTable = {} + + for peer in peers: + OID_END, cEigrpPeerAddrType, cEigrpPeerAddr, cEigrpPeerIfIndex, cEigrpHoldTime, cEigrpUpTime, cEigrpSrtt, \ + cEigrpRto, cEigrpPktsEnqueued, cEigrpRetrans, cEigrpRetries = peer + + cEigrpVrfId = int(OID_END.split('.')[0]) + cEigrpPeerAS = OID_END.split('.')[1] + cEigrpAddrFammily = int(OID_END.split('.')[2]) + if int(cEigrpPeerAddrType) == 1: # IPv4 address + cEigrpPeerAddr = _render_ip4_address(cEigrpPeerAddr) + elif int(cEigrpPeerAddrType) == 2: # IPv4 address + cEigrpPeerAddr = _render_ipv6_address(cEigrpPeerAddr) + + PeerInterface = '' + for ifIndex, ifDescr, ifType in peer_interfaces: + if int(cEigrpPeerIfIndex) == int(ifIndex): + PeerInterface = ifDescr + + cEigrpVrfName = '' + for VrfId, VrfName in VrfInfo: + if int(VrfId) == cEigrpVrfId: + cEigrpVrfName = VrfName + + if cEigrpAddrFammily == 2: + cEigrpAddrFammily = 'IPv6' + else: + cEigrpAddrFammily = 'IPv4' + + if cEigrpVrfName == 'default': + ServiceText = f'{cEigrpPeerAddr} on AS {cEigrpPeerAS}' + else: + ServiceText = f'{cEigrpPeerAddr} on AS {cEigrpPeerAS}, VRF {cEigrpVrfName}' + + PeerTable[ServiceText] = EigrpPeer( + cEigrpPeerAS=cEigrpPeerAS, + cEigrpPeerAddr=cEigrpPeerAddr, + cEigrpUpTimeSeconds=_get_uptime(cEigrpUpTime), + cEigrpSrtt=int(cEigrpSrtt), + cEigrpRto=int(cEigrpRto), + cEigrpPktsEnqueued=int(cEigrpPktsEnqueued), + cEigrpRetrans=int(cEigrpRetrans), + cEigrpRetries=int(cEigrpRetries), + cEigrpHoldTime=int(cEigrpHoldTime), + cEigrpVrfName=cEigrpVrfName, + cEigrpVrfId=cEigrpVrfId, + cEigrpAddrFammily=cEigrpAddrFammily, + PeerInterface=PeerInterface, + ) + + return PeerTable + + +########################################################################### +# +# INVENTORY function +# +########################################################################### + + +def discovery_cisco_eigrp_peers(section: Dict[str, EigrpPeer]) -> DiscoveryResult: + for key in section: + yield Service(item=key) + + +########################################################################### +# +# CHECK function +# +########################################################################### + + +def check_cisco_eigrp_peers(item, params, section: Dict[str, EigrpPeer]) -> CheckResult: + try: + peer = section[item] + except KeyError: + yield Result(state=State.CRIT, summary='Peer not found in SNMP data') + return + + yield from check_levels( + label='Uptime', + value=peer.cEigrpUpTimeSeconds, + metric_name='uptime', + render_func=render.timespan, + levels_lower=params['minuptime'] + ) + + yield Result(state=State.OK, notice=f'On interface: {peer.PeerInterface}') + yield Result(state=State.OK, notice=f'Hold time: {peer.cEigrpHoldTime}') + + for key, value in [ + ('cEigrpPktsEnqueued', peer.cEigrpPktsEnqueued), + ('cEigrpRetrans', peer.cEigrpRetrans), + ('cEigrpRetries', peer.cEigrpRetries), + ('cEigrpSrtt', peer.cEigrpSrtt), + ('cEigrpRto', peer.cEigrpRto), + ]: + yield Metric(name=f'cisco_eigrp_peers_{key}', value=value) + + +########################################################################### +# +# CHECK info +# +########################################################################### + +register.snmp_section( + name='cisco_eigrp_peers', + parse_function=parse_cisco_eigrp_peers, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.4.1.1', # + oids=[ + OIDEnd(), # u'65536.10.0' + '2', # cEigrpPeerAddrType + '3', # cEigrpPeerAddr + '4', # cEigrpPeerIfIndex + '5', # cEigrpHoldTime + '6', # cEigrpUpTime + '7', # cEigrpSrtt + '8', # cEigrpRto + '9', # cEigrpPktsEnqueued + '12', # cEigrpRetrans + '13', # cEigrpRetries + # '10', # cEigrpLastSeq + # '11', # cEigrpVersion + ] + ), + SNMPTree( + base='.1.3.6.1.2.1.2.2.1', # + oids=[ + '1', # ifIndex + '2', # ifDescr + '3', # ifType + ] + ), + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.1.1.1', # + oids=[ + OIDEnd(), # VRF ID + '2', # cEigrpVpnName + ] + ), + ], + detect=all_of( + contains('.1.3.6.1.2.1.1.1.0', 'cisco'), # sysDescr + exists('.1.3.6.1.4.1.9.9.449.1.4.1.1.*'), # CISCO-EIGRP-MIB::cEigrpPeerEntry + )) + +register.check_plugin( + name='cisco_eigrp_peers', + service_name='EIGRP peer %s', + discovery_function=discovery_cisco_eigrp_peers, + check_function=check_cisco_eigrp_peers, + check_default_parameters={ + 'minuptime': (3600, 7200) + }, + check_ruleset_name='cisco_eigrp_peers', +) diff --git a/agent_based/cisco_eigrp_topology_table.py b/agent_based/cisco_eigrp_topology_table.py new file mode 100644 index 0000000000000000000000000000000000000000..73211765ea8f90ad3512157d99d8aea34ec03024 --- /dev/null +++ b/agent_based/cisco_eigrp_topology_table.py @@ -0,0 +1,488 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-17-20 +# +# Monitor status of Cisco EIGRP Topology Table +# +# 2018-02-11: removed unnecessary OIDs +# 2018-08-06: modified scan function +# 2019-10-16: added initial IPv6 support, added parser function +# +# +# snmpwalk sample +# +# OMD[mysite]:~$ snmpwalk -ObentU -v2c -c router-01 simulant .1.3.6.1.4.1.9.9.449.1.3.1.1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.0.0.0.0.0 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.220.0.28 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.220.16.28 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.220.48.30 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.220.249.32 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.220.254.32 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.220.255.32 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.221.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.10.167.222.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.192.168.50.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.5.65536.10.1.4.192.168.55.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.0.0.0.0.0 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.220.0.28 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.220.16.28 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.220.48.30 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.220.249.32 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.220.254.32 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.220.255.32 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.221.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.10.167.222.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.192.168.50.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.6.65536.10.1.4.192.168.55.0.24 = INTEGER: 2 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.0.0.0.0.0 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.220.0.28 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.220.16.28 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.220.48.30 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.220.249.32 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.220.254.32 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.220.255.32 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.221.0.24 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.10.167.222.0.24 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.192.168.50.0.24 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.7.65536.10.1.4.192.168.55.0.24 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.0.0.0.0.0 = Gauge32: 28416 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.220.0.28 = Gauge32: 28416 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.220.16.28 = Gauge32: 2816 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.220.48.30 = Gauge32: 27904 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.220.249.32 = Gauge32: 1915392 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.220.254.32 = Gauge32: 128256 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.220.255.32 = Gauge32: 155904 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.221.0.24 = Gauge32: 1787392 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.10.167.222.0.24 = Gauge32: 3523840 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.192.168.50.0.24 = Gauge32: 2816 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.8.65536.10.1.4.192.168.55.0.24 = Gauge32: 28416 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.0.0.0.0.0 = STRING: "Summary" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.220.0.28 = STRING: "Internal" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.220.16.28 = STRING: "Connected" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.220.48.30 = STRING: "Connected" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.220.249.32 = STRING: "Internal" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.220.254.32 = STRING: "Connected" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.220.255.32 = STRING: "Internal" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.221.0.24 = STRING: "Internal" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.10.167.222.0.24 = STRING: "Connected" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.192.168.50.0.24 = STRING: "Rstatic" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.9.65536.10.1.4.192.168.55.0.24 = STRING: "External" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.0.0.0.0.0 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.220.0.28 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.220.16.28 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.220.48.30 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.220.249.32 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.220.254.32 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.220.255.32 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.221.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.10.167.222.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.192.168.50.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.10.65536.10.1.4.192.168.55.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.0.0.0.0.0 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.220.0.28 = Hex-STRING: 0A A7 DC 31 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.220.16.28 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.220.48.30 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.220.249.32 = Hex-STRING: 0A A7 DE 3A +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.220.254.32 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.220.255.32 = Hex-STRING: 0A A7 DC 31 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.221.0.24 = Hex-STRING: 0A A7 DE 3A +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.10.167.222.0.24 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.192.168.50.0.24 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.11.65536.10.1.4.192.168.55.0.24 = Hex-STRING: 0A A7 DC 31 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.0.0.0.0.0 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.220.0.28 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.220.16.28 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.220.48.30 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.220.249.32 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.220.254.32 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.220.255.32 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.221.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.10.167.222.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.192.168.50.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.12.65536.10.1.4.192.168.55.0.24 = INTEGER: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.0.0.0.0.0 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.220.0.28 = Hex-STRING: 0A A7 DC 31 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.220.16.28 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.220.48.30 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.220.249.32 = Hex-STRING: 0A A7 DE 3A +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.220.254.32 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.220.255.32 = Hex-STRING: 0A A7 DC 31 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.221.0.24 = Hex-STRING: 0A A7 DE 3A +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.10.167.222.0.24 = Hex-STRING: 00 00 00 00 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.192.168.50.0.24 = Hex-STRING: 0A A7 DC 11 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.13.65536.10.1.4.192.168.55.0.24 = Hex-STRING: 0A A7 DC 31 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.0.0.0.0.0 = STRING: "Null0" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.220.0.28 = STRING: "Tunnel10" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.220.16.28 = STRING: "GigabitEthernet0/0/0" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.220.48.30 = STRING: "Tunnel10" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.220.249.32 = STRING: "Tunnel101" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.220.254.32 = STRING: "Loopback0" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.220.255.32 = STRING: "Tunnel10" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.221.0.24 = STRING: "Tunnel101" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.10.167.222.0.24 = STRING: "Tunnel101" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.192.168.50.0.24 = "" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.14.65536.10.1.4.192.168.55.0.24 = STRING: "Tunnel10" +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.0.0.0.0.0 = Gauge32: 2816 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.220.0.28 = Gauge32: 28416 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.220.16.28 = Gauge32: 2816 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.220.48.30 = Gauge32: 27904 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.220.249.32 = Gauge32: 3651840 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.220.254.32 = Gauge32: 128256 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.220.255.32 = Gauge32: 155904 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.221.0.24 = Gauge32: 4035840 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.10.167.222.0.24 = Gauge32: 3523840 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.192.168.50.0.24 = Gauge32: 2816 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.15.65536.10.1.4.192.168.55.0.24 = Gauge32: 28416 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.0.0.0.0.0 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.220.0.28 = Gauge32: 2816 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.220.16.28 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.220.48.30 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.220.249.32 = Gauge32: 128256 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.220.254.32 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.220.255.32 = Gauge32: 128256 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.221.0.24 = Gauge32: 1761792 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.10.167.222.0.24 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.192.168.50.0.24 = Gauge32: 1 +# .1.3.6.1.4.1.9.9.449.1.3.1.1.16.65536.10.1.4.192.168.55.0.24 = Gauge32: 2816 +# +# sample info +# [ +# [u'65536.10.1.4.0.0.0.0.0', u'2', u'2', u'External', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd7', u'Tunnel100'], +# [u'65536.10.1.4.10.167.220.0.28', u'2', u'2', u'Internal', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd7', u'Tunnel100'], +# [u'65536.10.1.4.10.167.220.249.32', u'2', u'2', u'Internal', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd:', u'Tunnel100'], +# [u'65536.10.1.4.10.167.220.252.32', u'2', u'2', u'Internal', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd<', u'Tunnel100'], +# [u'65536.10.1.4.10.167.220.253.32', u'2', u'2', u'Connected', u'1', u'\x00\x00\x00\x00', u'1', u'\x00\x00\x00\x00', u'Loopback0'], +# [u'65536.10.1.4.10.167.220.255.32', u'2', u'2', u'Internal', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd7', u'Tunnel100'], +# [u'65536.10.1.4.10.167.221.0.24', u'2', u'2', u'Connected', u'1', u'\x00\x00\x00\x00', u'1', u'\x00\x00\x00\x00', u'Tunnel100'], +# [u'65536.10.1.4.192.168.57.0.24', u'2', u'2', u'Connected', u'1', u'\x00\x00\x00\x00', u'1', u'\x00\x00\x00\x00', u'Vlan1'], +# [u'65536.10.1.4.192.168.58.0.24', u'2', u'2', u'Internal', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd:', u'Tunnel100'], +# [u'65536.10.1.4.192.168.60.0.24', u'2', u'2', u'Internal', u'1', u'\n\xa7\xdd7', u'1', u'\n\xa7\xdd<', u'Tunnel100'] +# ] +# + + +import re +from dataclasses import dataclass +from typing import Optional, List + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + Result, + State, + SNMPTree, + all_of, + contains, + exists, + OIDEnd, + Metric, +) +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + +_InetAddressType = { + 0: 'unknown', + 1: 'ipv4', + 2: 'ipv6', + 3: 'ipv4z', + 4: 'ipv6z', + 16: 'dns', +} + + +def _render_ip_route(route): # sample: '65536.10.1.4.192.168.55.0.24' + route = route.split('.') + if int(route[2]) == 1: # ipv4 route + masklength + route = '.'.join(route[4:8]) + '/' + route[8] + # 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 + elif int(route[2]) == 2: # IPv6 131072.10.2.16.48.0.0.0.0.0.0.0.0.3.0.3.0.3.0.32.128 + for i in range(4, 20, 1): + route[i] = '%02s' % hex(int(route[i]))[2:] + address = ':'.join(route[4:20]).replace(' ', '0').upper() + route = _shorten_ipv6_adress(address) + '/' + route[20] + else: + route = 'unknown address type' + return route # sample: 192.168.55.0/24 + + +def _render_ip4_address(bytestring): + if len(bytestring) == 4: # byte sting length = 4 bytes + return '.'.join(['%s' % ord(m) for m in bytestring]) + elif len(bytestring) >= 7: # ipv4 address > 4 octets + 3 dots + return bytestring + + +def _shorten_ipv6_adress(address): + address = address.split(':') + span = 2 + address = [''.join(address[i:i + span]) for i in range(0, len(address), span)] + for m in range(0, len(address)): + address[m] = re.sub(r'^0{1,3}', r'', address[m]) + address = ':'.join(address) + zeros = ':0:0:0:0:0:0:' + while not zeros == '': + if zeros in address: + address = re.sub(r'%s' % zeros, r'::', address) + zeros = '' + else: + zeros = zeros[:-2] + if address == '0::0': + address = '::' + return address + + +def _render_ipv6_address(bytestring): + address = ":".join(["%02s" % hex(ord(m))[2:] for m in bytestring]).replace(' ', '0').upper() + address = _shorten_ipv6_adress(address) + + return address + + +########################################################################### +# +# DATA Parser function +# +########################################################################### + + +def parse_cisco_eigrp_topology_table(string_table: List[StringTable]): + TopologieTable = [] + ASTable = {} + Topologie, VrfInfo = string_table + + # 65536.<AS number>.1.4.<network>.<cidr> --> 65536.10.1.4.10.167.220.0.28 + for OID_END, cEigrpActive, cEigrpStuckInActive, cEigrpRouteOriginType, cEigrpRouteOriginAddrType, \ + cEigrpRouteOriginAddr, cEigrpNextHopAddressType, cEigrpNextHopAddress, cEigrpNextHopInterface in Topologie: + + cEigrpVrfId = int(OID_END.split('.')[0]) + cEigrpAS = OID_END.split('.')[1] + cEigrpAddrFammily = int(OID_END.split('.')[2]) + cEigrpRoute = _render_ip_route(OID_END) + + if int(cEigrpRouteOriginAddrType) == 1: # IPv4 + cEigrpRouteOriginAddr = _render_ip4_address(cEigrpRouteOriginAddr) + elif int(cEigrpRouteOriginAddrType) == 2: # IPv6 + cEigrpRouteOriginAddr = _render_ipv6_address(cEigrpRouteOriginAddr) + + if int(cEigrpNextHopAddressType) == 1: # IPv4 + cEigrpNextHopAddress = _render_ip4_address(cEigrpNextHopAddress) + if int(cEigrpNextHopAddressType) == 2: # IPv6 + cEigrpNextHopAddress = _render_ipv6_address(cEigrpNextHopAddress) + + cEigrpVrfName = '' + for VrfId, VrfName in VrfInfo: + if int(VrfId) == cEigrpVrfId: + cEigrpVrfName = VrfName + + if cEigrpAddrFammily == 2: + cEigrpAddrFammily = 'IPv6' + else: + cEigrpAddrFammily = 'IPv4' + + TopologieTable.append({ + 'cEigrpActive': int(cEigrpActive), + 'cEigrpStuckInActive': int(cEigrpStuckInActive), + 'cEigrpRouteOriginType': cEigrpRouteOriginType, + 'cEigrpRouteOriginAddr': cEigrpRouteOriginAddr, + 'cEigrpNextHopAddress': cEigrpNextHopAddress, + 'cEigrpNextHopInterface': cEigrpNextHopInterface, + 'cEigrpVrfName': cEigrpVrfName, + 'cEigrpAddrFammily': cEigrpAddrFammily, + 'cEigrpVrfId': cEigrpVrfId, + 'cEigrpAS': cEigrpAS, + 'cEigrpRoute': cEigrpRoute, + }) + + if cEigrpVrfName == 'default' and cEigrpAddrFammily == 'IPv4': + ASTable.update({cEigrpVrfId: {'ServiceText': cEigrpAS, 'cEigrpVrfId': cEigrpVrfId}}) + elif cEigrpVrfName == 'default' and cEigrpAddrFammily == 'IPv6': + ASTable.update({cEigrpVrfId: {'ServiceText': f'{cEigrpAS} IPv6', 'cEigrpVrfId': cEigrpVrfId}}) + elif cEigrpVrfName != 'default' and cEigrpAddrFammily == 'IPv4': + ASTable.update( + {cEigrpVrfId: {'ServiceText': f'{cEigrpAS} VRF {cEigrpVrfName}', 'cEigrpVrfId': cEigrpVrfId}}) + elif cEigrpVrfName != 'default' and cEigrpAddrFammily == 'IPv6': + ASTable.update({cEigrpVrfId: {'ServiceText': f'{cEigrpAS} IPv6 VRF {cEigrpVrfName}', + 'cEigrpVrfId': cEigrpVrfId}}) + + return [ASTable, TopologieTable] + + +########################################################################### +# +# INVENTORY function +# +########################################################################### + + +def discovery_cisco_eigrp_topology_table(section) -> DiscoveryResult: + ASTable, TopologieTable = section + ASTable = dict(ASTable) + for Key in ASTable.keys(): + ServiceText = ASTable.get(Key).get('ServiceText') + yield Service(item=ServiceText) + + +########################################################################### +# +# CHECK function +# +########################################################################### + + +def check_cisco_eigrp_topology_table(item, params, section) -> CheckResult: + ASTable, TopologieTable = section + ASTable = dict(ASTable) + cEigrpVrfId = '' + for Key in ASTable.keys(): + ServiceText = ASTable.get(Key).get('ServiceText') + if ServiceText == item: + cEigrpVrfId = ASTable.get(Key).get('cEigrpVrfId') + + if cEigrpVrfId != '': + routes = [] + activeroutes = [] + siaroutes = [] + origintypes = { + 'Static_redistributed': 0, + 'Internal': 0, + 'Connected': 0, + 'External': 0, + 'Summary': 0, + 'InetAddress': 0, + } + + for route in TopologieTable: + if route.get('cEigrpVrfId') == cEigrpVrfId: + cEigrpActive = route.get('cEigrpActive') + cEigrpStuckInActive = route.get('cEigrpStuckInActive') + cEigrpRouteOriginType = route.get('cEigrpRouteOriginType') + + # count routes + routes.append(route) + + # count active routes + if cEigrpActive == 1: + activeroutes.append(route) + + # count sia routes + if cEigrpStuckInActive == 1: + siaroutes.append(route) + + # count origin types (Rstatic, Internal, Connected, External, Summary, and so on...) + if cEigrpRouteOriginType == 'Rstatic': + cEigrpRouteOriginType = 'Static_redistributed' + origintype = 0 + if origintypes.get(cEigrpRouteOriginType): + origintype = origintypes.get(cEigrpRouteOriginType) + origintype += 1 + origintypes.update({cEigrpRouteOriginType: origintype}) + + if not len(routes) == 0: + yield Result(state=State.OK, summary=f'Routes in topology table: {len(routes)}') + + if not len(activeroutes) == 0: + if 'activeroutes' not in params.get('nowarnon'): + yield Result(state=State.WARN, notice='Active route found') + for route in activeroutes: + cEigrpRoute = route.get('cEigrpRoute') + cEigrpRouteOriginAddr = route.get('cEigrpRouteOriginAddr') + cEigrpNextHopAddress = route.get('cEigrpNextHopAddress') + cEigrpNextHopInterface = route.get('cEigrpNextHopInterface') + + yield Result( + state=State.OK, + notice=f'Active Route: {cEigrpRoute}, ' + f'originated by {cEigrpRouteOriginAddr} ' + f'on interface: {cEigrpNextHopInterface}, ' + f'next hop: {cEigrpNextHopAddress}' + ) + + if not len(siaroutes) == 0: + if 'siaroutes' not in params.get('nowarnon'): + yield Result(state=State.WARN, notice='Stuck in active (SIA) route found') + + for route in siaroutes: + cEigrpRoute = route.get('cEigrpRoute') + cEigrpRouteOriginAddr = route.get('cEigrpRouteOriginAddr') + cEigrpNextHopAddress = route.get('cEigrpNextHopAddress') + cEigrpNextHopInterface = route.get('cEigrpNextHopInterface') + + yield Result( + state=State.OK, + notice=f'SIA Route: {cEigrpRoute}, ' + f'originated by {cEigrpRouteOriginAddr} ' + f'on interface: {cEigrpNextHopInterface}, ' + f'next hop: {cEigrpNextHopAddress}' + ) + + for key, value in [ + ('activeroutes', len(activeroutes)), + ('siaroutes', len(siaroutes)), + ('routes', len(routes)), + ]: + yield Metric(name=f'cisco_eigrp_topology_table_{key}', value=value) + + # append perfdata for routes by origin type + for origintype in origintypes: + yield Metric(name=f'cisco_eigrp_topology_table_{origintype}', value=origintypes.get(origintype)) + + +########################################################################### +# +# CHECK info +# +########################################################################### + + +register.snmp_section( + name='cisco_eigrp_topology_table', + parse_function=parse_cisco_eigrp_topology_table, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.3.1.1', # + oids=[ + OIDEnd(), # 65536.<AS number>.1.4.<network>.<cidr> --> 65536.10.1.4.10.167.220.0.28 + '5', # cEigrpActive [1] + '6', # cEigrpStuckInActive [2] + '9', # cEigrpRouteOriginType [3] + '10', # cEigrpRouteOriginAddrType [4] + '11', # cEigrpRouteOriginAddr [5] + '12', # cEigrpNextHopAddressType [6] + '13', # cEigrpNextHopAddress [7] + '14', # cEigrpNextHopInterface [8] + # '7', # cEigrpDestSuccessors [] + # '8', # cEigrpFdistance [] + # '16', # cEigrpReportDistance [] + # '15', # cEigrpDistance [] + ] + ), + SNMPTree( + base='.1.3.6.1.4.1.9.9.449.1.1.1.1', # + oids=[ + OIDEnd(), # VRF ID + '2', # cEigrpVpnName [0] + ] + ) + ], + detect=all_of( + contains('.1.3.6.1.2.1.1.1.0', 'cisco'), # sysDescr + exists('.1.3.6.1.4.1.9.9.449.1.3.1.1.*'), # CISCO-EIGRP-MIB::cEigrpTopoEntry + )) + +register.check_plugin( + name='cisco_eigrp_topology_table', + service_name='EIGRP topology table AS %s', + discovery_function=discovery_cisco_eigrp_topology_table, + check_function=check_cisco_eigrp_topology_table, + check_default_parameters={ + 'nowarnon': []}, + check_ruleset_name='cisco_eigrp_topology_table', +) diff --git a/cisco_eigrp.mkp b/cisco_eigrp.mkp index 659dae5c9257e331f6d973a414774dfae0955734..dfcb2748b97ed2902a71a4be6a6fca09644671a3 100644 Binary files a/cisco_eigrp.mkp and b/cisco_eigrp.mkp differ diff --git a/packages/cisco_eigrp b/packages/cisco_eigrp index 627b2d40eef8a7d7257fe82e5c38515e622ae773..76361d47aede76e652ce192cfa19374a9e60a4ff 100644 --- a/packages/cisco_eigrp +++ b/packages/cisco_eigrp @@ -1,17 +1,26 @@ -{'author': u'Th.L. (thl-cmk[at]outlook[dot]com)', - 'description': u'Monitor Cisco EIGRP. Checks:\n - cisco_eigrp_peers: creates one service for the every IPv4/IPV6 peer, AS and VRF\n - cisco_eigrp_as_info: creates one service per autonomous system (AS)\n - cisco_eigrp_interface: creates one service per EIGRP enabled interface and AS\n - cisco_eigrp_topology_table: creates one service per topology table, AS and VRF\n', +{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)', + 'description': 'Monitor Cisco EIGRP. Checks:\n' + ' - cisco_eigrp_peers: creates one service for the every ' + 'IPv4/IPV6 peer, AS and VRF\n' + ' - cisco_eigrp_as_info: creates one service per autonomous ' + 'system (AS)\n' + ' - cisco_eigrp_interface: creates one service per EIGRP ' + 'enabled interface and AS\n' + ' - cisco_eigrp_topology_table: creates one service per ' + 'topology table, AS and VRF\n', 'download_url': 'https://thl-cmk.hopto.org', - 'files': {'checks': ['cisco_eigrp_peers', - 'cisco_eigrp_as_info', - 'cisco_eigrp_interface', - 'cisco_eigrp_topology_table'], + 'files': {'agent_based': ['cisco_eigrp_as_info.py', + 'cisco_eigrp_interface.py', + 'cisco_eigrp_peers.py', + 'cisco_eigrp_topology_table.py'], 'web': ['plugins/wato/cisco_eigrp_peers.py', 'plugins/wato/cisco_eigrp_interface.py', 'plugins/wato/cisco_eigrp_topology_table.py', 'plugins/metrics/cisco_eigrp.py']}, 'name': 'cisco_eigrp', 'num_files': 8, - 'title': u'Cisco EIGRP checks', - 'version': '20191021v.0.2a', - 'version.min_required': '1.2.8b8', - 'version.packaged': '1.4.0p35'} \ No newline at end of file + 'title': 'Cisco EIGRP checks', + 'version': '20210803v.0.3', + 'version.min_required': '2.0.0', + 'version.packaged': '2021.07.14', + 'version.usable_until': None} \ No newline at end of file diff --git a/web/plugins/metrics/cisco_eigrp.py b/web/plugins/metrics/cisco_eigrp.py index a572e40f2581abf2b15780931c431ff56b93741e..f2b52d02866086153e91082c3ce739211ea1753f 100644 --- a/web/plugins/metrics/cisco_eigrp.py +++ b/web/plugins/metrics/cisco_eigrp.py @@ -1,49 +1,25 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # -# Cisco EIGRP Peer metrics plugin +# License: GNU General Public License v2 # -# Author: Th.L. +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org # Date : 2017-12-26 # -# replaces : -# local/share/check_mk/pnp-templates/check_mk-cisco_eigrp_peers.php -# local/share/check_mk/web/plugins/perfometer/cisco_eigrp_peers.py +# Cisco EIGRP Peer metrics plugin # # missing a way to include hostname and service description # -# key a green 11/a 21/a 31/a 41/a 12/a 22/a 32/a 42/a -colors_a = ['#80F000', '#a500ff', '#ffc600', '#00ffb2', '#0075ff', '#cc00ff', '#ffd600', '#00ffff', '#0047ff', - # 13/a 23/a 33/a 43/a 14/a 24/a 34/a 44/a 15/a - '#f900ff', '#ffed00', '#00e8ff', '#000aff', '#ff4c00', '#e2ff00', '#00d1ff', '#4200ff', '#ff7a00', - # 25/a 35/a 45/a 16/a 26/a 36/a 46/a 51/a 52/a - '#bcff00', '#00b2ff', '#6000ff', '#ffa000', '#7fff00', '#0093ff', '#7f00ff', '#7f7f7f', '#7f4a26', - # 53/a - '#8c531c'] -# key b green 11/b 21/b 31/b 41/b 12/b 22/b 32/b 42/b -colors_b = ['#80F000', '#c966ff', '#cc9f00', '#00cc8e', '#66acff', '#e066ff', '#ccab00', '#00cccc', '#6690ff', - # 13/b 23/b 33/b 43/b 14/b 24/b 34/b 44/b 15/b - '#fb66ff', '#ccbd00', '#00b9cc', '#666cff', '#ff9366', '#b5cc00', '#00a7cc', '#8d66ff', '#ffaf66', - # 25/b 35/b 45/b 16/b 26/b 36/b 46/b 51/b 52/b - '#96cc00', '#008ecc', '#a066ff', '#ffc666', '#66cc00', '#0076cc', '#b266ff', '#7f7f7f', '#7f5f49', - # 53/b - '#8c6a48'] - - -# def eigrp_render_uptime(uptime): # expects time in seconds -# m, s = divmod(uptime, 60) # break in seconds / minutes -# h, m = divmod(m, 60) # break in mintes / hours -# if h >= 24: # more then one day -# d, h = divmod(h, 24) # break in hours / days -# else: -# return '%02d:%02d:%02d' % (h, m, s) -# if d >= 365: # more the one year -# y, d = divmod(d, 365) # break in days / years -# return '%dy %dd %02d:%02d:%02d' % (y, d, h, m, s) -# else: -# return '%dd %02d:%02d:%02d' % (d, h, m, s) +from cmk.gui.i18n import _ +from cmk.gui.plugins.metrics import ( + metric_info, + graph_info, + perfometer_info, + unit_info, +) ##################################################################################################################### # @@ -52,12 +28,6 @@ colors_b = ['#80F000', '#c966ff', '#cc9f00', '#00cc8e', '#66acff', '#e066ff', '# ##################################################################################################################### -# unit_info['uptime'] = { -# 'title': _('Uptime'), -# 'description': _('Timespan or Duration in seconds'), -# 'symbol': _('s'), -# 'render': lambda v: eigrp_render_uptime(v), -# } unit_info['milliseconds'] = { 'title': _('Milliseconds'), 'symbol': 'ms', @@ -65,72 +35,6 @@ unit_info['milliseconds'] = { 'stepping': 'integer', # for vertical graph labels } - -###################################################################################################################### -# -# map eigrp perfdata to metric, not really necessary but makes sure to use the right metrics -# -###################################################################################################################### - - -check_metrics['check_mk-cisco_eigrp_peers'] = { - 'cEigrpUpTime' : {'name': 'cisco_eigrp_peers_cEigrpUpTime', }, - 'cEigrpRetrans' : {'name': 'cisco_eigrp_peers_cEigrpRetrans', }, - 'cEigrpRetries' : {'name': 'cisco_eigrp_peers_cEigrpRetries', }, - 'cEigrpSrtt' : {'name': 'cisco_eigrp_peers_cEigrpSrtt', }, - 'cEigrpRto' : {'name': 'cisco_eigrp_peers_cEigrpRto', }, - 'cEigrpPktsEnqueued': {'name': 'cisco_eigrp_peers_cEigrpPktsEnqueued'} -} - -check_metrics['check_mk-cisco_eigrp_interface'] = { - 'cEigrpPeerCount' : {'name': 'cisco_eigrp_interface_cEigrpPeerCount', }, - 'cEigrpXmitReliableQ' : {'name': 'cisco_eigrp_interface_cEigrpXmitReliableQ', }, - 'cEigrpXmitUnreliableQ': {'name': 'cisco_eigrp_interface_cEigrpXmitUnreliableQ', }, - 'cEigrpMeanSrtt' : {'name': 'cisco_eigrp_interface_cEigrpMeanSrtt', }, - 'cEigrpPendingRoutes' : {'name': 'cisco_eigrp_interface_cEigrpPendingRoutes', }, - 'cEigrpRMcasts' : {'name': 'cisco_eigrp_interface_cEigrpRMcasts', }, - 'cEigrpUMcasts' : {'name': 'cisco_eigrp_interface_cEigrpUMcasts', }, - 'cEigrpUUcasts' : {'name': 'cisco_eigrp_interface_cEigrpUUcasts', }, - 'cEigrpRUcasts' : {'name': 'cisco_eigrp_interface_cEigrpRUcasts', }, - 'cEigrpMcastExcepts' : {'name': 'cisco_eigrp_interface_cEigrpMcastExcepts', }, - 'cEigrpCRpkts' : {'name': 'cisco_eigrp_interface_cEigrpCRpkts', }, - 'cEigrpAcksSuppressed' : {'name': 'cisco_eigrp_interface_cEigrpAcksSuppressed', }, - 'cEigrpRetransSent' : {'name': 'cisco_eigrp_interface_cEigrpRetransSent', }, - 'cEigrpOOSrvcd' : {'name': 'cisco_eigrp_interface_cEigrpOOSrvcd', }, -} - -check_metrics['check_mk-cisco_eigrp_topology_table'] = { - 'Internal' : {'name': 'cisco_eigrp_topology_table_Internal', }, - 'Connected' : {'name': 'cisco_eigrp_topology_table_Connected', }, - 'External' : {'name': 'cisco_eigrp_topology_table_External', }, - 'Summary' : {'name': 'cisco_eigrp_topology_table_Summary', }, - 'Static_redistributed': {'name': 'cisco_eigrp_topology_table_Static_redistributed', }, - 'InetAddress' : {'name': 'cisco_eigrp_topology_table_Inetaddress', }, - 'activeroutes' : {'name': 'cisco_eigrp_topology_table_activeroutes', }, - 'siaroutes' : {'name': 'cisco_eigrp_topology_table_siaroutes', }, - 'routes' : {'name': 'cisco_eigrp_topology_table_routes', }, -} - -check_metrics['check_mk-cisco_eigrp_as_info'] = { - 'cEigrpNbrCount' : {'name': 'cisco_eigrp_as_info_cEigrpNbrCount', }, - 'cEigrpHellosSent' : {'name': 'cisco_eigrp_as_info_cEigrpHellosSent', }, - 'cEigrpHellosRcvd' : {'name': 'cisco_eigrp_as_info_cEigrpHellosRcvd', }, - 'cEigrpUpdatesSent' : {'name': 'cisco_eigrp_as_info_cEigrpUpdatesSent', }, - 'cEigrpUpdatesRcvd' : {'name': 'cisco_eigrp_as_info_cEigrpUpdatesRcvd', }, - 'cEigrpQueriesSent' : {'name': 'cisco_eigrp_as_info_cEigrpQueriesSent', }, - 'cEigrpQueriesRcvd' : {'name': 'cisco_eigrp_as_info_cEigrpQueriesRcvd', }, - 'cEigrpRepliesSent' : {'name': 'cisco_eigrp_as_info_cEigrpRepliesSent', }, - 'cEigrpRepliesRcvd' : {'name': 'cisco_eigrp_as_info_cEigrpRepliesRcvd', }, - 'cEigrpAcksSent' : {'name': 'cisco_eigrp_as_info_cEigrpAcksSent', }, - 'cEigrpAcksRcvd' : {'name': 'cisco_eigrp_as_info_cEigrpAcksRcvd', }, - 'cEigrpInputQHighMark' : {'name': 'cisco_eigrp_as_info_cEigrpInputQHighMark', }, - 'cEigrpInputQDrops' : {'name': 'cisco_eigrp_as_info_cEigrpInputQDrops', }, - 'cEigrpSiaQueriesSent' : {'name': 'cisco_eigrp_as_info_cEigrpSiaQueriesSent', }, - 'cEigrpSiaQueriesRcvd' : {'name': 'cisco_eigrp_as_info_cEigrpSiaQueriesRcvd', }, - 'cEigrpTopoRoutes' : {'name': 'cisco_eigrp_as_info_cEigrpTopoRoutes', }, - 'cEigrpXmitPendReplies': {'name': 'cisco_eigrp_as_info_cEigrpXmitPendReplies', }, -} - ##################################################################################################################### # # define metrics for eigrp peer perfdata @@ -140,34 +44,34 @@ check_metrics['check_mk-cisco_eigrp_as_info'] = { # define metrics for cisco_eigrp_peer perfdata metric_info['cisco_eigrp_peers_cEigrpUpTime'] = { - 'title' : _('Peer uptime'), - 'unit' : 's', - 'color' : colors_a[0], + 'title': _('Peer uptime'), + 'unit': 's', + 'color': '26/a', } metric_info['cisco_eigrp_peers_cEigrpPktsEnqueued'] = { - 'title' : _('Packets enqueued'), - 'unit' : 'count', - 'color' : colors_a[1], + 'title': _('Packets enqueued'), + 'unit': 'count', + 'color': '11/a', } metric_info['cisco_eigrp_peers_cEigrpRetrans'] = { - 'title' : _('Retransmissions'), - 'unit' : 'count', - 'color' : colors_a[2], + 'title': _('Retransmissions'), + 'unit': 'count', + 'color': '21/a', } metric_info['cisco_eigrp_peers_cEigrpRetries'] = { - 'title' : _('Retries'), - 'unit' : 'count', - 'color' : colors_a[3], + 'title': _('Retries'), + 'unit': 'count', + 'color': '31/a', } metric_info['cisco_eigrp_peers_cEigrpSrtt'] = { 'title': _('Smooth round trip time'), - 'unit' : 'milliseconds', - 'color': colors_a[4], + 'unit': 'milliseconds', + 'color': '41/a', } metric_info['cisco_eigrp_peers_cEigrpRto'] = { - 'title' : _('Retransmission timeout'), - 'unit' : 'milliseconds', - 'color' : colors_b[5], + 'title': _('Retransmission timeout'), + 'unit': 'milliseconds', + 'color': '12/a', } # define metrics for cisco_eigrp_interface perfdata @@ -175,72 +79,72 @@ metric_info['cisco_eigrp_peers_cEigrpRto'] = { metric_info['cisco_eigrp_interface_cEigrpPeerCount'] = { 'title': _('Peer count'), 'unit': 'count', - 'color': colors_a[0], + 'color': '26/a', } metric_info['cisco_eigrp_interface_cEigrpXmitReliableQ'] = { 'title': _('Reliable queue length'), 'unit': 'count', - 'color': colors_a[1], + 'color': '11/a', } metric_info['cisco_eigrp_interface_cEigrpXmitUnreliableQ'] = { 'title': _('Unreliable queue length'), 'unit': 'count', - 'color': colors_a[2], + 'color': '21/a', } metric_info['cisco_eigrp_interface_cEigrpMeanSrtt'] = { 'title': _('Average smooth round trip time'), 'unit': 'milliseconds', - 'color': colors_a[3], + 'color': '31/a', } metric_info['cisco_eigrp_interface_cEigrpPendingRoutes'] = { 'title': _('Routing updates awaiting transmission'), 'unit': 'count', - 'color': colors_a[4], + 'color': '41/a', } metric_info['cisco_eigrp_interface_cEigrpRMcasts'] = { 'title': _('Reliable multicasts send'), 'unit': 'count', - 'color': colors_a[5], + 'color': '12/a', } metric_info['cisco_eigrp_interface_cEigrpUMcasts'] = { 'title': _('Unreliable multicasts send'), 'unit': 'count', - 'color': colors_a[6], + 'color': '22/a', } metric_info['cisco_eigrp_interface_cEigrpUUcasts'] = { 'title': _('Unreliable unicasts send'), 'unit': 'count', - 'color': colors_a[7], + 'color': '32/a', } metric_info['cisco_eigrp_interface_cEigrpRUcasts'] = { 'title': _('Reliable unicasts send'), 'unit': 'count', - 'color': colors_a[8], + 'color': '42/a', } metric_info['cisco_eigrp_interface_cEigrpMcastExcepts'] = { 'title': _('Multicast exceptions received'), 'unit': 'count', - 'color': colors_a[9], + 'color': '25/a', } metric_info['cisco_eigrp_interface_cEigrpCRpkts'] = { 'title': _('Conditional-Receive packets'), 'unit': 'count', - 'color': colors_a[10], + 'color': '35/a', } metric_info['cisco_eigrp_interface_cEigrpAcksSuppressed'] = { 'title': _('Suppressed acknowledgements'), 'unit': 'count', - 'color': colors_a[11], + 'color': '45/a', } metric_info['cisco_eigrp_interface_cEigrpRetransSent'] = { 'title': _('Retransmissions send'), 'unit': 'count', - 'color': colors_a[12], + 'color': '16/a', } metric_info['cisco_eigrp_interface_cEigrpOOSrvcd'] = { 'title': _('Out-of-sequence packets received'), 'unit': 'count', - 'color': colors_a[13], + 'color': '26/b', } # define metrics for cisco_eigrp_topology_table perfdata @@ -248,47 +152,47 @@ metric_info['cisco_eigrp_interface_cEigrpOOSrvcd'] = { metric_info['cisco_eigrp_topology_table_routes'] = { 'title': _('All routes'), 'unit': 'count', - 'color': colors_a[0], + 'color': '26/a', } metric_info['cisco_eigrp_topology_table_activeroutes'] = { 'title': _('Active routes'), 'unit': 'count', - 'color': colors_a[1], + 'color': '11/a', } metric_info['cisco_eigrp_topology_table_siaroutes'] = { 'title': _('Stuck in active (SIA) routes'), 'unit': 'count', - 'color': colors_a[2], + 'color': '21/a', } metric_info['cisco_eigrp_topology_table_Connected'] = { 'title': _('Connected'), 'unit': 'count', - 'color': colors_a[3], + 'color': '31/a', } metric_info['cisco_eigrp_topology_table_Internal'] = { - 'title' : _('Internal'), - 'unit' : 'count', - 'color' : colors_a[4], + 'title': _('Internal'), + 'unit': 'count', + 'color': '41/a', } metric_info['cisco_eigrp_topology_table_External'] = { 'title': _('External'), 'unit': 'count', - 'color': colors_a[5], + 'color': '12/a', } metric_info['cisco_eigrp_topology_table_Summary'] = { 'title': _('Summary'), 'unit': 'count', - 'color': colors_a[6], + 'color': '22/a', } metric_info['cisco_eigrp_topology_table_Static_redistributed'] = { - 'title' : _('Static redistributed'), - 'unit' : 'count', - 'color' : colors_a[14], + 'title': _('Static redistributed'), + 'unit': 'count', + 'color': '24/a', } metric_info['cisco_eigrp_topology_table_Inetaddress'] = { 'title': _('Inet address'), 'unit': 'count', - 'color': colors_a[17], + 'color': '15/a', } # define metrics for cisco_eigrp_as_info perfdata @@ -296,87 +200,87 @@ metric_info['cisco_eigrp_topology_table_Inetaddress'] = { metric_info['cisco_eigrp_as_info_cEigrpNbrCount'] = { 'title': _('Neighbour count'), 'unit': 'count', - 'color': colors_a[0], + 'color': '26/a', } metric_info['cisco_eigrp_as_info_cEigrpHellosSent'] = { 'title': _('Hellos send'), 'unit': '1/s', - 'color': colors_a[1], + 'color': '11/a', } metric_info['cisco_eigrp_as_info_cEigrpHellosRcvd'] = { 'title': _('Hellos received'), 'unit': '1/s', - 'color': colors_a[2], + 'color': '21/a', } metric_info['cisco_eigrp_as_info_cEigrpUpdatesSent'] = { 'title': _('Updates send'), 'unit': 'count', - 'color': colors_a[3], + 'color': '31/a', } metric_info['cisco_eigrp_as_info_cEigrpUpdatesRcvd'] = { 'title': _('Updates received'), 'unit': 'count', - 'color': colors_a[4], + 'color': '41/a', } metric_info['cisco_eigrp_as_info_cEigrpQueriesSent'] = { 'title': _('Alternate route queries send'), 'unit': 'count', - 'color': colors_a[5], + 'color': '12/a', } metric_info['cisco_eigrp_as_info_cEigrpQueriesRcvd'] = { 'title': _('Alternate route queries received'), 'unit': 'count', - 'color': colors_a[6], + 'color': '22/a', } metric_info['cisco_eigrp_as_info_cEigrpRepliesSent'] = { 'title': _('Reply packets send'), 'unit': 'count', - 'color': colors_a[7], + 'color': '32/a', } metric_info['cisco_eigrp_as_info_cEigrpRepliesRcvd'] = { 'title': _('Reply packets received'), 'unit': 'count', - 'color': colors_a[8], + 'color': '42/a', } metric_info['cisco_eigrp_as_info_cEigrpAcksSent'] = { 'title': _('Acknowledgements send'), 'unit': 'count', - 'color': colors_a[9], + 'color': '13/a', } metric_info['cisco_eigrp_as_info_cEigrpAcksRcvd'] = { 'title': _('Acknowledgements received'), 'unit': 'count', - 'color': colors_a[10], + 'color': '23/a', } metric_info['cisco_eigrp_as_info_cEigrpInputQHighMark'] = { 'title': _('Highest number of packets in the input queue'), 'unit': 'count', - 'color': colors_a[11], + 'color': '33/a', } metric_info['cisco_eigrp_as_info_cEigrpInputQDrops'] = { 'title': _('Packets dropped from the input queue'), 'unit': 'count', - 'color': colors_a[12], + 'color': '43/a', } metric_info['cisco_eigrp_as_info_cEigrpSiaQueriesSent'] = { 'title': _('Stuck in active (SIA) queries sent'), 'unit': 'count', - 'color': colors_a[13], + 'color': '14/a', } metric_info['cisco_eigrp_as_info_cEigrpSiaQueriesRcvd'] = { 'title': _('Stuck in active (SIA) queries received'), 'unit': 'count', - 'color': colors_a[14], + 'color': '24/a', } metric_info['cisco_eigrp_as_info_cEigrpTopoRoutes'] = { 'title': _('Routes in the topology table'), 'unit': 'count', - 'color': colors_a[15], + 'color': '34/a', } metric_info['cisco_eigrp_as_info_cEigrpXmitPendReplies'] = { 'title': _('Outstanding replies expected to queries send'), 'unit': 'count', - 'color': colors_a[16], + 'color': '44/a', } ###################################################################################################################### @@ -387,55 +291,60 @@ metric_info['cisco_eigrp_as_info_cEigrpXmitPendReplies'] = { # graphs for cisco_eigrp_peer -graph_info.append({ +graph_info['cisco_eigrp_peer_uptime'] = { 'title': _('Uptime'), 'metrics': [ ('cisco_eigrp_peers_cEigrpUpTime', 'area'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_peer_enqued'] = { 'title': _('Packets enqueued'), 'metrics': [ ('cisco_eigrp_peers_cEigrpPktsEnqueued', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_peer_retransmission'] = { 'title': _('Smooth round trip time / retransmission timeout'), 'metrics': [ ('cisco_eigrp_peers_cEigrpSrtt', 'line'), ('cisco_eigrp_peers_cEigrpRto', 'line'), ], -}) -graph_info.append({ +} +graph_info['cisco_eigrp_peer_error'] = { 'title': _('Retransmissions / Retries'), 'metrics': [ ('cisco_eigrp_peers_cEigrpRetrans', 'line'), ('cisco_eigrp_peers_cEigrpRetries', 'line'), ], -}) +} # graphs for cisco_eigrp_as_info -graph_info.append({ +graph_info['cisco_eigrp_as_info_neighbour_count'] = { 'title': _('Neighbour count'), 'metrics': [ ('cisco_eigrp_as_info_cEigrpNbrCount', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_as_info_route_count'] = { 'title': _('Routes in the topology table'), 'metrics': [ ('cisco_eigrp_as_info_cEigrpTopoRoutes', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_as_info_hellos'] = { 'title': _('Hellos send/received'), 'metrics': [ ('cisco_eigrp_as_info_cEigrpHellosSent', 'line'), ('cisco_eigrp_as_info_cEigrpHellosRcvd', '-line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_as_info_packets'] = { 'title': _('Packets send/received'), 'metrics': [ ('cisco_eigrp_as_info_cEigrpQueriesSent', 'line'), @@ -449,51 +358,57 @@ graph_info.append({ ('cisco_eigrp_as_info_cEigrpAcksRcvd', '-line'), ('cisco_eigrp_as_info_cEigrpSiaQueriesRcvd', '-line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_as_info_drops'] = { 'title': _('Input queue drops / Queue hi mark'), 'metrics': [ ('cisco_eigrp_as_info_cEigrpInputQDrops', 'line'), ('cisco_eigrp_as_info_cEigrpInputQHighMark', 'line'), ], -}) +} # graphs for cisco_eigrp_interface -graph_info.append({ +graph_info['cisco_eigrp_interface_peer_count'] = { 'title': _('Peer count'), 'metrics': [ ('cisco_eigrp_interface_cEigrpPeerCount', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_queue_length'] = { 'title': _('Queue length'), 'metrics': [ ('cisco_eigrp_interface_cEigrpXmitReliableQ', 'line'), ('cisco_eigrp_interface_cEigrpXmitUnreliableQ', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_multicasts'] = { 'title': _('Multicasts send'), 'metrics': [ ('cisco_eigrp_interface_cEigrpRMcasts', 'line'), ('cisco_eigrp_interface_cEigrpUMcasts', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_unicasts'] = { 'title': _('Unicasts send'), 'metrics': [ ('cisco_eigrp_interface_cEigrpUUcasts', 'line'), ('cisco_eigrp_interface_cEigrpRUcasts', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_pendinf_routes'] = { 'title': _('Pending Routes'), 'metrics': [ ('cisco_eigrp_interface_cEigrpPendingRoutes', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_packets'] = { 'title': _('Various packets'), 'metrics': [ ('cisco_eigrp_interface_cEigrpMcastExcepts', 'line'), @@ -501,23 +416,25 @@ graph_info.append({ ('cisco_eigrp_interface_cEigrpRetransSent', 'line'), ('cisco_eigrp_interface_cEigrpOOSrvcd', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_rtt'] = { 'title': _('Average smooth round trip time'), 'metrics': [ ('cisco_eigrp_interface_cEigrpMeanSrtt', 'line'), ], -}) -graph_info.append({ +} + +graph_info['cisco_eigrp_interface_ack_suppressed'] = { 'title': _('Suppressed acknowledgements'), 'metrics': [ ('cisco_eigrp_interface_cEigrpAcksSuppressed', 'line'), ], -}) +} # define metrics for cisco_eigrp_topology_table perfdata -graph_info.append({ +graph_info['cisco_eigrp_topology_table_routes'] = { 'title': _('Routes by origin type'), 'metrics': [ ('cisco_eigrp_topology_table_Inetaddress', 'line'), @@ -528,17 +445,24 @@ graph_info.append({ ('cisco_eigrp_topology_table_Connected', 'line'), ('cisco_eigrp_topology_table_routes', 'line'), ], + 'optional_metrics': [ + 'cisco_eigrp_topology_table_Inetaddress', + 'cisco_eigrp_topology_table_Static_redistributed', + 'cisco_eigrp_topology_table_Summary', + 'cisco_eigrp_topology_table_External', + 'cisco_eigrp_topology_table_Internal', + 'cisco_eigrp_topology_table_Connected', + ] # 'range': (0, 'cisco_eigrp_topology_table_routes:max') -}) +} -graph_info.append({ +graph_info['cisco_eigrp_topology_table_active_sia'] = { 'title': _('Stuck in active (SIA) / active routes'), 'metrics': [ ('cisco_eigrp_topology_table_siaroutes', 'line'), ('cisco_eigrp_topology_table_activeroutes', 'line'), ], -}) - +} ###################################################################################################################### # @@ -556,17 +480,17 @@ perfometer_info.append({ # cisco_eigrp_interface send packets perfometer_info.append({ - 'type': 'linear', - 'segments': ['cisco_eigrp_interface_cEigrpPeerCount'], - 'total': 50, - }) + 'type': 'linear', + 'segments': ['cisco_eigrp_interface_cEigrpPeerCount'], + 'total': 50, +}) # cisco_eigrp_topology_table perfometer_info.append({ - 'type': 'linear', - 'segments': ['cisco_eigrp_topology_table_routes'], - 'total': 1000, - }) + 'type': 'linear', + 'segments': ['cisco_eigrp_topology_table_routes'], + 'total': 1000, +}) # cisco_eigrp_as_info perfometer_info.append({ diff --git a/web/plugins/wato/cisco_eigrp_interface.py b/web/plugins/wato/cisco_eigrp_interface.py index 00f8e0b2429bbdc188d79c1dc1700ece41e3d93d..b15a414adffb11491ab9aaf559b951954ace3d61 100644 --- a/web/plugins/wato/cisco_eigrp_interface.py +++ b/web/plugins/wato/cisco_eigrp_interface.py @@ -1,17 +1,31 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-12-27 # # Check_MK cisco_eigrp_peer WATO plugin # -# Author: Th.L. -# Date: 2017-12-27 -# -# -# -# +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Integer, + TextAscii, + Tuple, + MonitoringState, + ListChoice, +) -ignore_interfaces_auth = [ +from cmk.gui.plugins.wato import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersNetworking, +) + +_ignore_interfaces_auth = [ (6, 'Ethernet CSMAD'), (24, 'Loopback'), (53, 'Proprietary Virtual (Cisco VLAN L3)'), @@ -20,19 +34,16 @@ ignore_interfaces_auth = [ (136, 'Layer 3 IP VLAN'), ] -register_check_parameters( - subgroup_networking, - 'cisco_eigrp_interface', - _('Cisco EIGRP interface'), - Dictionary( + +def _parameter_valuespec_cisco_eigrp_interface(): + return Dictionary( help=_(''), elements=[ ('ignore_interfaces_auth', ListChoice( title=_('no warning if EIRGP authentication not configured on selected interface types'), - label=_('no warning if EIRGP authentication not configured on selected interface types'), help=_('no warning if EIRGP authentication not configured on selected interface types'), - choices=ignore_interfaces_auth, + choices=_ignore_interfaces_auth, default_value=[], )), ('no_auth_state', @@ -47,12 +58,21 @@ register_check_parameters( ('md5_auth_state', MonitoringState( title=_('State to report when interface uses MD5 authentication'), - help=_('State if an EIGRP enabled interface uses an MD5 hash as authentication method. Default is warning'), + help=_( + 'State if an EIGRP enabled interface uses an MD5 hash as authentication method. Default is warning'), default_value=1, ), ), ], - ), - TextAscii(title=_('Cisco EIGRP interface')), - match_type='dict', -) + ) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name='cisco_eigrp_interface', + group=RulespecGroupCheckParametersNetworking, + item_spec=lambda: TextAscii(title=_('Cisco EIGRP interface'), ), + match_type='dict', + parameter_valuespec=_parameter_valuespec_cisco_eigrp_interface, + title=lambda: _('Cisco EIGRP interface'), + )) diff --git a/web/plugins/wato/cisco_eigrp_peers.py b/web/plugins/wato/cisco_eigrp_peers.py index 7d44d877323820529f4b21582e2dd0bf8ef0656a..5ed6f97e456753f5fb8f31509a175770329cd2c1 100644 --- a/web/plugins/wato/cisco_eigrp_peers.py +++ b/web/plugins/wato/cisco_eigrp_peers.py @@ -1,35 +1,61 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-12-25 # # Check_MK cisco_eigrp_peer WATO plugin # -# Author: Th.L. -# Date: 2017-12-25 -# -# -# -# -register_check_parameters( - subgroup_networking, - 'cisco_eigrp_peers', - _('Cisco EIGRP peer'), - Dictionary( +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Integer, + TextAscii, + Tuple, +) + +from cmk.gui.plugins.wato import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersNetworking, +) + + +def _parameter_valuespec_cisco_eigrp_peers(): + return Dictionary( help=_(''), elements=[ ('minuptime', - Integer( - help=_('Set the time in seconds, a peer must be up before the peer is considered sable.' - 'If the peer uptime less then X, the check outcome is set to warning.'), - title=_('Minimum uptime for peer. If uptime less, set check outcome to warning. Default is 1 day.'), - default_value=86400, - allow_empty=False, - unit='seconds', - minvalue=1, - ), - ) + Tuple( + title=_('Minimum uptime for peer. Default is 1/2 hours.'), + help=_('Set the time in seconds, a peer must be up before the peer is considered stable.' + 'If the peer uptime less then X, the check outcome is set to warning/critical.'), + elements=[ + Integer(title=_('Warning below'), + unit='seconds', + default_value=7200, + help=_('The uptime in seconds below which a warning state is triggered. Default is 7200s'), + ), + Integer(title=_('Critical below'), + unit='seconds', + default_value=3600, + help=_('The uptime in seconds below which a critical state is triggered. default is 3600s'), + ) + ], + )), ], - ), - TextAscii(title=_('Cisco EIGRP peer')), - match_type='dict', -) \ No newline at end of file + ) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name='cisco_eigrp_peers', + group=RulespecGroupCheckParametersNetworking, + item_spec=lambda: TextAscii(title=_('Cisco EIGRP peer'), ), + match_type='dict', + parameter_valuespec=_parameter_valuespec_cisco_eigrp_peers, + title=lambda: _('Cisco EIGRP peer'), + )) diff --git a/web/plugins/wato/cisco_eigrp_topology_table.py b/web/plugins/wato/cisco_eigrp_topology_table.py index 72e8da23eff841e43194fba52a39b996594736e8..51644c2b1fdf727dcbecc81c9a3c3fed1c136b24 100644 --- a/web/plugins/wato/cisco_eigrp_topology_table.py +++ b/web/plugins/wato/cisco_eigrp_topology_table.py @@ -1,37 +1,54 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- - -# -# Check_MK cisco_eigrp_topology_table WATO plugin -# -# Author: Th.L. -# Date: 2017-12-27 +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # +# License: GNU General Public License v2 + +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2017-12-27 # # +# Check_MK cisco_eigrp_topology_table WATO plugin # +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + ListChoice, + TextAscii, +) -nowarnon = [('siaroutes', 'Stuck in active (SIA) routes'), +from cmk.gui.plugins.wato import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersNetworking, +) + +_nowarnon = [('siaroutes', 'Stuck in active (SIA) routes'), ('activeroutes', 'Active routes')] -register_check_parameters( - subgroup_networking, - 'cisco_eigrp_topology_table', - _('Cisco EIGRP topology table'), - Dictionary( + +def _parameter_valuespec_cisco_eigrp_topology_table(): + return Dictionary( help=_(''), elements=[ ('nowarnon', ListChoice( title=_('no warning if EIRGP SIA/active route found'), - label=_('no warning if EIRGP SIA/active route found'), help=_('no warning if EIRGP Stuck in active (SIA) / active route found'), - choices=nowarnon, + choices=_nowarnon, default_value=[], ), ) ], - ), - TextAscii(title=_('Cisco EIGRP topology table')), - match_type='dict', -) + ) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name='cisco_eigrp_topology_table', + group=RulespecGroupCheckParametersNetworking, + item_spec=lambda: TextAscii(title=_('Cisco EIGRP topology table'), ), + match_type='dict', + parameter_valuespec=_parameter_valuespec_cisco_eigrp_topology_table, + title=lambda: _('Cisco EIGRP topology table'), + )) \ No newline at end of file