Ver código fonte

Don't complain about iBGP sessions being down to non "active" neighbors.

  If the status of a potential iBGP neighbor is not "active" (in Netbox),
  it's probably "planned" or "staged" etc. So it's not an issue and even
  more so not an actionable item if the session is down. So instruct the
  check not to complain about it.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 4 anos atrás
pai
commit
f8685b3985
1 arquivos alterados com 25 adições e 5 exclusões
  1. 25 5
      icinga2/bird_ibgp_sessions_down_ok.txt.tmpl

+ 25 - 5
icinga2/bird_ibgp_sessions_down_ok.txt.tmpl

@@ -1,9 +1,29 @@
 #
-# Sessions which are OK to be down in iBGP (Salt managed)
+# BGP sessions which are OK to be down (Salt managed)
 #
-{%- set nodes = salt['pillar.get']('nodes', {}) %}
-{%- for node, node_config in nodes.items ()|sort %}
-  {%- if node_config.get ('status', 'active') != "active" %}
-{{ salt['ffho.re_replace']('[.-]', '_', node) }}
+{#- Gather information for iBGP sessions #}
+{%- set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
+{%- set inactive_peers = [] %}
+{%- for node in salt['pillar.get']('nodes', [])|sort if node != grains['id'] %}
+  {%- set peer_node_config = salt['pillar.get']('nodes:' ~ node) %}
+  {%- set peer_roles = peer_node_config.get ('roles', []) %}
+
+  {#- Skip peer if it ain't no router #}
+  {%- if 'router' not in peer_roles %}
+    {%- continue %}
   {%- endif %}
+
+  {#- Skip peer if neither we nor him are a RR #}
+  {%- if 'routereflector' not in roles and 'routereflector' not in peer_roles %}
+    {%- continue %}
+  {%- endif %}
+
+  {%- if peer_node_config.get ('status', '') not in [ '', 'active' ] %}
+    {#- save peers node name, mangle . and - to _ to make bird happy #}
+    {%- set peer_name = salt['ffho.re_replace']('[.-]', '_', node) %}
+    {%- do inactive_peers.append (peer_name) %}
+  {%- endif %}
+{%- endfor %}
+{% for peer in inactive_peers %}
+{{ peer }}
 {%- endfor %}