Fix #1615
This commit is contained in:
parent
2696c46c95
commit
a3f5c9b5c5
|
@ -34,40 +34,40 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"service-soap:s" => { name => 'service_soap' },
|
'service-soap:s' => { name => 'service_soap' },
|
||||||
"data:s" => { name => 'data' },
|
'data:s' => { name => 'data' },
|
||||||
"lookup:s@" => { name => 'lookup' },
|
'lookup:s@' => { name => 'lookup' },
|
||||||
"hostname:s" => { name => 'hostname' },
|
'hostname:s' => { name => 'hostname' },
|
||||||
"vhost:s" => { name => 'vhost' },
|
'vhost:s' => { name => 'vhost' },
|
||||||
"port:s" => { name => 'port', },
|
'port:s' => { name => 'port', },
|
||||||
"proto:s" => { name => 'proto' },
|
'proto:s' => { name => 'proto' },
|
||||||
"urlpath:s" => { name => 'url_path' },
|
'urlpath:s' => { name => 'url_path' },
|
||||||
"credentials" => { name => 'credentials' },
|
'credentials' => { name => 'credentials' },
|
||||||
"basic" => { name => 'basic' },
|
'basic' => { name => 'basic' },
|
||||||
"ntlmv2" => { name => 'ntlmv2' },
|
'ntlmv2' => { name => 'ntlmv2' },
|
||||||
"username:s" => { name => 'username' },
|
'username:s' => { name => 'username' },
|
||||||
"password:s" => { name => 'password' },
|
'password:s' => { name => 'password' },
|
||||||
"header:s@" => { name => 'header' },
|
'header:s@' => { name => 'header' },
|
||||||
"timeout:s" => { name => 'timeout', default => 10 },
|
'timeout:s' => { name => 'timeout', default => 10 },
|
||||||
"cert-file:s" => { name => 'cert_file' },
|
'cert-file:s' => { name => 'cert_file' },
|
||||||
"key-file:s" => { name => 'key_file' },
|
'key-file:s' => { name => 'key_file' },
|
||||||
"cacert-file:s" => { name => 'cacert_file' },
|
'cacert-file:s' => { name => 'cacert_file' },
|
||||||
"cert-pwd:s" => { name => 'cert_pwd' },
|
'cert-pwd:s' => { name => 'cert_pwd' },
|
||||||
"cert-pkcs12" => { name => 'cert_pkcs12' },
|
'cert-pkcs12' => { name => 'cert_pkcs12' },
|
||||||
"unknown-status:s" => { name => 'unknown_status' },
|
'unknown-status:s' => { name => 'unknown_status' },
|
||||||
"warning-status:s" => { name => 'warning_status' },
|
'warning-status:s' => { name => 'warning_status' },
|
||||||
"critical-status:s" => { name => 'critical_status' },
|
'critical-status:s' => { name => 'critical_status' },
|
||||||
"warning-numeric:s" => { name => 'warning_numeric' },
|
'warning-numeric:s' => { name => 'warning_numeric' },
|
||||||
"critical-numeric:s" => { name => 'critical_numeric' },
|
'critical-numeric:s' => { name => 'critical_numeric' },
|
||||||
"warning-string:s" => { name => 'warning_string' },
|
'warning-string:s' => { name => 'warning_string' },
|
||||||
"critical-string:s" => { name => 'critical_string' },
|
'critical-string:s' => { name => 'critical_string' },
|
||||||
"warning-time:s" => { name => 'warning_time' },
|
'warning-time:s' => { name => 'warning_time' },
|
||||||
"critical-time:s" => { name => 'critical_time' },
|
'critical-time:s' => { name => 'critical_time' },
|
||||||
"threshold-value:s" => { name => 'threshold_value', default => 'count' },
|
'threshold-value:s' => { name => 'threshold_value', default => 'count' },
|
||||||
"format-ok:s" => { name => 'format_ok', default => '%{count} element(s) found' },
|
'format-ok:s' => { name => 'format_ok', default => '%{count} element(s) found' },
|
||||||
"format-warning:s" => { name => 'format_warning', default => '%{count} element(s) found' },
|
'format-warning:s' => { name => 'format_warning', default => '%{count} element(s) found' },
|
||||||
"format-critical:s" => { name => 'format_critical', default => '%{count} element(s) found' },
|
'format-critical:s' => { name => 'format_critical', default => '%{count} element(s) found' },
|
||||||
"values-separator:s" => { name => 'values_separator', default => ', ' },
|
'values-separator:s' => { name => 'values_separator', default => ', ' },
|
||||||
});
|
});
|
||||||
$self->{count} = 0;
|
$self->{count} = 0;
|
||||||
$self->{count_ok} = 0;
|
$self->{count_ok} = 0;
|
||||||
|
@ -216,11 +216,13 @@ sub lookup {
|
||||||
$self->{'count_' . $exit}++;
|
$self->{'count_' . $exit}++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => 'count',
|
$self->{output}->perfdata_add(
|
||||||
value => $self->{count},
|
label => 'count',
|
||||||
warning => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef,
|
value => $self->{count},
|
||||||
critical => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef,
|
warning => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef,
|
||||||
min => 0);
|
critical => $self->{option_results}->{threshold_value} eq 'count' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef,
|
||||||
|
min => 0
|
||||||
|
);
|
||||||
|
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach my $value (@{$self->{values}}) {
|
foreach my $value (@{$self->{values}}) {
|
||||||
|
@ -232,10 +234,12 @@ sub lookup {
|
||||||
push @{$self->{'values_' . $exit}}, $value;
|
push @{$self->{'values_' . $exit}}, $value;
|
||||||
$self->{'count_' . $exit}++
|
$self->{'count_' . $exit}++
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(label => 'element_' . $count,
|
$self->{output}->perfdata_add(
|
||||||
value => $value,
|
label => 'element_' . $count,
|
||||||
warning => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef,
|
value => $value,
|
||||||
critical => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef);
|
warning => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-numeric') : undef,
|
||||||
|
critical => $self->{option_results}->{threshold_value} eq 'values' ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-numeric') : undef
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (defined($self->{option_results}->{critical_string}) && $self->{option_results}->{critical_string} ne '' &&
|
if (defined($self->{option_results}->{critical_string}) && $self->{option_results}->{critical_string} ne '' &&
|
||||||
$value =~ /$self->{option_results}->{critical_string}/) {
|
$value =~ /$self->{option_results}->{critical_string}/) {
|
||||||
|
@ -262,7 +266,10 @@ sub run {
|
||||||
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
|
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => $self->{soap_response}, debug => 1);
|
$self->{output}->output_add(long_msg => $self->{soap_response}, debug => 1);
|
||||||
if (!defined($self->{option_results}->{lookup}) || scalar(@{$self->{option_results}->{lookup}}) == 0) {
|
if (!defined($self->{option_results}->{lookup}) ||
|
||||||
|
scalar(@{$self->{option_results}->{lookup}}) == 0 ||
|
||||||
|
$self->{option_results}->{lookup} eq ''
|
||||||
|
) {
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => "SOAP request success");
|
short_msg => "SOAP request success");
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,11 +284,13 @@ sub run {
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->output_add(long_msg => sprintf("Response time %.3fs", $timeelapsed));
|
$self->{output}->output_add(long_msg => sprintf("Response time %.3fs", $timeelapsed));
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(label => "time", unit => 's',
|
$self->{output}->perfdata_add(
|
||||||
value => sprintf('%.3f', $timeelapsed),
|
label => "time", unit => 's',
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-time'),
|
value => sprintf('%.3f', $timeelapsed),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-time'),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-time'),
|
||||||
min => 0);
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-time'),
|
||||||
|
min => 0
|
||||||
|
);
|
||||||
|
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
|
|
Loading…
Reference in New Issue