fix interface name local linux

This commit is contained in:
garnier-quentin 2020-03-24 09:43:23 +01:00
parent 9dab364909
commit e33e5dd79c
2 changed files with 51 additions and 52 deletions

View File

@ -31,8 +31,7 @@ use centreon::plugins::misc;
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf('status : %s', $self->{result_values}->{status});
return $msg;
return sprintf('status : %s', $self->{result_values}->{status});
}
sub custom_status_calc {
@ -46,13 +45,12 @@ sub custom_status_calc {
sub custom_packet_output {
my ($self, %options) = @_;
my $msg = sprintf("Packet %s %s : %.2f %% (%s)",
return sprintf('Packet %s %s : %.2f %% (%s)',
ucfirst($self->{result_values}->{type}),
ucfirst($self->{result_values}->{label}),
$self->{result_values}->{result_prct},
$self->{result_values}->{diff_value}
);
return $msg;
}
sub custom_packet_calc {
@ -222,6 +220,7 @@ sub do_selection {
my $states = '';
$states .= 'R' if ($values =~ /RUNNING|LOWER_UP/ms);
$states .= 'U' if ($values =~ /UP/ms);
$interface_name =~ s/:$//;
next if (defined($self->{option_results}->{no_loopback}) && $values =~ /LOOPBACK/ms);
next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' &&

View File

@ -31,8 +31,7 @@ use centreon::plugins::misc;
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf('status : %s', $self->{result_values}->{status});
return $msg;
return sprintf('status : %s', $self->{result_values}->{status});
}
sub custom_status_calc {
@ -81,10 +80,11 @@ sub custom_traffic_output {
my ($self, %options) = @_;
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1);
my $msg = sprintf("Traffic %s : %s/s (%s)",
return sprintf(
'Traffic %s : %s/s (%s)',
ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit,
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-');
return $msg;
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-'
);
}
sub custom_traffic_calc {
@ -148,26 +148,26 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'ip' },
"command-path:s" => { name => 'command_path', default => '/sbin' },
"command-options:s" => { name => 'command_options', default => '-s addr 2>&1' },
"filter-state:s" => { name => 'filter_state', },
"units:s" => { name => 'units', default => 'b/s' },
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"speed:s" => { name => 'speed' },
"no-loopback" => { name => 'no_loopback', },
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} ne "RU"' },
'hostname:s' => { name => 'hostname' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 30 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'ip' },
'command-path:s' => { name => 'command_path', default => '/sbin' },
'command-options:s' => { name => 'command_options', default => '-s addr 2>&1' },
'filter-state:s' => { name => 'filter_state', },
'units:s' => { name => 'units', default => 'b/s' },
'name:s' => { name => 'name' },
'regexp' => { name => 'use_regexp' },
'regexp-isensitive' => { name => 'use_regexpi' },
'speed:s' => { name => 'speed' },
'no-loopback' => { name => 'no_loopback', },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "RU"' },
});
return $self;