Adapt the network interfaces check to the modern ifconfig output.

This commit is contained in:
Andrea Dell'Amico 2019-08-10 17:34:49 +02:00
parent a9f4b58f35
commit 3a9875e458
1 changed files with 47 additions and 26 deletions

View File

@ -609,7 +609,7 @@ if ($@) {
}
# Version
my $Version='2.4';
my $Version='2.4.1';
############### BASE DIRECTORY FOR TEMP FILE (override this with -F) ########
my $o_base_dir="/tmp/tmp_Nagios_int.";
@ -1667,6 +1667,27 @@ sub getdata_localhost {
}
}
}
if (!$int_lines && scalar(@words)>2 && $words[1] =~ /flags=.*/) {
if (int_name_match($words[0])) {
$interfaces[$num_int] = {
'descr' => $words[0], 'admin_up'=> $status{'DOWN'}, 'oper_up'=> $status{'DOWN'}, # considered common between SNMP and local checks
'in_bytes' => 0, 'out_bytes' => 0, 'in_packets' => 0, 'out_packets' => 0, # considered common, but packets are not used
'in_errors' => 0, 'out_errors' => 0, # considered common
'in_dropped' => 0, 'out_dropped' => 0, # common, same as discards for SNMP
'in_overruns' => 0, 'out_overruns' => 0, # added to errors if not 0
'collisions' => 0, 'txqueuelen' => 0, 'metric' => 0, 'MTU'=>0 # linux-specific names, not really used
};
foreach(@words) {
if ($_ =~ /.*UP.*/) { $interfaces[$num_int]{'admin_up'} = $status{'UP'}; }
if ($_ =~ /.*RUNNING.*/) { $interfaces[$num_int]{'oper_up'} = $status{'UP'}; }
}
$int_lines=1;
}
}
elsif ($int_lines && scalar(@words)<2) {
$int_lines=0;
$num_int++;
}
}
finish_shell_command($shell_ref);
if ($check_speed) {