[MediaWiki-commits] [Gerrit] operations/puppet[production]: Icinga: add check_bfd check (part 1)

2017-08-03 Thread Ayounsi (Code Review)
Ayounsi has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370103 )

Change subject: Icinga: add check_bfd check (part 1)
..

Icinga: add check_bfd check (part 1)

Still WIP
Follow up from https://gerrit.wikimedia.org/r/#/c/369710/
Needs the MIBs installed in the SNMP MIB path, most likely with 
https://gerrit.wikimedia.org/r/#/c/364753/

Change-Id: I9e5b6d86e196b831793d93dd1e0259e886240b98
---
A modules/nagios_common/files/check_commands/check_bfd
A modules/nagios_common/files/check_commands/check_bfd.cfg
M modules/nagios_common/manifests/commands.pp
3 files changed, 69 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/03/370103/1

diff --git a/modules/nagios_common/files/check_commands/check_bfd 
b/modules/nagios_common/files/check_commands/check_bfd
new file mode 100644
index 000..6727d89
--- /dev/null
+++ b/modules/nagios_common/files/check_commands/check_bfd
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+
+# Icinga check for down BFD sessions.
+# Requires the MIBs: mib-jnx-bfd-exp, mib-jnx-exp, mib-jnx-smi
+# Returns CRITICAL if at least one BFD session is down, OK otherwise.
+#
+# Usage:
+# python3 check_bfd --host HOSTNAME --community COMMUNITY
+#
+# ayou...@wikimedia.org
+
+import argparse
+import ipaddress
+import socket
+import sys
+
+from snimpy.manager import Manager as M
+from snimpy.manager import load
+from socket import inet_ntoa
+
+def main():
+parser = argparse.ArgumentParser()
+parser.add_argument(
+"--host", nargs=1, dest='host', required=True, help="Target hostname")
+parser.add_argument("--community", nargs=1,
+dest='community', required=True, help="SNMP community")
+options = parser.parse_args()
+
+m = M(options.host[0], options.community[0], 2, cache=True)
+
+return_code = 0
+return_message = ''
+up_count = 0
+down_count = 0
+adminDown_count = 0
+
+for index in m.bfdSessState:
+if m.bfdSessAddrType[index] == 1:
+peerIP = ipaddress.IPv4Address(m.bfdSessAddr[index])
+elif m.bfdSessAddrType[index] == 2:
+peerIP = ipaddress.IPv6Address(m.bfdSessAddr[index])
+state = m.bfdSessState[index]
+if state == 2 or state == 3:
+down_count += 1
+return_code = 2
+return_message += 'BFD neighbor ' + str(peerIP) + ' down\n'
+elif state == 4:
+up_count += 1
+elif state == 1:
+adminDown_count += 1
+
+if return_code == 0:
+print('OK:' + ' UP: ' + str(up_count) + ' AdminDown: ' +
+  str(adminDown_count) + ' Down: ' + str(down_count))
+else:
+print('CRIT: Down: ' + str(down_count) + '\n' + return_message)
+
+sys.exit(return_code)
+
+if __name__ == "__main__":
+main()
diff --git a/modules/nagios_common/files/check_commands/check_bfd.cfg 
b/modules/nagios_common/files/check_commands/check_bfd.cfg
new file mode 100644
index 000..a3920fc
--- /dev/null
+++ b/modules/nagios_common/files/check_commands/check_bfd.cfg
@@ -0,0 +1,4 @@
+define command {
+command_namecheck_bfd
+command_line$USER1$/check_bfd --host $HOSTADDRESS$ --community $ARG1$
+}
diff --git a/modules/nagios_common/manifests/commands.pp 
b/modules/nagios_common/manifests/commands.pp
index 20261fe..199173a 100644
--- a/modules/nagios_common/manifests/commands.pp
+++ b/modules/nagios_common/manifests/commands.pp
@@ -31,6 +31,9 @@
 # check_prometheus_metric
 'jq',
 'curl',
