From 7452038113fb04f11efa6967e3d7b11b1ee3eb2a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Thu, 22 Dec 2016 15:07:06 +0100 Subject: [PATCH] Use centreon::plugins::misc::trim() --- centreon/common/cisco/standard/snmp/mode/environment.pm | 4 ++-- centreon/plugins/misc.pm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/environment.pm b/centreon/common/cisco/standard/snmp/mode/environment.pm index 57c30a10c..764d66bf6 100644 --- a/centreon/common/cisco/standard/snmp/mode/environment.pm +++ b/centreon/common/cisco/standard/snmp/mode/environment.pm @@ -123,8 +123,8 @@ sub snmp_execute { push @{$self->{request}}, { oid => $oid_entPhysicalDescr }, { oid => $oid_ciscoEnvMonPresent }; $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); - foreach my $k (keys(%{$self->{results}->{$oid_entPhysicalDescr}})) { - $self->{results}->{$oid_entPhysicalDescr}->{$k} =~ s/^\s+|\s+$|[\n\r]+//g; + while (my ($key, $value) = each %{$self->{results}->{$oid_entPhysicalDescr}}) { + $self->{results}->{$oid_entPhysicalDescr}->{$key} = centreon::plugins::misc::trim($value); } $self->{output}->output_add(long_msg => sprintf("Environment type: %s", defined($self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}) && defined($map_type_mon{$self->{results}->{$oid_ciscoEnvMonPresent}->{$oid_ciscoEnvMonPresent . '.0'}} ) ? diff --git a/centreon/plugins/misc.pm b/centreon/plugins/misc.pm index a32abb0b7..add26b8ed 100644 --- a/centreon/plugins/misc.pm +++ b/centreon/plugins/misc.pm @@ -314,8 +314,8 @@ sub trim { # Sometimes there is a null character $value =~ s/\x00$//; - $value =~ s/^[ \t]+//; - $value =~ s/[ \t]+$//; + $value =~ s/^[ \t\n]+//; + $value =~ s/[ \t\n]+$//; return $value; }