Module: check_mk
Branch: master
Commit: e02759e00d2db1ba739fe71a6edd25cb5aca91a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e02759e00d2db1…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Fri May 16 08:39:04 2014 +0200
juniper_bgp_state: New Check for BGP status at Juniper Routers
---
.werks/954 | 8 +++++
ChangeLog | 1 +
checkman/juniper_bgp_state | 19 ++++++++++
checks/juniper_bgp_state | 82 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 110 insertions(+)
diff --git a/.werks/954 b/.werks/954
new file mode 100644
index 0000000..4e594ce
--- /dev/null
+++ b/.werks/954
@@ -0,0 +1,8 @@
+Title: juniper_bgp_state: New Check for BGP status at Juniper Routers
+Level: 2
+Component: checks
+Version: 1.2.5i3
+Date: 1400222313
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 89f329f..feeeefd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -46,6 +46,7 @@
* 0160 brocade_vdx_status: New check to monitor the operational state of vdx
switches.
* 0916 if: now able to configure minimum bandwidth limits
* 0917 df checks: now able to show time left until disk full as perfometer and
pnpgraph...
+ * 0954 juniper_bgp_state: New Check for BGP status at Juniper Routers
* 0777 FIX: special agent emcvnx: did not work with security file authentication...
* 0786 FIX: zfsget: fixed compatibility with older Solaris agents...
* 0809 FIX: brocade_fcport: Fixed recently introduced problem with port speed
detection
diff --git a/checkman/juniper_bgp_state b/checkman/juniper_bgp_state
new file mode 100644
index 0000000..9228dfd
--- /dev/null
+++ b/checkman/juniper_bgp_state
@@ -0,0 +1,19 @@
+title: Juniper Routers: BGP Status
+agents: snmp
+catalog: hw/network/juniper
+license: GPL
+distribution: check_mk
+description:
+ Checks the BGP status for the connection to one peer at Juniper Routers.
+
+ If the operational status (jnxBgpM2PeerStatus) is not {running} it returns
+ {WARN} - that means: The connection has probably been shutdown manually.
+ If the operational status is {running} it looks for the state of the
+ connection (jnxBgpM2PeerState). On {established} it returns {OK} and {CRIT}
+ on every other.
+
+item:
+ The IP address of the peer.
+
+inventory:
+ Finds one check for every BGP connection reported by SNMP.
diff --git a/checks/juniper_bgp_state b/checks/juniper_bgp_state
new file mode 100644
index 0000000..a9cf183
--- /dev/null
+++ b/checks/juniper_bgp_state
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+def juniper_bgp_state_create_item(oid_end):
+ return re.sub("6\.1\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.1\.", "",
oid_end)
+
+def inventory_juniper_bgp_state(info):
+ inventory = []
+ for oid_end, bgp_state, bgp_operational_state in info:
+ inventory.append( (juniper_bgp_state_create_item(oid_end), None) )
+ return inventory
+
+def check_juniper_bgp_state(item, _no_params, info):
+ bgp_state_map = [ "undefined", # 0 does not exist
+ "idle", # 1
+ "connect", # 2
+ "active", # 3
+ "opensent", # 4
+ "openconfirm", # 5
+ "established"] # 6
+ bgp_operational_state_map = [ "undefined", # 0 does not exist
+ "halted", # 1
+ "running"] # 2
+ status = 0
+ for oid_end, bgp_state, bgp_operational_state in info:
+ peering_partner_ip = juniper_bgp_state_create_item(oid_end)
+ bgp_state = int(bgp_state)
+ bgp_operational_state = int(bgp_operational_state)
+
+ if peering_partner_ip == item:
+ operational_state_error_string = ""
+ state_error_string = ""
+
+ if bgp_operational_state != 2:
+ status = 1
+ operational_state_error_string = "(!)"
+ elif bgp_state != 6:
+ status = 2
+ state_error_string = "(!!)"
+
+ return status, "Status with peer %s is %s%s, operational status:
%s%s" \
+ % (peering_partner_ip, \
+ bgp_state_map[bgp_state], state_error_string, \
+ bgp_operational_state_map[bgp_operational_state], \
+ operational_state_error_string)
+
+ return 3, "Peering partner %s not configured" % item
+
+check_info["juniper_bgp_state"] = {
+ "check_function" : check_juniper_bgp_state,
+ "inventory_function" : inventory_juniper_bgp_state,
+ "service_description" : "BGP Status Peer %s",
+ "snmp_info" : ('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1', [
OID_END, # take peering partner IP from this
+ 2, #
jnxBgpM2PeerState
+ 3 ]), #
jnxBgpM2PeerStatus
+ # (like
operational status)
+ "snmp_scan_function" : lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.2636.1.1.1.2.90"),
+ "has_perfdata" : False,
+}