Fix #1642
This commit is contained in:
parent
f57cb02165
commit
585359cd89
|
@ -41,12 +41,14 @@ sub custom_usage_perfdata {
|
||||||
$total_options{cast_int} = 1;
|
$total_options{cast_int} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => $label,
|
$self->{output}->perfdata_add(
|
||||||
|
label => $label,
|
||||||
nlabel => $self->{nlabel},
|
nlabel => $self->{nlabel},
|
||||||
value => $value_perf, unit => 'B',
|
value => $value_perf, unit => 'B',
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
||||||
min => 0, max => $self->{result_values}->{total});
|
min => 0, max => $self->{result_values}->{total}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_threshold {
|
sub custom_usage_threshold {
|
||||||
|
@ -116,8 +118,8 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"units:s" => { name => 'units', default => '%' },
|
'units:s' => { name => 'units', default => '%' },
|
||||||
"free" => { name => 'free' },
|
'free' => { name => 'free' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
|
|
@ -43,13 +43,12 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'warning:s' => { name => 'warning', },
|
||||||
"warning:s" => { name => 'warning', },
|
'critical:s' => { name => 'critical', },
|
||||||
"critical:s" => { name => 'critical', },
|
'service:s@' => { name => 'service', },
|
||||||
"service:s@" => { name => 'service', },
|
'regexp' => { name => 'use_regexp', },
|
||||||
"regexp" => { name => 'use_regexp', },
|
'state:s' => { name => 'state', },
|
||||||
"state:s" => { name => 'state', },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -79,23 +78,20 @@ sub run {
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
|
|
||||||
my $oid_svSvcEntry = '.1.3.6.1.4.1.77.1.2.3.1';
|
my $oid_svSvcEntry = '.1.3.6.1.4.1.77.1.2.3.1';
|
||||||
my $oid_svSvcName = '.1.3.6.1.4.1.77.1.2.3.1.1';
|
|
||||||
my $oid_svSvcInstalledState = '.1.3.6.1.4.1.77.1.2.3.1.2';
|
my $oid_svSvcInstalledState = '.1.3.6.1.4.1.77.1.2.3.1.2';
|
||||||
my $oid_svSvcOperatingState = '.1.3.6.1.4.1.77.1.2.3.1.3';
|
my $oid_svSvcOperatingState = '.1.3.6.1.4.1.77.1.2.3.1.3';
|
||||||
my $result = $self->{snmp}->get_table(oid => $oid_svSvcEntry, start => $oid_svSvcName, end => $oid_svSvcOperatingState);
|
my $result = $self->{snmp}->get_table(oid => $oid_svSvcEntry, start => $oid_svSvcInstalledState, end => $oid_svSvcOperatingState);
|
||||||
|
|
||||||
my %services_match = ();
|
my %services_match = ();
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => 'All service states are ok');
|
short_msg => 'All service states are ok');
|
||||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||||
next if ($oid !~ /^$oid_svSvcName/);
|
next if ($oid !~ /^$oid_svSvcOperatingState\.(.*?)\.(.*)$/);
|
||||||
$oid =~ /^$oid_svSvcName\.([0-9\.]+)$/;
|
my $instance = $1 . '.' . $2;
|
||||||
my $instance = $1;
|
|
||||||
|
|
||||||
my $svc_name = $self->{output}->to_utf8($result->{$oid});
|
my $svc_name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $2))));
|
||||||
my $svc_installed_state = $result->{$oid_svSvcInstalledState . '.' . $instance};
|
my $svc_installed_state = $result->{$oid_svSvcInstalledState . '.' . $instance};
|
||||||
my $svc_operating_state = $result->{$oid_svSvcOperatingState . '.' . $instance};
|
my $svc_operating_state = $result->{$oid_svSvcOperatingState . '.' . $instance};
|
||||||
|
|
||||||
for (my $i = 0; $i < scalar(@{$self->{option_results}->{service}}); $i++) {
|
for (my $i = 0; $i < scalar(@{$self->{option_results}->{service}}); $i++) {
|
||||||
my $filter = ${$self->{option_results}->{service}}[$i];
|
my $filter = ${$self->{option_results}->{service}}[$i];
|
||||||
if (defined($self->{option_results}->{use_regexp}) && $svc_name =~ /$filter/) {
|
if (defined($self->{option_results}->{use_regexp}) && $svc_name =~ /$filter/) {
|
||||||
|
@ -125,7 +121,7 @@ sub run {
|
||||||
$numbers++;
|
$numbers++;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $numbers, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
my $exit = $self->{perfdata}->threshold_check(value => $numbers, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
$self->{output}->output_add(long_msg => sprintf("Service pattern '%s': service list %s",
|
$self->{output}->output_add(long_msg => sprintf("Service pattern '%s': service list %s",
|
||||||
${$self->{option_results}->{service}}[$i],
|
${$self->{option_results}->{service}}[$i],
|
||||||
join(', ', keys %{$services_match{$i}})));
|
join(', ', keys %{$services_match{$i}})));
|
||||||
|
|
|
@ -30,11 +30,10 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'warning:s' => { name => 'warning' },
|
||||||
"warning:s" => { name => 'warning' },
|
'critical:s' => { name => 'critical' },
|
||||||
"critical:s" => { name => 'critical' },
|
'real-swap' => { name => 'real_swap' },
|
||||||
"real-swap" => { name => 'real_swap' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{swap_memory_id} = undef;
|
$self->{swap_memory_id} = undef;
|
||||||
|
|
Loading…
Reference in New Issue