This script connects to one or more Cisco Nexus switches running NX-OS software, identifies interfaces that have flapped more than a certain amount, and generates a report indicating which switches and interfaces have flapped the most.
$ python nxos_interface_flap_finder.py 192.0.2.10 192.0.2.20 --interface-flap-floor 1
Input password for user account admin:
+----------------+---------------+-------------+-----------------+
| IP | Hostname | Interface | Number of Flaps |
+----------------+---------------+-------------+-----------------+
| 192.0.2.10 | N5K-C56128P-1 | Ethernet1/3 | 2 |
| 192.0.2.20 | N5K-C56128P-2 | Ethernet1/1 | 1 |
| 192.0.2.20 | N5K-C56128P-2 | Ethernet1/3 | 1 |
| 192.0.2.20 | N5K-C56128P-2 | Ethernet1/5 | 1 |
+----------------+---------------+-------------+-----------------+
This script can be used as a stop-gap measure in place of a more comprehensive syslog aggregation solution. Long-term, users should consider implementing a more robust syslog solution, such as ELK (Elasticsearch, Logstash, and Kibana), Graylog, or Splunk.
This script can be used as shown below:
python nxos_interface_flap_finder.py <switch-1-ip-address-or-fqdn> [switch-2-ip-address-or-fqdn] ... [switch-n-ip-address-or-fqdn] [--username switch-username] [--password switch-password] [--interface-flap-floor 5] [--connect-only]
Required parameters include:
Optional parameters include:
This script requires Python version 3.8 or higher. Consult your operating system's package manager's manual or the Python documentation to determine how to install Python 3.8 or higher on the host where this script will run.
This script can be installed using the instructions below:
git clone https://github.com/ChristopherJHart/nxos_interface_flap_finder.git
cd nxos_interface_flap_finder
python -m venv venv; source venv/bin/activate
pip
:pip install -r requirements.txt
python nxos_interface_flap_finder.py 192.0.2.10 192.0.2.20 --interface-flap-floor 1
In the context of network operations, a "flap" is when a network entity is in a working status, transitions to a non-working status, then transitions to a working status shortly afterwards. The word "bounce" is also sometimes used in place of the word "flap". Both words can be used to describe control plane protocol status, interface status, module or network device status, and so on. For example:
"The OSPF adjacency between the two routers was continuously flapping, causing instability in the network as IPv4 prefixes were rapidly inserted and removed from unicast routing tables."
"One of the DWDM service provider's optical devices encountered hardware failure, degrading the signal in the circuit and causing the interface of our switch to flap. This disrupted network connectivity between sites."
This script associates interface flaps with the "interface resets" counter present in a Nexus switch's interface statistics. An example of this can be found in the show interface
command, as shown below.
switch# show interface
<snip>
Ethernet1/1 is up
Dedicated Interface
Hardware: 1000/10000 Ethernet, address: 00de.fb61.4468 (bia 00de.fb61.4468)
MTU 1500 bytes, BW 10000000 Kbit, DLY 10 usec
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, medium is broadcast
Port mode is access
full-duplex, 10 Gb/s, media type is 10G
Beacon is turned off
Input flow-control is off, output flow-control is off
Rate mode is dedicated
Switchport monitor is off
EtherType is 0x8100
Last link flapped 05:46:22
Last clearing of "show interface" counters never
1 interface resets <<<
30 seconds input rate 344 bits/sec, 0 packets/sec
30 seconds output rate 72 bits/sec, 0 packets/sec
Load-Interval #2: 5 minute (300 seconds)
input rate 200 bps, 0 pps; output rate 136 bps, 0 pps
RX
0 unicast packets 11444 multicast packets 0 broadcast packets
11444 input packets 1031554 bytes
0 jumbo packets 0 storm suppression bytes
0 runts 0 giants 0 CRC 0 no buffer
0 input error 0 short frame 0 overrun 0 underrun 0 ignored
0 watchdog 0 bad etype drop 0 bad proto drop 0 if down drop
0 input with dribble 0 input discard
0 Rx pause
TX
0 unicast packets 1055 multicast packets 0 broadcast packets
1055 output packets 364652 bytes
0 jumbo packets
0 output error 0 collision 0 deferred 0 late collision
0 lost carrier 0 no carrier 0 babble 0 output discard
0 Tx pause
Every network environment is different. Some networks may expect hundreds or thousands of flaps on a regular basis on specific interfaces. For this reason, the --interface-flap-floor
parameter can be used with this script to fine-tune the threshold between normal behavior and abnormal flapping behavior. The default value for this parameter is 5.
Owner
Contributors
Categories
Data CenterNetworkingNetworkingProducts
NX-OSProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community