Update sessions.pm
Add failed sessions monitoring https://github.com/centreon/centreon-plugins/issues/158
This commit is contained in:
parent
d825452bfc
commit
6b90ad23d5
|
@ -34,7 +34,9 @@ sub new {
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>
|
||||||
{
|
{
|
||||||
"warning:s" => { name => 'warning', },
|
"warning:s" => { name => 'warning', },
|
||||||
|
"warning-failed:s" => { name => 'warning_failed', },
|
||||||
"critical:s" => { name => 'critical', },
|
"critical:s" => { name => 'critical', },
|
||||||
|
"critical-failed:s" => { name => 'critical_failed', },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -52,6 +54,14 @@ sub check_options {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'warning-failed', value => $self->{option_results}->{warning_failed})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong warning-failed threshold '" . $self->{option_results}->{warning_failed} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
if (($self->{perfdata}->threshold_validate(label => 'critical-failed', value => $self->{option_results}->{critical_failed})) == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Wrong critical-failed threshold '" . $self->{option_results}->{critical_failed} . "'.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
@ -61,26 +71,38 @@ sub run {
|
||||||
|
|
||||||
my $oid_nsResSessAllocate = '.1.3.6.1.4.1.3224.16.3.2.0';
|
my $oid_nsResSessAllocate = '.1.3.6.1.4.1.3224.16.3.2.0';
|
||||||
my $oid_nsResSessMaxium = '.1.3.6.1.4.1.3224.16.3.3.0';
|
my $oid_nsResSessMaxium = '.1.3.6.1.4.1.3224.16.3.3.0';
|
||||||
|
my $oid_nsResSessFailed = '.1.3.6.1.4.1.3224.16.3.4.0';
|
||||||
|
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium], nothing_quit => 1);
|
my $result = $self->{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium, $oid_nsResSessFailed], nothing_quit => 1);
|
||||||
|
|
||||||
my $spu_done = 0;
|
my $spu_done = 0;
|
||||||
my $cp_total = $result->{$oid_nsResSessMaxium};
|
my $cp_total = $result->{$oid_nsResSessMaxium};
|
||||||
my $cp_used = $result->{$oid_nsResSessAllocate};
|
my $cp_used = $result->{$oid_nsResSessAllocate};
|
||||||
|
my $cp_failed = $result->{oid_nsResSessAllocate};
|
||||||
my $prct_used = $cp_used * 100 / $cp_total;
|
my $prct_used = $cp_used * 100 / $cp_total;
|
||||||
|
my $prct_failed = $cp_failed * 100 / $cp_total;
|
||||||
$spu_done = 1;
|
$spu_done = 1;
|
||||||
my $exit_code = $self->{perfdata}->threshold_check(value => $prct_used,
|
|
||||||
|
my $exit_used = $self->{perfdata}->threshold_check(value => $prct_used,
|
||||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
|
my $exit_failed = $self->{perfdata}->threshold_check(value => $prct_failed,
|
||||||
|
threshold => [ { label => 'critical-failed', 'exit_litteral' => 'critical' }, { label => 'warning-failed', exit_litteral => 'warning' } ]);
|
||||||
|
my $exit_code = $self->{output}->get_most_critical(status => [ $exit_failed, $exit_used ]);
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit_code,
|
$self->{output}->output_add(severity => $exit_code,
|
||||||
short_msg => sprintf("%.2f%% of the sessions limit reached (%d of max. %d)",
|
short_msg => sprintf("%.2f%% of the sessions limit reached (%d of max. %d)",
|
||||||
$prct_used, $cp_used, $cp_total));
|
$prct_used, $cp_used, $cp_total));
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => 'sessions',
|
$self->{output}->perfdata_add(label => 'sessions',
|
||||||
value => $cp_used,
|
value => $cp_used,
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $cp_total, cast_int => 1),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $cp_total, cast_int => 1),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $cp_total, cast_int => 1),
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $cp_total, cast_int => 1),
|
||||||
min => 0, max => $cp_total);
|
min => 0, max => $cp_total);
|
||||||
|
$self->{output}->perfdata_add(label => 'sessions_failed',
|
||||||
|
value => $cp_failed,
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-failed', total => $cp_total, cast_int => 1),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-failed', total => $cp_total, cast_int => 1),
|
||||||
|
min => 0, max => $cp_total);
|
||||||
|
|
||||||
if ($spu_done == 0) {
|
if ($spu_done == 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot check sessions usage (no total values).");
|
$self->{output}->add_option_msg(short_msg => "Cannot check sessions usage (no total values).");
|
||||||
|
@ -95,19 +117,25 @@ sub run {
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
=head1 MODE
|
Check Juniper sessions usage and failed sessions (NETSCREEN-RESOURCE-MIB).
|
||||||
|
|
||||||
Check Juniper sessions usage (NETSCREEN-RESOURCE-MIB).
|
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning>
|
||||||
|
|
||||||
Threshold warning in percent.
|
Threshold warning (percentage).
|
||||||
|
|
||||||
=item B<--critical>
|
=item B<--critical>
|
||||||
|
|
||||||
Threshold critical in percent.
|
Threshold critical (percentage).
|
||||||
|
|
||||||
|
=item B<--warning-failed>
|
||||||
|
|
||||||
|
Threshold warning on failed sessions (percentage).
|
||||||
|
|
||||||
|
=item B<--critical-failed>
|
||||||
|
|
||||||
|
Threshold critical in failed sessions (percentage).
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue