lausser / check_nwc_health

nwc = network component. This plugin checks lots of aspects of routers, switches, wlan controllers, firewalls,.....
http://labs.consol.de/nagios/check_nwc_health
GNU General Public License v2.0
147 stars 87 forks source link

interface-status on Cisco Nexus 9000 - regexp issue #264

Closed OG2K closed 3 years ago

OG2K commented 3 years ago

Dears,

I am facing issue with checking interface-status on Cisco Nexus 9000 series giving an regexp argument as follows:

$ '/usr/lib64/nagios/plugins/check_nwc_health' '--regexp' 'true' '--hostname' 'xxx.xxx.xxx.xxx' '--community' 'xxx' '--mode'  'interface-status' '--name' 'Ethernet1/(?1|4|13|16|25|28)' '--multiline'
Mode interface-status is not implemented for this type of device

Output message is misleading, because inteface-status works, but without regexp argument.

$  '/usr/lib64/nagios/plugins/check_nwc_health' --help
check_nwc_health $Revision: 7.10.3 $ [http://labs.consol.de/nagios/check_nwc_health]

# show inventory chassis 
NAME: "Chassis",  DESCR: "Nexus9000 C93180YC-FX Chassis"
PID: N9K-C93180YC-FX     ,  VID: V02 ,  SN: xxxx

After failure, it was decided to create several different checks, but faced another issue: tried determine which interface to check, script will output all interfaces which contain Ethernet1/1 in it:

$ '/usr/lib64/nagios/plugins/check_nwc_health' '--regexp' 'false' '--hostname' 'xxx.xxx.xxx.xxx' '--community' 'xxx' '--mode' 'interface-status' '--name' 'Ethernet1/1' '--multiline' 
CRITICAL - Ethernet1/10 is admin down
Ethernet1/11 is admin down
Ethernet1/12 is admin down
Ethernet1/14 is admin down
Ethernet1/15 is admin down
Ethernet1/17 is admin down
Ethernet1/18 is admin down
Ethernet1/19 is admin down, Ethernet1/1 (alias xxx) is up/up
Ethernet1/10 is down/down
Ethernet1/11 is down/down
Ethernet1/12 is down/down
Ethernet1/13 (alias xxx) is up/up
Ethernet1/14 is down/down
Ethernet1/15 is down/down
Ethernet1/16 (alias xxx) is up/up
Ethernet1/17 is down/down
Ethernet1/18 is down/down
Ethernet1/19 is down/down

My questions are: 1) Am I doing something wrong enabling regexp feature for this particular switch model? if yes, what it could be? 2) How do I specify particular interface to check?

Wishing everybody to be safe, BR /A

lausser commented 3 years ago

There is no --regexp true/false. Just writing "--regexp" means: the argument of --name is to be treated as a regular expression. Without this, the argument is compared 1:1 with the interface names.

OG2K commented 3 years ago

Dear Lausser,

It is how icinga generates values for boolean custom variables. Hopefully, this resolution will be useful for others in future.

$ '/usr/lib64/nagios/plugins/check_nwc_health' '--regexp' '--hostname' 'xxx.xxx.xxx.xxx' '--community' 'xxx' '--mode'  'interface-st
atus' '--name' 'Ethernet1/(?1|4|13|16|25|28)' '--multiline'
Mode interface-status is not implemented for this type of device

and removing '--regexp' 'false' did solved an issue:

$ '/usr/lib64/nagios/plugins/check_nwc_health' '--hostname' 'xxx.xxx.xxx.xxx' '--community' 'xxx' '--mode' 'interface-status' '--nam
e' 'Ethernet1/1' '--multiline'
OK - Ethernet1/1 (alias xxx) is up/up

So, I need to modify in icinga given arguments to command by removing boolean "use regexp" and passing additional argument to command, which will be "--regexp". Presence of '--regexp' 'false' told script to use regexp feature and 'false' was ignored.

Good, second question resolved.

1a) Will it be possible to use regexp with Cisco Nexus 9000 series? 1b) cosmetic note, regarding misleading message.

BR /A

lausser commented 3 years ago

Ethernet1/... The slash might break something. The plugin is written in Perl and a slash must be escaped, because internally it is used as some kind of delimiter. if ($interface_name =~ /$regexp/) ..... Regular expressions in Perl are surrounded by /, so you must write 'Ethernet1\/(?1|4|13|16|25|28)'

OG2K commented 3 years ago

it works properly with other network devices. I run as you adviced, got same error message

Mode interface-status is not implemented for this type of device

Might it be affected with Cisco OS ?

# sh version
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac

[...]

Software
  BIOS: version 05.39
 NXOS: version 9.3(3)
  BIOS compile time:  08/30/2019
  NXOS image file is: bootflash:///nxos.9.3.3.bin
  NXOS compile time:  12/22/2019 2:00:00 [12/22/2019 17:00:37]

Hardware
  cisco Nexus9000 C93180YC-FX Chassis
  Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz with 65808192 kB of memory.
  Processor Board ID xxx

  Device name: xxx
  bootflash:  115805356 kB
Kernel uptime is 298 day(s), 5 hour(s), 41 minute(s), 0 second(s)

Last reset at 851206 usecs after Sun Feb  9 10:27:08 2020
  Reason: Power Down/UP epld upgrade process
  System version: 9.3(3)
  Service: Power Down/UP epld upgrade process

plugin
  Core Plugin, Ethernet Plugin