Adapt the network interfaces check to the modern ifconfig output.
This commit is contained in:
parent
a9f4b58f35
commit
3a9875e458
|
@ -609,7 +609,7 @@ if ($@) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
my $Version='2.4';
|
my $Version='2.4.1';
|
||||||
|
|
||||||
############### BASE DIRECTORY FOR TEMP FILE (override this with -F) ########
|
############### BASE DIRECTORY FOR TEMP FILE (override this with -F) ########
|
||||||
my $o_base_dir="/tmp/tmp_Nagios_int.";
|
my $o_base_dir="/tmp/tmp_Nagios_int.";
|
||||||
|
@ -1637,35 +1637,56 @@ sub getdata_localhost {
|
||||||
verb("got line: $_");
|
verb("got line: $_");
|
||||||
my @words = split;
|
my @words = split;
|
||||||
if (!$int_lines && scalar(@words)>2 && $words[1] eq 'Link') {
|
if (!$int_lines && scalar(@words)>2 && $words[1] eq 'Link') {
|
||||||
if (int_name_match($words[0])) {
|
if (int_name_match($words[0])) {
|
||||||
$interfaces[$num_int] = {
|
$interfaces[$num_int] = {
|
||||||
'descr' => $words[0], 'admin_up'=> $status{'DOWN'}, 'oper_up'=> $status{'DOWN'}, # considered common between SNMP and local checks
|
'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_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_errors' => 0, 'out_errors' => 0, # considered common
|
||||||
'in_dropped' => 0, 'out_dropped' => 0, # common, same as discards for SNMP
|
'in_dropped' => 0, 'out_dropped' => 0, # common, same as discards for SNMP
|
||||||
'in_overruns' => 0, 'out_overruns' => 0, # added to errors if not 0
|
'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
|
'collisions' => 0, 'txqueuelen' => 0, 'metric' => 0, 'MTU'=>0 # linux-specific names, not really used
|
||||||
};
|
};
|
||||||
$int_lines=1;
|
$int_lines=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($int_lines && scalar(@words)<2) {
|
elsif ($int_lines && scalar(@words)<2) {
|
||||||
$int_lines=0;
|
$int_lines=0;
|
||||||
$num_int++;
|
$num_int++;
|
||||||
}
|
}
|
||||||
elsif ($int_lines) {
|
elsif ($int_lines) {
|
||||||
my $prefix="";
|
my $prefix="";
|
||||||
foreach(@words) {
|
foreach(@words) {
|
||||||
if ($_ eq "RX") { $prefix = "in_"; }
|
if ($_ eq "RX") { $prefix = "in_"; }
|
||||||
elsif ($_ eq "TX") { $prefix = "out_"; }
|
elsif ($_ eq "TX") { $prefix = "out_"; }
|
||||||
elsif ($_ eq "UP") { $interfaces[$num_int]{'admin_up'} = $status{'UP'}; }
|
elsif ($_ eq "UP") { $interfaces[$num_int]{'admin_up'} = $status{'UP'}; }
|
||||||
elsif ($_ eq "RUNNING") { $interfaces[$num_int]{'oper_up'} = $status{'UP'}; }
|
elsif ($_ eq "RUNNING") { $interfaces[$num_int]{'oper_up'} = $status{'UP'}; }
|
||||||
elsif ($_ =~ /^(.*):(\d+)/) {
|
elsif ($_ =~ /^(.*):(\d+)/) {
|
||||||
verb(" interface #".$num_int." (".$interfaces[$num_int]{'descr'}.") : ".$prefix.$1." = ".$2);
|
verb(" interface #".$num_int." (".$interfaces[$num_int]{'descr'}.") : ".$prefix.$1." = ".$2);
|
||||||
$interfaces[$num_int]{$prefix.$1} = $2;
|
$interfaces[$num_int]{$prefix.$1} = $2;
|
||||||
$interfaces[$num_int]{$prefix.'errors'} += $2 if ($1 eq 'overruns');
|
$interfaces[$num_int]{$prefix.'errors'} += $2 if ($1 eq 'overruns');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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);
|
finish_shell_command($shell_ref);
|
||||||
|
|
Loading…
Reference in New Issue