diff --git a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/interfaces.pm b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/interfaces.pm index 173e38786..756536914 100644 --- a/centreon-plugins/centreon/common/cisco/standard/snmp/mode/interfaces.pm +++ b/centreon-plugins/centreon/common/cisco/standard/snmp/mode/interfaces.pm @@ -237,6 +237,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/interfaces.pm b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/interfaces.pm index 0be7338d6..6d2e6485a 100644 --- a/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/interfaces.pm +++ b/centreon-plugins/centreon/common/fortinet/fortigate/snmp/mode/interfaces.pm @@ -98,6 +98,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/adva/fsp3000/snmp/mode/interfaces.pm b/centreon-plugins/network/adva/fsp3000/snmp/mode/interfaces.pm index b27aa0456..02142776c 100644 --- a/centreon-plugins/network/adva/fsp3000/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/adva/fsp3000/snmp/mode/interfaces.pm @@ -316,6 +316,10 @@ Check interface traffic. Check interface optical. +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/atrica/snmp/mode/connections.pm b/centreon-plugins/network/atrica/snmp/mode/connections.pm index 724645130..134e02937 100644 --- a/centreon-plugins/network/atrica/snmp/mode/connections.pm +++ b/centreon-plugins/network/atrica/snmp/mode/connections.pm @@ -100,7 +100,7 @@ sub default_critical_status { return undef; } -sub default_check_status { +sub default_check_metrics { my ($self, %options) = @_; return '%{opstatus} eq "up" or %{opstatus} eq "inService"'; @@ -403,6 +403,10 @@ Check interface traffic. Check interface errors. +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up" or %{opstatus} eq "inService"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/brocade/snmp/mode/interfaces.pm b/centreon-plugins/network/brocade/snmp/mode/interfaces.pm index 0ed7bf916..5d061f880 100644 --- a/centreon-plugins/network/brocade/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/brocade/snmp/mode/interfaces.pm @@ -291,6 +291,10 @@ Check interface data volume between two checks (not supposed to be graphed, usef Check interface optical. +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/dlink/standard/snmp/mode/interfaces.pm b/centreon-plugins/network/dlink/standard/snmp/mode/interfaces.pm index ea56188fd..693b01180 100644 --- a/centreon-plugins/network/dlink/standard/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/dlink/standard/snmp/mode/interfaces.pm @@ -162,6 +162,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/extreme/snmp/mode/interfaces.pm b/centreon-plugins/network/extreme/snmp/mode/interfaces.pm index 31c1c8bf8..76b037dd6 100644 --- a/centreon-plugins/network/extreme/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/extreme/snmp/mode/interfaces.pm @@ -115,6 +115,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/fortinet/fortiswitch/snmp/mode/interfaces.pm b/centreon-plugins/network/fortinet/fortiswitch/snmp/mode/interfaces.pm index d1c3a6faf..b105c2e27 100644 --- a/centreon-plugins/network/fortinet/fortiswitch/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/fortinet/fortiswitch/snmp/mode/interfaces.pm @@ -75,6 +75,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/hp/procurve/snmp/mode/interfaces.pm b/centreon-plugins/network/hp/procurve/snmp/mode/interfaces.pm index 2bc702949..6fd7eb4ff 100644 --- a/centreon-plugins/network/hp/procurve/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/hp/procurve/snmp/mode/interfaces.pm @@ -174,6 +174,10 @@ Check interface data volume between two checks (not supposed to be graphed, usef Check power over thernet. +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/juniper/common/junos/mode/interfaces.pm b/centreon-plugins/network/juniper/common/junos/mode/interfaces.pm index 5169c41e5..05b495754 100644 --- a/centreon-plugins/network/juniper/common/junos/mode/interfaces.pm +++ b/centreon-plugins/network/juniper/common/junos/mode/interfaces.pm @@ -276,6 +276,10 @@ Check interface data volume between two checks (not supposed to be graphed, usef Check interface optical metrics. +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/lenovo/rackswitch/snmp/mode/interfaces.pm b/centreon-plugins/network/lenovo/rackswitch/snmp/mode/interfaces.pm index 8bfd13a95..d0e7ba3f9 100644 --- a/centreon-plugins/network/lenovo/rackswitch/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/lenovo/rackswitch/snmp/mode/interfaces.pm @@ -75,6 +75,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm b/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm index 6db0a18aa..3162f1d13 100644 --- a/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/microsens/g6/snmp/mode/interfaces.pm @@ -75,6 +75,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm b/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm index d092f3bb4..c2c827dc8 100644 --- a/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm @@ -173,6 +173,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/network/mrv/optiswitch/snmp/mode/interfaces.pm b/centreon-plugins/network/mrv/optiswitch/snmp/mode/interfaces.pm index 905916c4d..9af8baef5 100644 --- a/centreon-plugins/network/mrv/optiswitch/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/mrv/optiswitch/snmp/mode/interfaces.pm @@ -155,7 +155,7 @@ sub set_oids_cast { $self->{oid_ifHCOutBroadcastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.11'; } -sub default_check_status { +sub default_check_metrics { my ($self, %options) = @_; return '%{opstatus} eq "enabled" and %{linkstatus} eq "true"'; @@ -456,6 +456,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "enabled" and %{linkstatus} eq "true"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/snmp_standard/mode/interfaces.pm b/centreon-plugins/snmp_standard/mode/interfaces.pm index 3919c1426..f0415bc07 100644 --- a/centreon-plugins/snmp_standard/mode/interfaces.pm +++ b/centreon-plugins/snmp_standard/mode/interfaces.pm @@ -42,9 +42,10 @@ sub custom_threshold_output { $status = 'warning'; } - $self->{instance_mode}->{last_status} = 0; - if (eval "$self->{instance_mode}->{check_status}") { - $self->{instance_mode}->{last_status} = 1; + $self->{instance_mode}->{last_status} = 1; + if (defined($self->{instance_mode}->{option_results}->{check_metrics}) && $self->{instance_mode}->{option_results}->{check_metrics} ne '' && + !$self->eval(value => $self->{instance_mode}->{option_results}->{check_metrics})) { + $self->{instance_mode}->{last_status} = 0; } return $status; @@ -798,7 +799,7 @@ sub check_oids_label { } } -sub default_check_status { +sub default_check_metrics { my ($self, %options) = @_; return '%{opstatus} eq "up"'; @@ -867,6 +868,7 @@ sub new { 'add-duplex-status' => { name => 'add_duplex_status' }, 'warning-status:s' => { name => 'warning_status', default => $self->default_warning_status() }, 'critical-status:s' => { name => 'critical_status', default => $self->default_critical_status() }, + 'check-metrics:s' => { name => 'check_metrics', default => $self->default_check_metrics() }, 'global-admin-up-rule:s' => { name => 'global_admin_up_rule', default => $self->default_global_admin_up_rule() }, 'global-oper-up-rule:s' => { name => 'global_oper_up_rule', default => $self->default_global_oper_up_rule() }, 'global-admin-down-rule:s' => { name => 'global_admin_down_rule', default => $self->default_global_admin_down_rule() }, @@ -984,8 +986,7 @@ sub check_options { } $self->change_macros(macros => ['warning_status', 'critical_status']); - $self->{check_status} = $self->default_check_status(); - $self->{check_status} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g; + $self->{option_results}->{check_metrics} =~ s/%\{(.*?)\}/\$values->{$1}/g; } sub get_display_value { @@ -1571,6 +1572,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status. diff --git a/centreon-plugins/storage/lenovo/iomega/snmp/mode/interfaces.pm b/centreon-plugins/storage/lenovo/iomega/snmp/mode/interfaces.pm index 11afdd3d6..5d5a30192 100644 --- a/centreon-plugins/storage/lenovo/iomega/snmp/mode/interfaces.pm +++ b/centreon-plugins/storage/lenovo/iomega/snmp/mode/interfaces.pm @@ -88,6 +88,10 @@ Check interface speed. Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + =item B<--warning-status> Set warning threshold for status.