Refs #5569
This commit is contained in:
parent
9bc8730897
commit
e4f70d19e1
|
@ -145,7 +145,8 @@ sub run {
|
||||||
my $oid_hrSWRunPerfCPU = '.1.3.6.1.2.1.25.5.1.1.1';
|
my $oid_hrSWRunPerfCPU = '.1.3.6.1.2.1.25.5.1.1.1';
|
||||||
|
|
||||||
my $oid2check_filter;
|
my $oid2check_filter;
|
||||||
foreach (keys %$oids) {
|
# To have a better order
|
||||||
|
foreach (('name', 'path', 'args', 'status')) {
|
||||||
if (defined($self->{option_results}->{'process_' . $_})) {
|
if (defined($self->{option_results}->{'process_' . $_})) {
|
||||||
$oid2check_filter = $_;
|
$oid2check_filter = $_;
|
||||||
last;
|
last;
|
||||||
|
@ -172,9 +173,13 @@ sub run {
|
||||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||||
my $option_val = $self->{option_results}->{'process_' . $oid2check_filter};
|
my $option_val = $self->{option_results}->{'process_' . $oid2check_filter};
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{'regexp_' . $oid2check_filter}) && $result->{$key} =~ /$option_val/)
|
if ($oid2check_filter eq 'status') {
|
||||||
|| (!defined($self->{option_results}->{'regexp_' . $oid2check_filter}) && $result->{$key} eq $option_val)
|
if ($map_process_status{$result->{$key}} =~ /$option_val/) {
|
||||||
|| ($oid2check_filter eq 'status' && $map_process_status{$result->{$key}} =~ /$option_val/)) {
|
$key =~ /\.([0-9]+)$/;
|
||||||
|
$instances_keep->{$1} = 1;
|
||||||
|
}
|
||||||
|
} elsif ((defined($self->{option_results}->{'regexp_' . $oid2check_filter}) && $result->{$key} =~ /$option_val/)
|
||||||
|
|| (!defined($self->{option_results}->{'regexp_' . $oid2check_filter}) && $result->{$key} eq $option_val)) {
|
||||||
$key =~ /\.([0-9]+)$/;
|
$key =~ /\.([0-9]+)$/;
|
||||||
$instances_keep->{$1} = 1;
|
$instances_keep->{$1} = 1;
|
||||||
}
|
}
|
||||||
|
@ -190,20 +195,27 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $key (keys %$instances_keep) {
|
foreach my $key (keys %$instances_keep) {
|
||||||
my $long_value = '[ ' . $oid2check_filter . ' => ' . $result->{$oids->{$oid2check_filter} . '.' . $key} . ' ]';
|
my $value = ($oid2check_filter eq 'status') ? $map_process_status{$result->{$oids->{$oid2check_filter} . '.' . $key}} : $result->{$oids->{$oid2check_filter} . '.' . $key};
|
||||||
|
my $long_value = '[ ' . $oid2check_filter . ' => ' . $value . ' ]';
|
||||||
my $deleted = 0;
|
my $deleted = 0;
|
||||||
foreach (keys %$mores_filters) {
|
foreach (keys %$mores_filters) {
|
||||||
my $val = $self->{option_results}->{'process_' . $_};
|
my $opt_val = $self->{option_results}->{'process_' . $_};
|
||||||
|
$value = ($_ eq 'status') ? $map_process_status{$result2->{$oids->{$_} . '.' . $key}} : $result2->{$oids->{$_} . '.' . $key};
|
||||||
|
|
||||||
if ((defined($self->{option_results}->{'regexp_' . $_}) && $result2->{$oids->{$_} . '.' . $key} !~ /$val/)
|
if ($_ eq 'status') {
|
||||||
|| (!defined($self->{option_results}->{'regexp_' . $_}) && $result2->{$oids->{$_} . '.' . $key} ne $val)
|
if ($value !~ /$opt_val/) {
|
||||||
|| ($_ eq 'status' && $map_process_status{$result2->{$oids->{$_} . '.' . $key}} !~ /$val/)) {
|
delete $instances_keep->{$key};
|
||||||
|
$deleted = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
} elsif ((defined($self->{option_results}->{'regexp_' . $_}) && $value !~ /$opt_val/)
|
||||||
|
|| (!defined($self->{option_results}->{'regexp_' . $_}) && $value ne $opt_val)) {
|
||||||
delete $instances_keep->{$key};
|
delete $instances_keep->{$key};
|
||||||
$deleted = 1;
|
$deleted = 1;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
$long_value .= ' [ ' . $_ . ' => ' . $result2->{$oids->{$_} . '.' . $key} . ' ]';
|
$long_value .= ' [ ' . $_ . ' => ' . $value . ' ]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($deleted == 0) {
|
if ($deleted == 0) {
|
||||||
|
|
Loading…
Reference in New Issue