From 577ee23fb9953290beb1e8fb3eb7b81fb90c2faa Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Sun, 15 Dec 2013 22:53:23 +0100 Subject: [PATCH] Fix #4189 --- centreon/plugins/snmp.pm | 6 ++++++ network/bluecoat/mode/clientrequests.pm | 3 ++- network/bluecoat/mode/clienttraffic.pm | 3 ++- network/bluecoat/mode/cpu.pm | 3 ++- snmp_standard/mode/diskio.pm | 5 +++-- snmp_standard/mode/numericvalue.pm | 3 ++- snmp_standard/mode/packeterrors.pm | 5 +++-- snmp_standard/mode/storage.pm | 3 ++- snmp_standard/mode/traffic.pm | 5 +++-- 9 files changed, 25 insertions(+), 11 deletions(-) diff --git a/centreon/plugins/snmp.pm b/centreon/plugins/snmp.pm index af4985ddc..c0bbcbb86 100644 --- a/centreon/plugins/snmp.pm +++ b/centreon/plugins/snmp.pm @@ -591,6 +591,12 @@ sub get_hostname { return $host; } +sub get_port { + my ($self) = @_; + + return $self->{snmp_params}->{RemotePort}; +} + sub oid_lex_sort { my $self = shift; diff --git a/network/bluecoat/mode/clientrequests.pm b/network/bluecoat/mode/clientrequests.pm index e12ca30a7..061038749 100644 --- a/network/bluecoat/mode/clientrequests.pm +++ b/network/bluecoat/mode/clientrequests.pm @@ -88,13 +88,14 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); if ($self->{snmp}->is_snmpv1()) { $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); $self->{output}->option_exit(); } - $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{mode}); + $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.1.1.0', '.1.3.6.1.4.1.3417.2.11.3.1.1.2.0', '.1.3.6.1.4.1.3417.2.11.3.1.1.3.0', diff --git a/network/bluecoat/mode/clienttraffic.pm b/network/bluecoat/mode/clienttraffic.pm index b770a095a..78823d48c 100644 --- a/network/bluecoat/mode/clienttraffic.pm +++ b/network/bluecoat/mode/clienttraffic.pm @@ -88,13 +88,14 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); if ($self->{snmp}->is_snmpv1()) { $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); $self->{output}->option_exit(); } - $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{mode}); + $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.1.9.0', '.1.3.6.1.4.1.3417.2.11.3.1.1.10.0'], nothing_quit => 1); diff --git a/network/bluecoat/mode/cpu.pm b/network/bluecoat/mode/cpu.pm index 30a2bb0d5..dc4a76965 100644 --- a/network/bluecoat/mode/cpu.pm +++ b/network/bluecoat/mode/cpu.pm @@ -78,6 +78,7 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); if ($self->{snmp}->is_snmpv1()) { $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); @@ -87,7 +88,7 @@ sub run { my $new_datas = {}; my $old_timestamp = undef; - $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{mode}); + $self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); my $result = $self->{snmp}->get_table(oid => '.1.3.6.1.4.1.3417.2.11.2.4.1', nothing_quit => 1); $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp'); diff --git a/snmp_standard/mode/diskio.pm b/snmp_standard/mode/diskio.pm index 2dcacb653..713d0047e 100644 --- a/snmp_standard/mode/diskio.pm +++ b/snmp_standard/mode/diskio.pm @@ -98,6 +98,7 @@ sub run { my ($self, %options) = @_; # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; + $self->{snmp_port} = $self->{snmp}->get_port(); if ($self->{snmp}->is_snmpv1()) { $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); @@ -113,7 +114,7 @@ sub run { my $oid_diskIONWrittenX = '.1.3.6.1.4.1.2021.13.15.1.1.13'; # in B my $new_datas = {}; - $self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{device}) ? md5_hex($self->{option_results}->{device}) : md5_hex('all'))); + $self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{device}) ? md5_hex($self->{option_results}->{device}) : md5_hex('all'))); $self->{snmp}->load(oids => [$oid_diskIONReadX, $oid_diskIONWrittenX], instances => $self->{device_id_selected}); @@ -229,7 +230,7 @@ sub manage_selection { my ($self, %options) = @_; # init cache file - my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode}); + my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); if (defined($self->{option_results}->{show_cache})) { $self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content()); $self->{output}->option_exit(); diff --git a/snmp_standard/mode/numericvalue.pm b/snmp_standard/mode/numericvalue.pm index 04c0089f7..335bd182f 100644 --- a/snmp_standard/mode/numericvalue.pm +++ b/snmp_standard/mode/numericvalue.pm @@ -103,6 +103,7 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); my $result = $self->{snmp}->get_leef(oids => [$self->{option_results}->{oid}], nothing_quit => 1); my $value = $result->{$self->{option_results}->{oid}}; @@ -110,7 +111,7 @@ sub run { if ($self->{option_results}->{oid_type} =~ /^counter$/i) { my $datas = {}; - $self->{statefile_cache}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . md5_hex($self->{option_results}->{oid})); + $self->{statefile_cache}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . md5_hex($self->{option_results}->{oid})); my $old_timestamp = $self->{statefile_cache}->get(name => 'timestamp'); my $old_value = $self->{statefile_cache}->get(name => 'value'); diff --git a/snmp_standard/mode/packeterrors.pm b/snmp_standard/mode/packeterrors.pm index 7dda32952..c5091985d 100644 --- a/snmp_standard/mode/packeterrors.pm +++ b/snmp_standard/mode/packeterrors.pm @@ -145,6 +145,7 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); $self->manage_selection(); @@ -174,7 +175,7 @@ sub run { my $oid_ifOutErrors = '.1.3.6.1.2.1.2.2.1.20'; my $new_datas = {}; - $self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all'))); + $self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all'))); foreach (@{$self->{interface_id_selected}}) { $self->{snmp}->load(oids => [$oid_adminstatus . "." . $_, $oid_operstatus . "." . $_, @@ -384,7 +385,7 @@ sub manage_selection { my ($self, %options) = @_; # init cache file - my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode}); + my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); if (defined($self->{option_results}->{show_cache})) { $self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content()); $self->{output}->option_exit(); diff --git a/snmp_standard/mode/storage.pm b/snmp_standard/mode/storage.pm index 1b7dc3072..d829a253d 100644 --- a/snmp_standard/mode/storage.pm +++ b/snmp_standard/mode/storage.pm @@ -114,6 +114,7 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); $self->manage_selection(); @@ -243,7 +244,7 @@ sub manage_selection { my ($self, %options) = @_; # init cache file - my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode}); + my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); if (defined($self->{option_results}->{show_cache})) { $self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content()); $self->{output}->option_exit(); diff --git a/snmp_standard/mode/traffic.pm b/snmp_standard/mode/traffic.pm index 5ea375dae..90b16e63c 100644 --- a/snmp_standard/mode/traffic.pm +++ b/snmp_standard/mode/traffic.pm @@ -122,6 +122,7 @@ sub run { # $options{snmp} = snmp object $self->{snmp} = $options{snmp}; $self->{hostname} = $self->{snmp}->get_hostname(); + $self->{snmp_port} = $self->{snmp}->get_port(); $self->manage_selection(); @@ -135,7 +136,7 @@ sub run { my $oid_out64 = '.1.3.6.1.2.1.31.1.1.1.10'; # in B my $new_datas = {}; - $self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all'))); + $self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all'))); foreach (@{$self->{interface_id_selected}}) { $self->{snmp}->load(oids => [$oid_adminstatus . "." . $_, $oid_operstatus . "." . $_, $oid_in32 . "." . $_, $oid_out32 . "." . $_]); @@ -327,7 +328,7 @@ sub manage_selection { my ($self, %options) = @_; # init cache file - my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode}); + my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode}); if (defined($self->{option_results}->{show_cache})) { $self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content()); $self->{output}->option_exit();