Browse Source

icinga2: check_bird_ospf: Don't show neighbor IDs for ptp interfaces.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm 6 years ago
parent
commit
1adf33b2a2
3 changed files with 19 additions and 3 deletions
  1. 4 0
      icinga2/commands.d/network.conf
  2. 13 3
      icinga2/plugins/check_bird_ospf
  3. 2 0
      icinga2/services/network.conf

+ 4 - 0
icinga2/commands.d/network.conf

@@ -39,6 +39,9 @@ object CheckCommand "bird_ospf" {
 		"--ignore_missing_file" = {
 			set_if = "$ignore_missing_file$"
 		}
+		"--no_ptp_ip" = {
+			set_if = "$no_ptp_ip$"
+		}
 	}
 
 	vars.proto = "4"			# IP protocol version to check
@@ -46,6 +49,7 @@ object CheckCommand "bird_ospf" {
 	vars.interfaces_down_ok = ""		# List of interfaces which are OK to have no session. (Space separated list)
 	vars.interfaces_down_ok_file = ""	# List of interfaces which are OK to have no session. (One per line)
 	vars.ignore_missing_file = false	# Ignore a possible non-existent file given as --interfaces_down_ok_file
+	vars.no_ptp_ip = false			# Do not show neighbor IDs for ptp interfaces
 }
 
 object CheckCommand "bird_bgp" {

+ 13 - 3
icinga2/plugins/check_bird_ospf

@@ -33,6 +33,15 @@ def read_interfaces_from_file (file_path, missing_ok):
 	return interfaces
 
 
+def format_peer (ifname, iface_config, peer):
+	global args
+
+	if args.no_ptp_ip and iface_config['Type'] == 'ptp':
+		return ifname
+
+	return "%s/%s" % (ifname, peer)
+
+
 parser = argparse.ArgumentParser (description = 'check bird OSPF sessions')
 
 parser.add_argument ('--proto', '-p', help = 'IP protocol version to check', default = '4', choices = ['4', '6'])
@@ -40,6 +49,7 @@ parser.add_argument ('--protocol', '-P', help = 'Bird OSPF protocol instance nam
 parser.add_argument ('--interfaces_down_ok', metavar = "LIST", help = "List of interfaces which are OK to have no OSPF neighbor. Provide a space separated list.")
 parser.add_argument ('--interfaces_down_ok_file', metavar = "FILENAME", help = "List of interfaces which are OK to have no OSPF neighbor. Provide one interfaces per line.")
 parser.add_argument ('--ignore_missing_file', help = "Ignore a possible non-existent file given as --interfaces_down_ok_file", action = 'store_true')
+parser.add_argument ('--no_ptp_ip', help = "Do not print router ID/IP on ptp interfaces", action = 'store_true')
 
 args = parser.parse_args ()
 
@@ -143,17 +153,17 @@ for line in neighbors_fh.stdout.readlines ():
 
 		# State FULL is awesome.
 		if 'Full' in state:
-			ok.append ("%s/%s" % (ifname, peer))
+			ok.append (format_peer (ifname, interface, peer))
 
 		# In broadcast areas there are only two FULL sessions (to the DR and BDR)
 		# all other sessions will be 2-Way/Other which is perfectly fine.
 		elif state == "2-Way/Other" and interface['Type'] == "broadcast":
-			ok.append ("%s/%s" % (ifname, peer))
+			ok.append (format_peer (ifname, interface, peer))
 
 		# Everything else is considered broken.
 		# Likely some ExStart/* etc. pointing to possible MTU troubles.
 		else:
-			broken.append ("%s/%s:%s" % (ifname, peer, state))
+			broken.append ("%s:%s" % (format_peer (ifname, interface, peer), state))
 
 
 # Check for any interfaces which should have (at least) an OSPF peer

+ 2 - 0
icinga2/services/network.conf

@@ -84,6 +84,7 @@ apply Service "bird_ospf" {
 	check_command = "bird_ospf"
 	vars.interfaces_down_ok_file = "/etc/icinga2/ffho-conf.d/bird_ospf_interfaces_down_ok.txt"
 	vars.ignore_missing_file = true
+	vars.no_ptp_ip = true
 
 	if (host.name != NodeName) {
 		command_endpoint = host.name
@@ -99,6 +100,7 @@ apply Service "bird_ospf6" {
 	vars.proto = "6"
 	vars.interfaces_down_ok_file = "/etc/icinga2/ffho-conf.d/bird_ospf_interfaces_down_ok.txt"
 	vars.ignore_missing_file = true
+	vars.no_ptp_ip = true
 
 	if (host.name != NodeName) {
 		command_endpoint = host.name