Fix #1642
This commit is contained in:
parent
f57cb02165
commit
585359cd89
|
@ -41,12 +41,14 @@ sub custom_usage_perfdata {
|
|||
$total_options{cast_int} = 1;
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => $label,
|
||||
nlabel => $self->{nlabel},
|
||||
value => $value_perf, unit => 'B',
|
||||
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),
|
||||
min => 0, max => $self->{result_values}->{total});
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label,
|
||||
nlabel => $self->{nlabel},
|
||||
value => $value_perf, unit => 'B',
|
||||
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),
|
||||
min => 0, max => $self->{result_values}->{total}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
|
@ -116,8 +118,8 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
"free" => { name => 'free' },
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'free' => { name => 'free' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
|
|
@ -43,14 +43,13 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
"service:s@" => { name => 'service', },
|
||||
"regexp" => { name => 'use_regexp', },
|
||||
"state:s" => { name => 'state', },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning', },
|
||||
'critical:s' => { name => 'critical', },
|
||||
'service:s@' => { name => 'service', },
|
||||
'regexp' => { name => 'use_regexp', },
|
||||
'state:s' => { name => 'state', },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -60,8 +59,8 @@ sub check_options {
|
|||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{service})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify at least one '--service' option.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify at least one '--service' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
|
@ -79,23 +78,20 @@ sub run {
|
|||
$self->{snmp} = $options{snmp};
|
||||
|
||||
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_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 = ();
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All service states are ok');
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($oid !~ /^$oid_svSvcName/);
|
||||
$oid =~ /^$oid_svSvcName\.([0-9\.]+)$/;
|
||||
my $instance = $1;
|
||||
next if ($oid !~ /^$oid_svSvcOperatingState\.(.*?)\.(.*)$/);
|
||||
my $instance = $1 . '.' . $2;
|
||||
|
||||
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_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++) {
|
||||
my $filter = ${$self->{option_results}->{service}}[$i];
|
||||
if (defined($self->{option_results}->{use_regexp}) && $svc_name =~ /$filter/) {
|
||||
|
@ -125,7 +121,7 @@ sub run {
|
|||
$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->{option_results}->{service}}[$i],
|
||||
join(', ', keys %{$services_match{$i}})));
|
||||
|
@ -140,7 +136,7 @@ sub run {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
|
|
@ -30,12 +30,11 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"real-swap" => { name => 'real_swap' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'real-swap' => { name => 'real_swap' },
|
||||
});
|
||||
|
||||
$self->{swap_memory_id} = undef;
|
||||
$self->{physical_memory_id} = undef;
|
||||
|
|
Loading…
Reference in New Issue