Merge branch 'master' of adellam/ansible-roles into master

This commit is contained in:
Andrea Dell'Amico 2019-08-10 17:35:35 +02:00 committed by Gitea
commit bbee6c924c
2 changed files with 48 additions and 28 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.";
@ -1637,35 +1637,56 @@ sub getdata_localhost {
verb("got line: $_");
my @words = split;
if (!$int_lines && scalar(@words)>2 && $words[1] eq 'Link') {
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
};
$int_lines=1;
}
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
};
$int_lines=1;
}
}
elsif ($int_lines && scalar(@words)<2) {
$int_lines=0;
$num_int++;
$int_lines=0;
$num_int++;
}
elsif ($int_lines) {
my $prefix="";
foreach(@words) {
if ($_ eq "RX") { $prefix = "in_"; }
elsif ($_ eq "TX") { $prefix = "out_"; }
elsif ($_ eq "UP") { $interfaces[$num_int]{'admin_up'} = $status{'UP'}; }
elsif ($_ eq "RUNNING") { $interfaces[$num_int]{'oper_up'} = $status{'UP'}; }
elsif ($_ =~ /^(.*):(\d+)/) {
verb(" interface #".$num_int." (".$interfaces[$num_int]{'descr'}.") : ".$prefix.$1." = ".$2);
$interfaces[$num_int]{$prefix.$1} = $2;
$interfaces[$num_int]{$prefix.'errors'} += $2 if ($1 eq 'overruns');
}
}
my $prefix="";
foreach(@words) {
if ($_ eq "RX") { $prefix = "in_"; }
elsif ($_ eq "TX") { $prefix = "out_"; }
elsif ($_ eq "UP") { $interfaces[$num_int]{'admin_up'} = $status{'UP'}; }
elsif ($_ eq "RUNNING") { $interfaces[$num_int]{'oper_up'} = $status{'UP'}; }
elsif ($_ =~ /^(.*):(\d+)/) {
verb(" interface #".$num_int." (".$interfaces[$num_int]{'descr'}.") : ".$prefix.$1." = ".$2);
$interfaces[$num_int]{$prefix.$1} = $2;
$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);

View File

@ -41,8 +41,7 @@ command[global_check_linux_raid]={{ nagios_plugins_dir }}/check_raid
command[global_check_smart]={{ nagios_local_plugdir }}/check_smart -d $ARG1$ -i $ARG2$
# Network interfaces
#command[global_net_interfaces]={{ nagios_local_plugdir }}/check_netint.pl -K -f -e
command[global_net_interfaces]={{ nagios_local_plugdir }}/check_netint.pl -K -f -e -D -S -n \(l\|eth\|p\|bond\)
command[global_net_interfaces]={{ nagios_local_plugdir }}/check_netint.pl -K -f -e -D -S -n \(l\|eth\|p\|bond\|\xen\|en\|es\)
# Restart ntp (via handler)
command[global_restart_ntp]=/usr/bin/sudo /etc/init.d/ntp start