This commit is contained in:
garnier-quentin 2016-01-12 12:26:07 +01:00
parent 828b17ae77
commit 60c6592cc2
1 changed files with 59 additions and 124 deletions

View File

@ -20,11 +20,53 @@
package network::juniper::common::ive::mode::users;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{global} = [
{ label => 'web', set => {
key_values => [ { name => 'web' } ],
output_template => 'Current concurrent signed-in web users connections: %s', output_error_template => 'Current concurrent signed-in web users connections: %s',
perfdatas => [
{ label => 'web', value => 'web_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'meeting', set => {
key_values => [ { name => 'meeting' } ],
output_template => 'Current concurrent meeting users connections: %s', output_error_template => 'Current concurrent meeting users connections: %s',
perfdatas => [
{ label => 'meeting', value => 'meeting_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'node', set => {
key_values => [ { name => 'node' } ],
output_template => 'Current concurrent node logged users connections: %s', output_error_template => 'Current concurrent node logged users connections: %s',
perfdatas => [
{ label => 'node', value => 'node_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'cluster', set => {
key_values => [ { name => 'cluster' } ],
output_template => 'Current concurrent cluster logged users connections: %s', output_error_template => 'Current concurrent cluster logged users connections: %s',
perfdatas => [
{ label => 'cluster', value => 'cluster_absolute', template => '%s', min => 0 },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -33,114 +75,24 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning-web:s" => { name => 'warning_web' },
"critical-web:s" => { name => 'critical_web' },
"warning-meeting:s" => { name => 'warning_meeting' },
"critical-meeting:s" => { name => 'critical_meeting' },
"warning-node:s" => { name => 'warning_node' },
"critical-node:s" => { name => 'critical_node' },
"warning-cluster:s" => { name => 'warning_cluster' },
"critical-cluster:s" => { name => 'critical_cluster' },
});
return $self;
}
sub check_options {
sub manage_selection {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning_web', value => $self->{option_results}->{warning_web})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning web threshold '" . $self->{option_results}->{warning_web} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical_web', value => $self->{option_results}->{critical_web})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical web threshold '" . $self->{option_results}->{critical_web} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning_meeting', value => $self->{option_results}->{warning_meeting})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning meeting threshold '" . $self->{option_results}->{warning_meeting} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical_meeting', value => $self->{option_results}->{critical_meeting})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical meeting threshold '" . $self->{option_results}->{critical_meeting} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning_node', value => $self->{option_results}->{warning_node})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning node threshold '" . $self->{option_results}->{warning_node} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical_node', value => $self->{option_results}->{critical_node})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical node threshold '" . $self->{option_results}->{critical_node} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning_cluster', value => $self->{option_results}->{warning_cluster})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning cluster threshold '" . $self->{option_results}->{warning_cluster} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical_cluster', value => $self->{option_results}->{critical_cluster})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical cluster threshold '" . $self->{option_results}->{critical_cluster} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_signedInWebUsers = '.1.3.6.1.4.1.12532.2.0';
my $oid_meetingUserCount = '.1.3.6.1.4.1.12532.9.0';
my $oid_iveConcurrentUsers = '.1.3.6.1.4.1.12532.12.0';
my $oid_clusterConcurrentUsers = '.1.3.6.1.4.1.12532.13.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_signedInWebUsers, $oid_meetingUserCount,
$oid_iveConcurrentUsers, $oid_clusterConcurrentUsers], nothing_quit => 1);
my $exit1 = $self->{perfdata}->threshold_check(value => $result->{$oid_signedInWebUsers},
threshold => [ { label => 'critical_web', 'exit_litteral' => 'critical' }, { label => 'warning_web', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $result->{$oid_meetingUserCount},
threshold => [ { label => 'critical_meeting', 'exit_litteral' => 'critical' }, { label => 'warning_meeting', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $result->{$oid_iveConcurrentUsers},
threshold => [ { label => 'critical_node', 'exit_litteral' => 'critical' }, { label => 'warning_node', exit_litteral => 'warning' } ]);
my $exit4 = $self->{perfdata}->threshold_check(value => $result->{$oid_clusterConcurrentUsers},
threshold => [ { label => 'critical_cluster', 'exit_litteral' => 'critical' }, { label => 'warning_cluster', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit1,
short_msg => sprintf("Current concurrent signed-in web users connections: %d",
$result->{$oid_signedInWebUsers}));
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Current concurrent meeting users connections: %s",
defined($result->{$oid_meetingUserCount}) ? $result->{$oid_meetingUserCount} : 'unknown'));
$self->{output}->output_add(severity => $exit3,
short_msg => sprintf("Current concurrent node logged users connections: %d",
$result->{$oid_iveConcurrentUsers}));
$self->{output}->output_add(severity => $exit4,
short_msg => sprintf("Current concurrent cluster logged users connections: %d",
$result->{$oid_clusterConcurrentUsers}));
$self->{output}->perfdata_add(label => "web",
value => $result->{$oid_signedInWebUsers},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_web'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_web'),
min => 0);
$self->{output}->perfdata_add(label => "meeting",
value => $result->{$oid_meetingUserCount},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_meeting'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_meeting'),
min => 0);
$self->{output}->perfdata_add(label => "node",
value => $result->{$oid_iveConcurrentUsers},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_node'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_node'),
min => 0);
$self->{output}->perfdata_add(label => "cluster",
value => $result->{$oid_clusterConcurrentUsers},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_cluster'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_cluster'),
min => 0);
$self->{output}->display();
$self->{output}->exit();
my $result = $options{snmp}->get_leef(oids => [$oid_signedInWebUsers, $oid_meetingUserCount,
$oid_iveConcurrentUsers, $oid_clusterConcurrentUsers], nothing_quit => 1);
$self->{global} = { web => $result->{$oid_signedInWebUsers},
meeting => $result->{$oid_meetingUserCount},
node => $result->{$oid_iveConcurrentUsers},
cluster => $result->{$oid_clusterConcurrentUsers} };
}
1;
@ -153,37 +105,20 @@ Check users connections (web users, cluster users, node users, meeting users) (J
=over 8
=item B<--warning-web>
=item B<--filter-counters>
Threshold warning for users connected and uses the web feature.
Only display some counters (regexp can be used).
Example: --filter-counters='^web|meeting$'
=item B<--critical-web>
=item B<--warning-*>
Threshold critical for users connected and uses the web feature.
Threshold warning.
Can be: 'web', 'meeting', 'node', 'cluster'.
=item B<--warning-meeting>
=item B<--critical-*>
Threshold warning for secure meeting users connected.
=item B<--critical-meeting>
Threshold critical for secure meeting users connected.
=item B<--warning-node>
Threshold warning for users in this node that are logged in.
=item B<--critical-node>
Threshold critical for users in this node that are logged in.
=item B<--warning-cluster>
Threshold warning for users in this cluster that are logged in.
=item B<--critical-cluster>
Threshold critical for users in this cluster that are logged in.
Threshold critical.
Can be: 'web', 'meeting', 'node', 'cluster'.
=back