From 79fb00d9423663c08b60e72341571173db07722a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 28 Dec 2016 16:06:22 +0100 Subject: [PATCH] + add filter-type option --- .../network/sophos/es/snmp/mode/message.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/network/sophos/es/snmp/mode/message.pm b/centreon-plugins/network/sophos/es/snmp/mode/message.pm index d60eb2f84..871ad5426 100644 --- a/centreon-plugins/network/sophos/es/snmp/mode/message.pm +++ b/centreon-plugins/network/sophos/es/snmp/mode/message.pm @@ -97,7 +97,8 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => - { + { + "filter-type:s" => { name => 'filter_type' }, }); return $self; @@ -124,6 +125,7 @@ sub manage_selection { my $results = $options{snmp}->get_table(oid => $oid_sophosStatisticsEmail, nothing_quit => 1); $self->{cache_name} = "sophos_es_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_type}) ? md5_hex($self->{option_results}->{filter_type}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); $self->{global} = { total_in => 0, total_out => 0 }; @@ -135,6 +137,11 @@ sub manage_selection { my $instance = $1; my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && + $result->{counterType} !~ /$self->{option_results}->{filter_type}/i) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{counterType} . "': no matching filter.", debug => 1); + next; + } $self->{sea_msg}->{lc($result->{counterType})} = { display => lc($result->{counterType}), in => $result->{counterInbound}, out => $result->{counterOutbound} @@ -155,6 +162,10 @@ Check message statistics. =over 8 +=item B<--filter-type> + +Filter message type (can be a regexp). + =item B<--filter-counters> Only display some counters (regexp can be used).