Skip to main content

Hi

I am trying to filter out host links that are not used so that they are not displayed, but the usual filtering options (--filter= or --exclude=) are not working for me.

Does anyone have any tips on how I could filter out unwanted host links?

My command: /usr/lib/centreon/plugins//centreon_cisco_standard_snmp.pl --plugin=network::cisco::standard::snmp::plugin --mode=vpc --hostname=xxxxx --snmp-version='2c' --snmp-community='xxxx'   --verbose

Output: WARNING: vPC domain '12' host link 'port-channel31' operational status: downStar - host link 'port-channel100' operational status: downStar

For example I would like to filter out port-channel31 and port-channel100.

hello

the check in question does not have filter option, however there are customization possible 

an extract of the --help

    --warning-link-status
            Define the conditions to match for the status to be WARNING
            (default: '%{link_status} =~ /downStar/i') You can use the
            following variables: %{link_status}, %{display}

    --critical-link-status
            Define the conditions to match for the status to be CRITICAL
            (default: '%{link_status} eq "down"'). You can use the following
            variables: %{link_status}, %{display}

there are 2 variables usable for the check status, %{link_status} and %{display}

so maybe something could be done with a more complex query, but I don’t have this check or equipement and I cannot try (as I don’t know what is in the variable “display”, probably this could contain the text “port-channel100”

 

unfortunately I can’t find a documentation explaining how to write this, it is “perl” syntax, but I don’t know how to do a complex query. here is what I gathered after playing with other check, like bgp peer state

=~ /xxxx/i  <= means “contains xxx”

!~ /yyy/i <= means does not contain “yyy” 

eq <= means equal, and you can use “and” or “&&”, “or” or “||” for logical operation ( Perl - Operators )

 

now you need to test, I suggest copying the command line you got from the GUI, go in the ssh shell of your poller and “su - centreon-engine” to do the tests.

change the --warning-link-status (or add it, to change the default value described in the --help) to this :

%{link_status} =~ /downStar/i and %{display} !~ /portchannel-100/i 

(remember to add quotes around the value when you are in the command line, this is a single parameter so all the spaces needs to be between quotes)

if that works, next would be to try a multiple “A and ( B or C )” , and perl supports grouping with parenthesis, so maybe that should work like that :

%{link_status} =~ /downStar/i and ( %{display} !~ /portchannel-31/i or %{display} !~ /portchannel-100/i  )

 

no guarantee that it works, as I said, I cannot find a documentation explaining that syntax on centreon, and it all depends if the ${display} variable contains the value you want to filter


Reply