+# check_bfd
+'python3-cffi-backend',
+'python3-snimpy',
 ])
 
 file { "${config_dir}/commands":
@@ -42,6 +45,7 @@
 
 nagios_common::check_command { [
 'check_all_memcached.php',
+'check_bfd',
 'check_bgp',
 'check_dsh_groups',
 'check_grafana_alert',

-- 
To view, visit https://gerrit.wikimedia.org/r/370103
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9e5b6d86e196b831793d93dd1e0259e886240b98
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ayounsi 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/puppet[production]: Icinga: add check_bfd check (part 1)

2017-08-02 Thread Ayounsi (Code Review)
Ayounsi has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/369710 )

Change subject: Icinga: add check_bfd check (part 1)
..


Icinga: add check_bfd check (part 1)

Bug: T83992
Change-Id: Id36d7febc47d64f23e4507d8860ba3fcf5d10eb4
---
A modules/icinga/files/mib-jnx-bfd-exp.txt
A modules/icinga/files/mib-jnx-exp.txt
A modules/icinga/files/mib-jnx-smi.txt
M modules/icinga/manifests/plugins.pp
A modules/nagios_common/files/check_commands/check_bfd
A modules/nagios_common/files/check_commands/check_bfd.cfg
M modules/nagios_common/manifests/commands.pp
7 files changed, 1,348 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Ayounsi: Looks good to me, approved
  Dzahn: Looks good to me, but someone else must approve



diff --git a/modules/icinga/files/mib-jnx-bfd-exp.txt 
b/modules/icinga/files/mib-jnx-bfd-exp.txt
new file mode 100644
index 000..6c2189b
--- /dev/null
+++ b/modules/icinga/files/mib-jnx-bfd-exp.txt
@@ -0,0 +1,857 @@
+BFD-STD-MIB DEFINITIONS ::= BEGIN  
+   IMPORTS 
+  MODULE-IDENTITY, OBJECT-TYPE,  
+  Unsigned32, Counter32, Counter64,  
+  NOTIFICATION-TYPE 
+ FROM SNMPv2-SMI-- [RFC2578]
+
+  MODULE-COMPLIANCE, OBJECT-GROUP, 
+  NOTIFICATION-GROUP 
+  FROM SNMPv2-CONF  -- [RFC2580]
+
+  TEXTUAL-CONVENTION, TruthValue, 
+  RowStatus, StorageType, TimeStamp 
+ FROM SNMPv2-TC -- [RFC2579]
+
+  InetAddress, InetAddressType, InetPortNumber 
+ FROM INET-ADDRESS-MIB  -- [RFC3291]
+
+  -- Juniper specific   *** JNX ***
+  jnxBfdExperiment   -- *** JNX ***
+ FROM JUNIPER-EXPERIMENT-MIB -- *** JNX ***
+   ; 
+
+   bfdMIB MODULE-IDENTITY 
+  LAST-UPDATED "200507221200Z"  -- 04 July 2005 12:00:00 EST 
+  ORGANIZATION "IETF" 
+  CONTACT-INFO 
+  "Thomas D. Nadeau 
+   Cisco Systems, Inc. 
+   Email:  tnad...@cisco.com 
+
+   Zafar Ali  
+   Cisco Systems, Inc. 
+   Email:  z...@cisco.com 
+  " 
+  DESCRIPTION 
+  "Bidirectional Forwarding Management Information Base." 
+
+  -- Revision history. 
+  REVISION 
+  "200508221200Z"  -- 04 August 2005 12:00:00 EST 
+  DESCRIPTION 
+  "Initial version. Published as RFC ." -- RFC-editor pls fill 
+-- in 
+   ::= { jnxBfdExperiment 1 }
+
+   -- Top level components of this MIB module. 
+
+   bfdNotifications OBJECT IDENTIFIER ::= { bfdMIB 0 } 
+
+   bfdObjects   OBJECT IDENTIFIER ::= { bfdMIB 1 } 
+
+   bfdConformance   OBJECT IDENTIFIER ::= { bfdMIB 3 } 
+
+   bfdScalarObjects OBJECT IDENTIFIER ::= { bfdObjects 1 } 
+
+
+   --  Textual Conventions 
+
+   BfdSessIndexTC ::= TEXTUAL-CONVENTION 
+  DISPLAY-HINT "d" 
+  STATUScurrent 
+  DESCRIPTION 
+  "An index used to uniquely identify BFD sessions." 
+  SYNTAX Unsigned32 (1..4294967295) 
+
+   BfdInterval ::= TEXTUAL-CONVENTION 
+  STATUScurrent 
+  DESCRIPTION 
+  "The BFD interval delay in microseconds." 
+  SYNTAXUnsigned32 (1..4294967295) 
+
+   BfdDiag ::=  TEXTUAL-CONVENTION 
+  STATUScurrent 
+  DESCRIPTION 
+  "A common BFD diagnostic code." 
+
+  SYNTAX INTEGER { noDiagnostic(1),  
+   controlDetectionTimeExpired(2),  
+   echoFunctionFailed(3),  
+   neighborSignaledSessionDown(4),  
+   forwardingPlaneReset(5), 
+   pathDown(6),  
+   concatenatedPathDown(7), 
+   administrativelyDown(8),  
+   reverseConcatenatedPathDown (9) 
+ } 
+
+--  BFD General Variables 
+
+--  These parameters apply globally to the Router's 
+--  BFD Process. 
+
+   bfdAdminStatus OBJECT-TYPE 
+  SYNTAX   INTEGER { enabled(1), disabled(2) } 
+--  MAX-ACCESS   read-write 
+  MAX-ACCESS   read-only 
+  STATUS   current 
+  DESCRIPTION 
+  "The global administrative status of BFD in this router.  
+   The value 'enabled' denotes that the BFD Process is 
+   active on at least one interface; 'disabled' disables  
+   it on all interfaces." 
+  DEFVAL { enabled }  
+  ::= { bfdScalarObjects 1 } 
+
+   bfdVersionNumber OBJECT-TYPE 
+  SYNTAX   Unsigned32 
+  MAX-ACCESS   read-only 
+  STATUS   current 
+  DESCRIPTION 
+  "The current version number of the BFD protocol." 
+  REFERENCE 

[MediaWiki-commits] [Gerrit] operations/puppet[production]: Icinga: add check_bfd check (part 1)

2017-08-02 Thread Ayounsi (Code Review)
Ayounsi has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/369710 )

Change subject: Icinga: add check_bfd check (part 1)
..

Icinga: add check_bfd check (part 1)

Bug: T83992
Change-Id: Id36d7febc47d64f23e4507d8860ba3fcf5d10eb4
---
A modules/icinga/files/mib-jnx-bfd-exp.txt
A modules/icinga/files/mib-jnx-exp.txt
A modules/icinga/files/mib-jnx-smi.txt
M modules/icinga/manifests/plugins.pp
A modules/nagios_common/files/check_commands/check_bfd
A modules/nagios_common/files/check_commands/check_bfd.cfg
M modules/nagios_common/manifests/commands.pp
7 files changed, 1,348 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/10/369710/1

diff --git a/modules/icinga/files/mib-jnx-bfd-exp.txt 
b/modules/icinga/files/mib-jnx-bfd-exp.txt
new file mode 100644
index 000..6c2189b
--- /dev/null
+++ b/modules/icinga/files/mib-jnx-bfd-exp.txt
@@ -0,0 +1,857 @@
+BFD-STD-MIB DEFINITIONS ::= BEGIN  
+   IMPORTS 
+  MODULE-IDENTITY, OBJECT-TYPE,  
+  Unsigned32, Counter32, Counter64,  
+  NOTIFICATION-TYPE 
+ FROM SNMPv2-SMI-- [RFC2578]
+
+  MODULE-COMPLIANCE, OBJECT-GROUP, 
+  NOTIFICATION-GROUP 
+  FROM SNMPv2-CONF  -- [RFC2580]
+
+  TEXTUAL-CONVENTION, TruthValue, 
+  RowStatus, StorageType, TimeStamp 
+ FROM SNMPv2-TC -- [RFC2579]
+
+  InetAddress, InetAddressType, InetPortNumber 
+ FROM INET-ADDRESS-MIB  -- [RFC3291]
+
+  -- Juniper specific   *** JNX ***
+  jnxBfdExperiment   -- *** JNX ***
+ FROM JUNIPER-EXPERIMENT-MIB -- *** JNX ***
+   ; 
+
+   bfdMIB MODULE-IDENTITY 
+  LAST-UPDATED "200507221200Z"  -- 04 July 2005 12:00:00 EST 
+  ORGANIZATION "IETF" 
+  CONTACT-INFO 
+  "Thomas D. Nadeau 
+   Cisco Systems, Inc. 
+   Email:  tnad...@cisco.com 
+
+   Zafar Ali  
+   Cisco Systems, Inc. 
+   Email:  z...@cisco.com 
+  " 
+  DESCRIPTION 
+  "Bidirectional Forwarding Management Information Base." 
+
+  -- Revision history. 
+  REVISION 
+  "200508221200Z"  -- 04 August 2005 12:00:00 EST 
+  DESCRIPTION 
+  "Initial version. Published as RFC ." -- RFC-editor pls fill 
+-- in 
+   ::= { jnxBfdExperiment 1 }
+
+   -- Top level components of this MIB module. 
+
+   bfdNotifications OBJECT IDENTIFIER ::= { bfdMIB 0 } 
+
+   bfdObjects   OBJECT IDENTIFIER ::= { bfdMIB 1 } 
+
+   bfdConformance   OBJECT IDENTIFIER ::= { bfdMIB 3 } 
+
+   bfdScalarObjects OBJECT IDENTIFIER ::= { bfdObjects 1 } 
+
+
+   --  Textual Conventions 
+
+   BfdSessIndexTC ::= TEXTUAL-CONVENTION 
+  DISPLAY-HINT "d" 
+  STATUScurrent 
+  DESCRIPTION 
+  "An index used to uniquely identify BFD sessions." 
+  SYNTAX Unsigned32 (1..4294967295) 
+
+   BfdInterval ::= TEXTUAL-CONVENTION 
+  STATUScurrent 
+  DESCRIPTION 
+  "The BFD interval delay in microseconds." 
+  SYNTAXUnsigned32 (1..4294967295) 
+
+   BfdDiag ::=  TEXTUAL-CONVENTION 
+  STATUScurrent 
+  DESCRIPTION 
+  "A common BFD diagnostic code." 
+
+  SYNTAX INTEGER { noDiagnostic(1),  
+   controlDetectionTimeExpired(2),  
+   echoFunctionFailed(3),  
+   neighborSignaledSessionDown(4),  
+   forwardingPlaneReset(5), 
+   pathDown(6),  
+   concatenatedPathDown(7), 
+   administrativelyDown(8),  
+   reverseConcatenatedPathDown (9) 
+ } 
+
+--  BFD General Variables 
+
+--  These parameters apply globally to the Router's 
+--  BFD Process. 
+
+   bfdAdminStatus OBJECT-TYPE 
+  SYNTAX   INTEGER { enabled(1), disabled(2) } 
+--  MAX-ACCESS   read-write 
+  MAX-ACCESS   read-only 
+  STATUS   current 
+  DESCRIPTION 
+  "The global administrative status of BFD in this router.  
+   The value 'enabled' denotes that the BFD Process is 
+   active on at least one interface; 'disabled' disables  
+   it on all interfaces." 
+  DEFVAL { enabled }  
+  ::= { bfdScalarObjects 1 } 
+
+   bfdVersionNumber OBJECT-TYPE 
+  SYNTAX   Unsigned32 
+  MAX-ACCESS   read-only 
+  STATUS   current 
+  DESCRIPTION 
+  "The current version number of the BFD protocol." 
+  REFERENCE 
+  " BFD Version 0