diff --git a/checks/cisco_eigrp_topology_table b/checks/cisco_eigrp_topology_table deleted file mode 100644 index 8e0755753eb0aed5a44e1686fff663cf2a872774..0000000000000000000000000000000000000000 --- a/checks/cisco_eigrp_topology_table +++ /dev/null @@ -1,447 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Cisco EIGRP AS info -# -# Author: Th.L. -# 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'] -# ] -# - -factory_settings['cisco_eigrp_topology_table_defaults'] = { - 'nowarnon': [] -} - -########################################################################### -# -# DATA Parser function -# -########################################################################### - - -def parse_cisco_eigrp_topology_table(info): - - 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 - span = 2 - 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 - - TopologieTable = [] - ASTable = {} - Topologie, VrfInfo = info - - # 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': '%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, TopologieTable] - -########################################################################### -# -# INVENTORY function -# -########################################################################### - - -def inventory_cisco_eigrp_topology_table(parsed): - ASTable, TopologieTable = parsed - ASTable = dict(ASTable) - for Key in ASTable.keys(): - ServiceText = ASTable.get(Key).get('ServiceText') - yield ServiceText, {} - - -########################################################################### -# -# CHECK function -# -########################################################################### - -########################################################################### -# -# CHECK function -# -########################################################################### - - -def check_cisco_eigrp_topology_table(item, params, parsed): - ASTable, TopologieTable = parsed - 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 != '': - state = 0 - infotext = '' - longoutput = '' - perfdata = [] - - 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: - state = 0 - infotext = 'Routes in topology table: %s' % (len(routes)) - - if not len(activeroutes) == 0: - if not 'activeroutes' in params.get('nowarnon'): - state = max(1, state) - yield 1, 'Active route found' - for route in activeroutes: - cEigrpRoute = route.get('cEigrpRoute') - cEigrpRouteOriginAddr = route.get('cEigrpRouteOriginAddr') - cEigrpNextHopAddress = route.get('cEigrpNextHopAddress') - cEigrpNextHopInterface = route.get('cEigrpNextHopInterface') - - longoutput += "\nActive Route: %s, originated by %s on interface: %s, next hop: %s" \ - % (cEigrpRoute, cEigrpRouteOriginAddr, cEigrpNextHopInterface, cEigrpNextHopAddress) - - if not len(siaroutes) == 0: - if not 'siaroutes' in params.get('nowarnon'): - state = max(1, state) - yield 1, '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') - - longoutput += "\nSIA Route: %s, originated by %s on interface: %s, next hop: %s" \ - % (cEigrpRoute, cEigrpRouteOriginAddr, cEigrpNextHopInterface, cEigrpNextHopAddress) - - if not state == 0: - infotext += '. See long output!' - - perfdata = [('activeroutes', len(activeroutes)), - ('siaroutes', len(siaroutes)), - ('routes', len(routes), None, None, 0, len(routes)+10), - ] - - # append perfdata for routes by origin type - for origintype in origintypes: - perfdata.append((origintype, origintypes.get(origintype))) - - yield state, infotext + longoutput, perfdata - -########################################################################### -# -# CHECK info -# -########################################################################### - - -check_info['cisco_eigrp_topology_table'] = { - 'check_function' : check_cisco_eigrp_topology_table, - 'inventory_function' : inventory_cisco_eigrp_topology_table, - 'service_description' : 'EIGRP topology table AS %s', - 'has_perfdata' : True, - 'snmp_scan_function' : lambda oid: oid('.1.3.6.1.2.1.1.1.0').lower().find('cisco') != -1 and - oid('.1.3.6.1.4.1.9.9.449.1.3.1.1.*'), # CISCO-EIGRP-MIB::cEigrpTopoEntry - 'group' : 'cisco_eigrp_topology_table', - 'default_levels_variable': 'cisco_eigrp_topology_table_defaults', - 'parse_function' : parse_cisco_eigrp_topology_table, - 'snmp_info' : [('.1.3.6.1.4.1.9.9.449.1.3.1.1', [OID_END, # 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 [] - ]), - ('.1.3.6.1.4.1.9.9.449.1.1.1.1', [OID_END, # VRF ID - '2', # cEigrpVpnName [0] - ]), - ] -}