commit
c0bf29235f
|
@ -27,7 +27,7 @@ It seems that 'os::linux::snmp::plugin' is the good one. So i verify with the op
|
|||
Plugin Description:
|
||||
Check Linux operating systems in SNMP.
|
||||
|
||||
It's exactly what i need. Now i'll the option ``--list-mode`` to know what can i do with it:
|
||||
It's exactly what i need. Now i'll add the option ``--list-mode`` to know what can i do with it:
|
||||
|
||||
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --list-mode
|
||||
...
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -360,14 +360,14 @@ Threshold for HTTP timeout
|
|||
|
||||
Threshold unit (Default: '%'. Can be: '%' or 'absolute')
|
||||
|
||||
=item B<--warning>
|
||||
=item B<--warning-*>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'busy', 'free', 'waiting', 'starting', 'reading',
|
||||
'sending', 'keepalive', 'dns-lookup', 'closing',
|
||||
'logging', 'gracefuly-finished', 'idle-cleanup-worker'.
|
||||
|
||||
=item B<--critical>
|
||||
=item B<--critical-*>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'busy', 'free', 'waiting', 'starting', 'reading',
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -82,7 +82,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::centreon::map::jmx::mode::elements;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => "com.centreon.studio.map:name=BusinessElement,type=repo" }
|
||||
];
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
my $elements = $result->{"com.centreon.studio.map:name=BusinessElement,type=repo"}->{LoadedModelCount};
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $elements,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Element loaded : %d",
|
||||
$result->{"com.centreon.studio.map:name=BusinessElement,type=repo"}->{LoadedModelCount}));
|
||||
|
||||
$self->{output}->perfdata_add(label => 'elements',
|
||||
value => $result->{"com.centreon.studio.map:name=BusinessElement,type=repo"}->{LoadedModelCount},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Centreon Map Open Gates
|
||||
|
||||
Example:
|
||||
|
||||
perl centreon_plugins.pl --plugin=apps::centreon::map::jmx::plugin --custommode=jolokia --url=http://10.30.2.22:8080/jolokia-war --mode=elements
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set this threshold if you want a warning if opened gates match condition
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set this threshold if you want a warning if opened gates match condition
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -55,7 +55,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
|
|
|
@ -55,7 +55,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{request} = [
|
||||
|
|
|
@ -27,11 +27,11 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'gates' => 'apps::centreon::map::jmx::mode::gates',
|
||||
'elements' => 'apps::centreon::map::jmx::mode::elements',
|
||||
'sessions' => 'apps::centreon::map::jmx::mode::sessions',
|
||||
'event-queue' => 'apps::centreon::map::jmx::mode::eventqueue',
|
||||
'event-statistics' => 'apps::centreon::map::jmx::mode::eventstatistics',
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -66,7 +66,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
|
|
|
@ -66,7 +66,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
|
|
|
@ -66,7 +66,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
|
|
|
@ -66,7 +66,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -67,7 +67,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_lnDeadMail = '.1.3.6.1.4.1.334.72.1.1.4.1.0';
|
||||
|
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_lnAverageMailDeliverTime = '.1.3.6.1.4.1.334.72.1.1.4.9.0';
|
||||
|
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_lnServerAvailabilityIndex = '.1.3.6.1.4.1.334.72.1.1.6.3.19.0';
|
||||
|
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_lnServerTransPerMin = '.1.3.6.1.4.1.334.72.1.1.6.3.2.0';
|
||||
|
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_lnServerUsers = '.1.3.6.1.4.1.334.72.1.1.6.3.6.0';
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::msmq::local::mode::listqueues;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Win32::OLE;
|
||||
|
||||
my %state_map = (
|
||||
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"filter-state:s" => { name => 'filter_state' },
|
||||
});
|
||||
$self->{result} = {};
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $objMsmqApp = Win32::OLE->CreateObject('MSMQ.MSMQApplication');
|
||||
print Data::Dumper::Dumper($objMsmqApp);
|
||||
|
||||
if (defined($objMsmqApp->{PrivateQueues})) {
|
||||
foreach my $queue_name (@{$objMsmqApp->{PrivateQueues}}) {
|
||||
|
||||
my $objQueue = Win32::OLE->CreateObject('MSMQ.MSMQApplication');
|
||||
$objQueue->init(undef, undef, "DIRECT=OS:" . $queue_name);
|
||||
use Data::Dumper;
|
||||
print Data::Dumper::Dumper($objQueue->{MessageCount});
|
||||
}
|
||||
}
|
||||
|
||||
exit(1);
|
||||
#if (!defined($wmi)) {
|
||||
# $self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError());
|
||||
# $self->{output}->option_exit();
|
||||
#}
|
||||
#my $query = 'SELECT Name, AutoStart FROM ApplicationPool';
|
||||
#my $resultset = $wmi->ExecQuery($query);
|
||||
my $resultset;
|
||||
# AutoStart -> 1/0
|
||||
foreach my $obj (in $resultset) {
|
||||
my $name = $obj->{Name};
|
||||
my $auto_start = $obj->{AutoStart};
|
||||
my $state = $obj->GetState();
|
||||
|
||||
if (defined($self->{option_results}->{filter_state}) && $state_map{$state} !~ /$self->{option_results}->{filter_state}/) {
|
||||
next;
|
||||
}
|
||||
|
||||
next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && $name ne $self->{option_results}->{name});
|
||||
next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && $name !~ /$self->{option_results}->{name}/);
|
||||
|
||||
$self->{result}->{$name} = {AutoStart => $auto_start, State => $state};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->manage_selection();
|
||||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
$self->{output}->output_add(long_msg => "'" . $name . "' [AutoStart = " . $self->{result}->{$name}->{AutoStart} . ', ' .
|
||||
'State = ' . $state_map{$self->{result}->{$name}->{State}} .
|
||||
']');
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'List application pools:');
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => ['name', 'auto_start', 'state']);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->manage_selection();
|
||||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
$self->{output}->add_disco_entry(name => $name,
|
||||
auto_start => $self->{result}->{$name}->{AutoStart},
|
||||
state => $state_map{$self->{result}->{$name}->{State}}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List IIS Application Pools.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Set the application pool name.
|
||||
|
||||
=item B<--regexp>
|
||||
|
||||
Allows to use regexp to filter application pool name (with option --name).
|
||||
|
||||
=item B<--filter-state>
|
||||
|
||||
Filter application pool state. Regexp can be used.
|
||||
Available states are:
|
||||
- 'started',
|
||||
- 'starting',
|
||||
- 'stopped',
|
||||
- 'stopping'
|
||||
- 'unknown'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -80,7 +80,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
|
|
|
@ -60,7 +60,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
||||
|
|
|
@ -58,7 +58,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_pfsenseStatus = '.1.3.6.1.4.1.12325.1.200.1.1.1.0';
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -89,7 +89,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_bgpPeerTable = '.1.3.6.1.2.1.15.3';
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -71,9 +71,9 @@ sub new {
|
|||
"warning-time:s" => { name => 'warning_time' },
|
||||
"critical-time:s" => { name => 'critical_time' },
|
||||
"threshold-value:s" => { name => 'threshold_value', default => 'count' },
|
||||
"format-ok:s" => { name => 'format_ok', default => '%{count} element(s) finded' },
|
||||
"format-warning:s" => { name => 'format_warning', default => '%{count} element(s) finded' },
|
||||
"format-critical:s" => { name => 'format_critical', default => '%{count} element(s) finded' },
|
||||
"format-ok:s" => { name => 'format_ok', 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' },
|
||||
"values-separator:s" => { name => 'values_separator', default => ', ' },
|
||||
});
|
||||
$self->{count} = 0;
|
||||
|
@ -296,7 +296,7 @@ FORMAT OPTIONS:
|
|||
|
||||
=item B<--format-ok>
|
||||
|
||||
Output format (Default: '%{count} element(s) finded')
|
||||
Output format (Default: '%{count} element(s) found')
|
||||
Can used:
|
||||
'%{values}' = display all values (also text string)
|
||||
'%{values_ok}' = values from attributes and text node only (seperated by option values-separator)
|
||||
|
@ -304,11 +304,11 @@ Can used:
|
|||
|
||||
=item B<--format-warning>
|
||||
|
||||
Output warning format (Default: %{count} element(s) finded')
|
||||
Output warning format (Default: %{count} element(s) found')
|
||||
|
||||
=item B<--format-critical>
|
||||
|
||||
Output critical format (Default: %{count} element(s) finded')
|
||||
Output critical format (Default: %{count} element(s) found')
|
||||
|
||||
=item B<--values-separator>
|
||||
|
||||
|
|
|
@ -70,9 +70,9 @@ sub new {
|
|||
"warning-time:s" => { name => 'warning_time' },
|
||||
"critical-time:s" => { name => 'critical_time' },
|
||||
"threshold-value:s" => { name => 'threshold_value', default => 'count' },
|
||||
"format-ok:s" => { name => 'format_ok', default => '%{count} element(s) finded' },
|
||||
"format-warning:s" => { name => 'format_warning', default => '%{count} element(s) finded' },
|
||||
"format-critical:s" => { name => 'format_critical', default => '%{count} element(s) finded' },
|
||||
"format-ok:s" => { name => 'format_ok', 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' },
|
||||
"values-separator:s" => { name => 'values_separator', default => ', ' },
|
||||
});
|
||||
$self->{count} = 0;
|
||||
|
@ -120,7 +120,7 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "You need to specify data.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
$self->{http}->add_header(key => 'SOAPAction', value => $self->{option_results}->{service_soap});
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ FORMAT OPTIONS:
|
|||
|
||||
=item B<--format-ok>
|
||||
|
||||
Output format (Default: '%{count} element(s) finded')
|
||||
Output format (Default: '%{count} element(s) found')
|
||||
Can used:
|
||||
'%{values}' = display all values (also text string)
|
||||
'%{values_ok}' = values from attributes and text node only (seperated by option values-separator)
|
||||
|
@ -317,11 +317,11 @@ Can used:
|
|||
|
||||
=item B<--format-warning>
|
||||
|
||||
Output warning format (Default: %{count} element(s) finded')
|
||||
Output warning format (Default: %{count} element(s) found')
|
||||
|
||||
=item B<--format-critical>
|
||||
|
||||
Output critical format (Default: %{count} element(s) finded')
|
||||
Output critical format (Default: %{count} element(s) found')
|
||||
|
||||
=item B<--values-separator>
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -227,7 +227,6 @@ sub find_values {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -0,0 +1,206 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::protocols::telnet::mode::scenario;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
use JSON;
|
||||
use Net::Telnet;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"scenario:s" => { name => 'scenario' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => 23 },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
# Example of a scenario file:
|
||||
# [
|
||||
# {"cmd": "open", "options": { "Host": "10.0.0.1", "Port": "23", "Timeout": "30" } },
|
||||
# {"cmd": "login", "options": { "Name": "admin", "Password": "pass", "Timeout": "5" } },
|
||||
# {"cmd": "waitfor", "options": { "Match": "/string/", "Timeout": "5" } },
|
||||
# {"cmd": "put", "options": { "String": "/mystring/", "Timeout": "5" } },
|
||||
# {"cmd": "close" }
|
||||
#]
|
||||
if (!defined($self->{option_results}->{scenario})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Please specify a scenario file.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub read_scenario {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $content_scenario;
|
||||
if (-f $self->{option_results}->{scenario}) {
|
||||
$content_scenario = do {
|
||||
local $/ = undef;
|
||||
if (!open my $fh, "<", $self->{option_results}->{scenario}) {
|
||||
$self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{scenario} : $!");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
<$fh>;
|
||||
};
|
||||
} else {
|
||||
$content_scenario = $self->{option_results}->{scenario};
|
||||
}
|
||||
|
||||
eval {
|
||||
$self->{json_scenario} = decode_json($content_scenario);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json scenario");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub execute_scenario {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $timing0 = [gettimeofday];
|
||||
my $session = new Net::Telnet();
|
||||
$session->errmode('return');
|
||||
|
||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||
if (!$session->open(Host => $self->{option_results}->{hostname}, Port => $self->{option_results}->{port}, Timeout => 30)) {
|
||||
$self->{output}->output_add(severity => 'critical',
|
||||
short_msg => sprintf("cannot open session: %s", $session->errmsg()));
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
my ($step_ok, $exit1) = (0, 'OK');
|
||||
my $step_total = scalar(@{$self->{json_scenario}});
|
||||
foreach my $cmd (@{$self->{json_scenario}}) {
|
||||
next if (!defined($cmd->{cmd}));
|
||||
if ($cmd->{cmd} !~ /^(open|login|waitfor|put|close)$/i) {
|
||||
$self->{output}->add_option_msg(short_msg => "command '$cmd->{cmd}' is not managed");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $cmd_name = lc($cmd->{cmd});
|
||||
my $method = $session->can($cmd_name);
|
||||
if ($method) {
|
||||
my $ret = $method->($session, defined($cmd->{options}) ? %{$cmd->{options}} : undef);
|
||||
if (!defined($ret)) {
|
||||
$self->{output}->output_add(long_msg => sprintf("errmsg: %s", $session->errmsg()));
|
||||
$exit1 = 'CRITICAL';
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$step_ok++;
|
||||
}
|
||||
|
||||
my $timeelapsed = tv_interval($timing0, [gettimeofday]);
|
||||
my $exit2 = $self->{perfdata}->threshold_check(value => $timeelapsed,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("%d/%d steps (%.3fs)", $step_ok, $step_total, $timeelapsed));
|
||||
|
||||
$self->{output}->perfdata_add(label => "time", unit => 's',
|
||||
value => sprintf('%.3f', $timeelapsed),
|
||||
min => 0,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
||||
$self->{output}->perfdata_add(label => "steps",
|
||||
value => $step_ok,
|
||||
min => 0,
|
||||
max => $step_total);
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->read_scenario();
|
||||
$self->execute_scenario();
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check telnet scenario execution
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--scenario>
|
||||
|
||||
Scenario used (Required).
|
||||
Can be a file or json content.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set global execution timeout (Default: 50)
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Set telnet hostname.
|
||||
Could be used if you want to use the same scenario for X hosts.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Set telnet port.
|
||||
Could be used if you want to use the same scenario for X hosts.
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning in seconds (Scenario execution time)
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical in seconds (Scenario execution time)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,47 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::protocols::telnet::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_simple);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'scenario' => 'apps::protocols::telnet::mode::scenario',
|
||||
);
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check telnet server.
|
||||
|
||||
=cut
|
|
@ -67,7 +67,11 @@ sub check_options {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $icmp_sock = new IO::Socket::INET(Proto=>"icmp");
|
||||
my $icmp_sock = new IO::Socket::INET(Proto => "icmp");
|
||||
if (!defined($icmp_sock)) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot create socket: $!");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my $read_set = new IO::Select();
|
||||
$read_set->add($icmp_sock);
|
||||
|
||||
|
@ -78,7 +82,8 @@ sub run {
|
|||
|
||||
$sock->send("Hello");
|
||||
close($sock);
|
||||
(my $new_readable) = IO::Select->select($read_set, undef, undef, $self->{option_results}->{timeout});
|
||||
|
||||
my ($new_readable) = IO::Select->select($read_set, undef, undef, $self->{option_results}->{timeout});
|
||||
my $icmp_arrived = 0;
|
||||
foreach $sock (@$new_readable) {
|
||||
if ($sock == $icmp_sock) {
|
||||
|
@ -89,8 +94,8 @@ sub run {
|
|||
close($icmp_sock);
|
||||
|
||||
if ($icmp_arrived == 1) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Connection failed on port %s", $self->{option_results}->{port}));
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Connection failed on port %s", $self->{option_results}->{port}));
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("Connection success on port %s", $self->{option_results}->{port}));
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -26,7 +26,8 @@ use strict;
|
|||
use warnings;
|
||||
use IO::Socket::SSL;
|
||||
use Net::SSLeay;
|
||||
use Date::Manip;
|
||||
use Socket;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -79,7 +80,6 @@ sub run {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
# Global variables
|
||||
|
||||
my $client = IO::Socket::SSL->new(
|
||||
PeerHost => $self->{option_results}->{hostname},
|
||||
PeerPort => $self->{option_results}->{port},
|
||||
|
@ -101,22 +101,25 @@ sub run {
|
|||
$self->{output}->display();
|
||||
$self->{output}->exit()
|
||||
}
|
||||
|
||||
my $subject = Net::SSLeay::X509_NAME_get_text_by_NID(
|
||||
Net::SSLeay::X509_get_subject_name($cert), 13); # NID_CommonName
|
||||
$subject =~ s{\0$}{}; # work around Bug in Net::SSLeay <1.33
|
||||
|
||||
#Expiration Date
|
||||
if ($self->{option_results}->{validity_mode} eq 'expiration') {
|
||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Date::Manip',
|
||||
error_msg => "Cannot load module 'Date::Manip'.");
|
||||
(my $notafterdate = Net::SSLeay::P_ASN1_UTCTIME_put2string(Net::SSLeay::X509_get_notAfter($cert))) =~ s/ GMT//;
|
||||
my $daysbefore = int((&UnixDate(&ParseDate($notafterdate),"%s") - time) / 86400);
|
||||
my $daysbefore = int((Date::Manip::UnixDate(Date::Manip::ParseDate($notafterdate),"%s") - time) / 86400);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $daysbefore,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Certificate expiration days: %s - Validity Date: %s", $daysbefore, $notafterdate));
|
||||
short_msg => sprintf("Certificate expiration for '%s' in days: %s - Validity Date: %s", $subject, $daysbefore, $notafterdate));
|
||||
#Subject Name
|
||||
} elsif ($self->{option_results}->{validity_mode} eq 'subject') {
|
||||
my @subject_matched = ();
|
||||
|
||||
my $subject = Net::SSLeay::X509_NAME_get_text_by_NID(
|
||||
Net::SSLeay::X509_get_subject_name($cert), 13); # NID_CommonName
|
||||
$subject =~s{\0$}{}; # work around Bug in Net::SSLeay <1.33
|
||||
if ($subject =~ /$self->{option_results}->{subjectname}/mi) {
|
||||
push @subject_matched, $subject;
|
||||
} else {
|
||||
|
@ -124,16 +127,17 @@ sub run {
|
|||
}
|
||||
|
||||
my @subject_alt_names = Net::SSLeay::X509_get_subjectAltNames($cert);
|
||||
for (my $i = 0; $i < $#subject_alt_names; $i++) {
|
||||
next if ($i % 2 == 0);
|
||||
if ($subject_alt_names[$i] =~ /$self->{option_results}->{subjectname}/mi) {
|
||||
push @subject_matched, $subject_alt_names[$i];
|
||||
for (my $i = 0; $i < $#subject_alt_names; $i += 2) {
|
||||
my ($type, $name) = ($subject_alt_names[$i], $subject_alt_names[$i + 1]);
|
||||
if ($type == GEN_IPADD) {
|
||||
$name = inet_ntoa($name);
|
||||
}
|
||||
if ($name =~ /$self->{option_results}->{subjectname}/mi) {
|
||||
push @subject_matched, $name;
|
||||
} else {
|
||||
$self->{output}->output_add(long_msg => sprintf("Subject Name '%s' is also present in Certificate", $subject_alt_names[$i]), debug => 1);
|
||||
$self->{output}->output_add(long_msg => sprintf("Subject Name '%s' is also present in Certificate", $name), debug => 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (@subject_matched == 0) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
|
@ -148,10 +152,10 @@ sub run {
|
|||
my $issuer_name = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($cert));
|
||||
if ($issuer_name =~ /$self->{option_results}->{issuername}/mi) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("Issuer Name '%s' is present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name));
|
||||
short_msg => sprintf("Issuer Name '%s' is present in Certificate '%s': %s", $self->{option_results}->{issuername}, $subject, $issuer_name));
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Issuer Name '%s' is not present in Certificate: %s", $self->{option_results}->{issuername}, $issuer_name));
|
||||
short_msg => sprintf("Issuer Name '%s' is not present in Certificate '%s': %s", $self->{option_results}->{issuername}, $subject, $issuer_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::vmware::connector::mode::devicevm;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"vm-hostname:s" => { name => 'vm_hostname' },
|
||||
"filter" => { name => 'filter' },
|
||||
"scope-datacenter:s" => { name => 'scope_datacenter' },
|
||||
"scope-cluster:s" => { name => 'scope_cluster' },
|
||||
"scope-host:s" => { name => 'scope_host' },
|
||||
"filter-description:s" => { name => 'filter_description' },
|
||||
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
|
||||
"nopoweredon-status:s" => { name => 'nopoweredon_status', default => 'unknown' },
|
||||
"display-description" => { name => 'display_description' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"device:s" => { name => 'device' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $label (('warning', 'critical')) {
|
||||
if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) {
|
||||
my ($label_opt) = $label;
|
||||
$label_opt =~ tr/_/-/;
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($self->{option_results}->{device}) || $self->{option_results}->{device} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Please set device option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{nopoweredon_status}) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong nopoweredon-status option '" . $self->{option_results}->{nopoweredon_status} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
$self->{connector}->add_params(params => $self->{option_results},
|
||||
command => 'devicevm');
|
||||
$self->{connector}->run();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check virtual machine device connected.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--vm-hostname>
|
||||
|
||||
VM hostname to check.
|
||||
If not set, we check all VMs.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
VM hostname is a regexp.
|
||||
|
||||
=item B<--filter-description>
|
||||
|
||||
Filter also virtual machines description (can be a regexp).
|
||||
|
||||
=item B<--scope-datacenter>
|
||||
|
||||
Search in following datacenter(s) (can be a regexp).
|
||||
|
||||
=item B<--scope-cluster>
|
||||
|
||||
Search in following cluster(s) (can be a regexp).
|
||||
|
||||
=item B<--scope-host>
|
||||
|
||||
Search in following host(s) (can be a regexp).
|
||||
|
||||
=item B<--disconnect-status>
|
||||
|
||||
Status if VM disconnected (default: 'unknown').
|
||||
|
||||
=item B<--nopoweredon-status>
|
||||
|
||||
Status if VM is not poweredOn (default: 'unknown').
|
||||
|
||||
=item B<--display-description>
|
||||
|
||||
Display virtual machine description.
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning in bytes per seconds.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical in bytes per seconds.
|
||||
|
||||
=item B<--device>
|
||||
|
||||
Device to check (Required) (Example: --device='VirtualCdrom').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -38,8 +38,11 @@ sub new {
|
|||
"scope-datacenter:s" => { name => 'scope_datacenter' },
|
||||
"scope-cluster:s" => { name => 'scope_cluster' },
|
||||
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"warning-state:s" => { name => 'warning_state' },
|
||||
"critical-state:s" => { name => 'critical_state' },
|
||||
"no-memory-state" => { name => 'no_memory_state' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
@ -48,13 +51,13 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
foreach my $label (('warning', 'critical', 'warning_state', 'critical_state')) {
|
||||
if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) {
|
||||
my ($label_opt) = $label;
|
||||
$label_opt =~ tr/_/-/;
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'.");
|
||||
|
@ -110,6 +113,18 @@ Threshold warning in percent.
|
|||
|
||||
Threshold critical in percent.
|
||||
|
||||
=item B<--warning-state>
|
||||
|
||||
Threshold warning. For state != 'high': --warning-state=0
|
||||
|
||||
=item B<--critical-state>
|
||||
|
||||
Threshold critical. For state != 'high': --warning-state=0
|
||||
|
||||
=item B<--no-memory-state>
|
||||
|
||||
Don't check memory state.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
@ -43,7 +42,8 @@ sub new {
|
|||
'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops',
|
||||
'datastore-snapshot' => 'apps::vmware::connector::mode::datastoresnapshot',
|
||||
'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage',
|
||||
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
|
||||
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
|
||||
'device-vm' => 'apps::vmware::connector::mode::devicevm',
|
||||
'getmap' => 'apps::vmware::connector::mode::getmap',
|
||||
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
||||
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -64,7 +64,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my ($result, $value);
|
||||
|
|
|
@ -82,7 +82,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my ($result, $value);
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -59,7 +59,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
# Nombre de ports audio utilise
|
||||
|
|
|
@ -59,7 +59,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
# Nombre de ports audio utilise
|
||||
|
|
|
@ -59,7 +59,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
# Nombre de ports audio utilise
|
||||
|
|
|
@ -59,7 +59,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
# Nombre de ports video utilise
|
||||
|
|
|
@ -28,7 +28,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
|
|
|
@ -0,0 +1,251 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::vtom::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s@" => { name => 'hostname' },
|
||||
"port:s@" => { name => 'port' },
|
||||
"proto:s@" => { name => 'proto' },
|
||||
"username:s@" => { name => 'username' },
|
||||
"password:s@" => { name => 'password' },
|
||||
"proxyurl:s@" => { name => 'proxyurl' },
|
||||
"timeout:s@" => { name => 'timeout' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{mode} = $options{mode};
|
||||
$self->{http} = centreon::plugins::http->new(output => $self->{output});
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
# Method to manage multiples
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
# options{options_result}
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
# Method to manage multiples
|
||||
sub set_defaults {
|
||||
my ($self, %options) = @_;
|
||||
# options{default}
|
||||
|
||||
# Manage default value
|
||||
foreach (keys %{$options{default}}) {
|
||||
if ($_ eq $self->{mode}) {
|
||||
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
|
||||
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
|
||||
if (!defined($self->{option_results}->{$opt}[$i])) {
|
||||
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
# return 1 = ok still hostname
|
||||
# return 0 = no hostname left
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef;
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : 30080;
|
||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'http';
|
||||
$self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : '';
|
||||
$self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : '';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10;
|
||||
$self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef;
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($self->{hostname}) ||
|
||||
scalar(@{$self->{option_results}->{hostname}}) == 0) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = $self->{hostname};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
$self->{option_results}->{port} = $self->{port};
|
||||
$self->{option_results}->{proto} = $self->{proto};
|
||||
$self->{option_results}->{proxyurl} = $self->{proxyurl};
|
||||
$self->{option_results}->{credentials} = 1;
|
||||
$self->{option_results}->{username} = $self->{username};
|
||||
$self->{option_results}->{password} = $self->{password};
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
}
|
||||
|
||||
sub cache_environment {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $has_cache_file = $options{statefile}->read(statefile => 'cache_vtom_env_' . $self->{hostname} . '_' . $self->{port});
|
||||
my $timestamp_cache = $options{statefile}->get(name => 'last_timestamp');
|
||||
my $environments = $options{statefile}->get(name => 'environments');
|
||||
if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($options{reload_cache_time}) * 60))) {
|
||||
$environments = {};
|
||||
my $datas = { last_timestamp => time(), environments => $environments };
|
||||
my $result = $self->get(path => '/api/environment/list');
|
||||
if (defined($result->{result}->{rows})) {
|
||||
foreach (@{$result->{result}->{rows}}) {
|
||||
$environments->{$_->{id}} = $_->{name};
|
||||
}
|
||||
}
|
||||
$options{statefile}->write(data => $datas);
|
||||
}
|
||||
|
||||
return $environments;
|
||||
}
|
||||
|
||||
sub cache_application {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $has_cache_file = $options{statefile}->read(statefile => 'cache_vtom_app_' . $self->{hostname} . '_' . $self->{port});
|
||||
my $timestamp_cache = $options{statefile}->get(name => 'last_timestamp');
|
||||
my $applications = $options{statefile}->get(name => 'applications');
|
||||
if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($options{reload_cache_time}) * 60))) {
|
||||
$applications = {};
|
||||
my $datas = { last_timestamp => time(), applications => $applications };
|
||||
my $result = $self->get(path => '/api/application/list');
|
||||
if (defined($result->{result}->{rows})) {
|
||||
foreach (@{$result->{result}->{rows}}) {
|
||||
$applications->{$_->{id}} = { name => $_->{name}, envSId => $_->{envSId} };
|
||||
}
|
||||
}
|
||||
$options{statefile}->write(data => $datas);
|
||||
}
|
||||
|
||||
return $applications;
|
||||
}
|
||||
|
||||
sub get {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings();
|
||||
|
||||
my $response = $self->{http}->request(url_path => $options{path},
|
||||
critical_status => '', warning_status => '');
|
||||
my $content;
|
||||
eval {
|
||||
$content = JSON::XS->new->utf8->decode($response);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (defined($content->{errmsg})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot get data: " . $content->{errmsg});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
VTOM REST API
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
VTOM Rest API custom mode
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
VTOM hostname.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Port used (Default: 30080)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'http')
|
||||
|
||||
=item B<--username>
|
||||
|
||||
Storeonce username.
|
||||
|
||||
=item B<--password>
|
||||
|
||||
Storeonce password.
|
||||
|
||||
=item B<--proxyurl>
|
||||
|
||||
Proxy URL if any
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set HTTP timeout
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,406 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::vtom::restapi::mode::jobstatus;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
|
||||
my $instance_mode;
|
||||
|
||||
sub custom_status_threshold {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
|
||||
eval "$instance_mode->{option_results}->{critical_status}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
|
||||
eval "$instance_mode->{option_results}->{warning_status}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
my $msg = 'status : ' . $self->{result_values}->{status};
|
||||
if ($self->{result_values}->{information} ne '') {
|
||||
$msg .= ' [information: ' . $self->{result_values}->{information} . ']';
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
|
||||
$self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'};
|
||||
$self->{result_values}->{environment} = $options{new_datas}->{$self->{instance} . '_environment'};
|
||||
$self->{result_values}->{application} = $options{new_datas}->{$self->{instance} . '_application'};
|
||||
$self->{result_values}->{exit_code} = $options{new_datas}->{$self->{instance} . '_exit_code'};
|
||||
$self->{result_values}->{family} = $options{new_datas}->{$self->{instance} . '_family'};
|
||||
$self->{result_values}->{information} = $options{new_datas}->{$self->{instance} . '_information'};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub custom_long_threshold {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($instance_mode->{option_results}->{critical_long}) && $instance_mode->{option_results}->{critical_long} ne '' &&
|
||||
eval "$instance_mode->{option_results}->{critical_long}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($instance_mode->{option_results}->{warning_long}) && $instance_mode->{option_results}->{warning_long} ne '' &&
|
||||
eval "$instance_mode->{option_results}->{warning_long}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub custom_long_output {
|
||||
my ($self, %options) = @_;
|
||||
my $msg = 'started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed});
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_long_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
|
||||
$self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'};
|
||||
$self->{result_values}->{environment} = $options{new_datas}->{$self->{instance} . '_environment'};
|
||||
$self->{result_values}->{application} = $options{new_datas}->{$self->{instance} . '_application'};
|
||||
$self->{result_values}->{elapsed} = $options{new_datas}->{$self->{instance} . '_elapsed'};
|
||||
$self->{result_values}->{family} = $options{new_datas}->{$self->{instance} . '_family'};
|
||||
|
||||
return -11 if ($self->{result_values}->{status} !~ /Running/i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', },
|
||||
{ name => 'job', type => 1, cb_prefix_output => 'prefix_job_output', message_multiple => 'All jobs are ok', , skipped_code => { -11 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{job} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'status' }, { name => 'name' }, { name => 'environment' },
|
||||
{ name => 'application' }, { name => 'exit_code' }, { name => 'family' }, { name => 'information' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => $self->can('custom_status_threshold'),
|
||||
}
|
||||
},
|
||||
{ label => 'long', threshold => 0, set => {
|
||||
key_values => [ { name => 'status' }, { name => 'name' }, { name => 'environment' },
|
||||
{ name => 'application' }, { name => 'elapsed' }, { name => 'family' } ],
|
||||
closure_custom_calc => $self->can('custom_long_calc'),
|
||||
closure_custom_output => $self->can('custom_long_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => $self->can('custom_long_threshold'),
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'total-error', set => {
|
||||
key_values => [ { name => 'error' }, { name => 'total' } ],
|
||||
output_template => 'Error : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_error', value => 'error_absolute', template => '%s',
|
||||
min => 0, max => 'total_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'total-running', set => {
|
||||
key_values => [ { name => 'running' }, { name => 'total' } ],
|
||||
output_template => 'Running : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_running', value => 'running_absolute', template => '%s',
|
||||
min => 0, max => 'total_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'total-unplanned', set => {
|
||||
key_values => [ { name => 'unplanned' }, { name => 'total' } ],
|
||||
output_template => 'Unplanned : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_unplanned', value => 'unplanned_absolute', template => '%s',
|
||||
min => 0, max => 'total_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'total-finished', set => {
|
||||
key_values => [ { name => 'finished' }, { name => 'total' } ],
|
||||
output_template => 'Finished : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_finished', value => 'finished_absolute', template => '%s',
|
||||
min => 0, max => 'total_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'total-coming', set => {
|
||||
key_values => [ { name => 'coming' }, { name => 'total' } ],
|
||||
output_template => 'Coming : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_coming', value => 'coming_absolute', template => '%s',
|
||||
min => 0, max => 'total_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-application:s" => { name => 'filter_application' },
|
||||
"filter-environment:s" => { name => 'filter_environment' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"filter-family:s" => { name => 'filter_family' },
|
||||
"warning-status:s" => { name => 'warning_status' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /Error/i' },
|
||||
"warning-long:s" => { name => 'warning_long' },
|
||||
"critical-long:s" => { name => 'critical_long' },
|
||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
||||
});
|
||||
$self->{statefile_cache_app} = centreon::plugins::statefile->new(%options);
|
||||
$self->{statefile_cache_env} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{statefile_cache_app}->check_options(%options);
|
||||
$self->{statefile_cache_env}->check_options(%options);
|
||||
$instance_mode = $self;
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Total Job ";
|
||||
}
|
||||
|
||||
sub prefix_job_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "job '" . $options{instance_value}->{environment} . '/' . $options{instance_value}->{application} . '/' . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning_status', 'critical_status', 'warning_long', 'critical_long')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %mapping_job_status = (
|
||||
R => 'Running',
|
||||
U => 'Unplanned',
|
||||
F => 'Finished',
|
||||
W => 'Coming',
|
||||
E => 'Error',
|
||||
);
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $environments = $options{custom}->cache_environment(statefile => $self->{statefile_cache_env},
|
||||
reload_cache_time => $self->{option_results}->{reload_cache_time});
|
||||
my $applications = $options{custom}->cache_application(statefile => $self->{statefile_cache_app},
|
||||
reload_cache_time => $self->{option_results}->{reload_cache_time});
|
||||
|
||||
$self->{job} = {};
|
||||
$self->{global} = { total => 0, running => 0, unplanned => 0, finished => 0, coming => 0, error => 0 };
|
||||
my $path = '/api/job/getAll';
|
||||
if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '') {
|
||||
$path = '/api/job/list?applicationName=' . $self->{option_results}->{filter_application};
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_environment}) && $self->{option_results}->{filter_environment} ne '') {
|
||||
$path = '/api/job/list?environmentName=' . $self->{option_results}->{filter_environment};
|
||||
}
|
||||
my $result = $options{custom}->get(path => $path);
|
||||
my $entries = defined($result->{result}) && ref($result->{result}) eq 'ARRAY' ?
|
||||
$result->{result} : (defined($result->{result}->{rows}) ?
|
||||
$result->{result}->{rows} : []);
|
||||
|
||||
my $current_time = time();
|
||||
foreach my $entry (@{$entries}) {
|
||||
my $application_sid = defined($entry->{applicationSId}) ? $entry->{applicationSId} :
|
||||
(defined($entry->{appSId}) ? $entry->{appSId} : undef);
|
||||
my $application = defined($application_sid) && defined($applications->{$application_sid}) ?
|
||||
$applications->{$application_sid}->{name} : 'unknown';
|
||||
my $environment = defined($application_sid) && defined($applications->{$application_sid}) && defined($environments->{$applications->{$application_sid}->{envSId}}) ?
|
||||
$environments->{$applications->{$application_sid}->{envSId}} : 'unknown';
|
||||
my $display = $environment . '/' . $application . '/' . $entry->{name};
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$display !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
my $family = defined($entry->{family}) ? $entry->{family} : '-';
|
||||
if (defined($self->{option_results}->{filter_family}) && $self->{option_results}->{filter_family} ne '' &&
|
||||
$family !~ /$self->{option_results}->{filter_family}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $family . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
my $information = defined($entry->{information}) ? $entry->{information} : '';
|
||||
$information =~ s/\|/-/msg;
|
||||
|
||||
$self->{global}->{total} += 1;
|
||||
$self->{global}->{lc($mapping_job_status{$entry->{status}})} += 1;
|
||||
$self->{job}->{$entry->{id}} = {
|
||||
name => $entry->{name},
|
||||
status => $mapping_job_status{$entry->{status}}, information => $information,
|
||||
exit_code => defined($entry->{retcode}) ? $entry->{retcode} : '-',
|
||||
family => $family, application => $application, environment => $environment,
|
||||
elapsed => defined($entry->{timeBegin}) ? ( $current_time - $entry->{timeBegin}) : undef,
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{job}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No job found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check job status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-environment>
|
||||
|
||||
Filter environment name (cannot be a regexp).
|
||||
|
||||
=item B<--filter-application>
|
||||
|
||||
Filter application name (cannot be a regexp).
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter name (can be a regexp).
|
||||
|
||||
=item B<--filter-family>
|
||||
|
||||
Filter family (can be a regexp).
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^total-error$'
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'total-error', 'total-running', 'total-unplanned',
|
||||
'total-finished', 'total-coming'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'total-error', 'total-running', 'total-unplanned',
|
||||
'total-finished', 'total-coming'.
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: -)
|
||||
Can used special variables like: %{name}, %{status},
|
||||
%{exit_code}, %{family}, %{information}, %{environment}, %{application}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{exit_code} =~ /Error/i').
|
||||
Can used special variables like: %{name}, %{status},
|
||||
%{exit_code}, %{family}, %{information}, %{environment}, %{application}
|
||||
|
||||
=item B<--warning-long>
|
||||
|
||||
Set warning threshold for long jobs (Default: none)
|
||||
Can used special variables like: %{name}, %{status}, %{elapsed},
|
||||
%{family}, %{environment}, %{application}
|
||||
|
||||
=item B<--critical-long>
|
||||
|
||||
Set critical threshold for long jobs (Default: none).
|
||||
Can used special variables like: %{name}, %{status}, %{elapsed},
|
||||
%{family}, %{environment}, %{application}
|
||||
|
||||
=item B<--reload-cache-time>
|
||||
|
||||
Time in seconds before reloading cache file (default: 180).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::vtom::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'job-status' => 'apps::vtom::restapi::mode::jobstatus',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{api} = 'apps::vtom::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check VTOM software through HTTP/REST API.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,78 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::common::adic::tape::snmp::mode::components::component;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'unknown',
|
||||
2 => 'unused',
|
||||
3 => 'ok',
|
||||
4 => 'warning',
|
||||
5 => 'failed',
|
||||
);
|
||||
|
||||
# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB'
|
||||
my $mapping = {
|
||||
componentDisplayName => { oid => '.1.3.6.1.4.1.3764.1.1.30.10.1.3' },
|
||||
componentStatus => { oid => '.1.3.6.1.4.1.3764.1.1.30.10.1.8', map => \%map_status },
|
||||
};
|
||||
my $oid_componentEntry = '.1.3.6.1.4.1.3764.1.1.30.10.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_componentEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking components");
|
||||
$self->{components}->{component} = {name => 'components', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'component'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_componentEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{componentStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_componentEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'component', instance => $result->{componentDisplayName}));
|
||||
$self->{components}->{component}->{total}++;
|
||||
|
||||
$result->{componentDisplayName} =~ s/\s+/ /g;
|
||||
$result->{componentDisplayName} = centreon::plugins::misc::trim($result->{componentDisplayName});
|
||||
$self->{output}->output_add(long_msg => sprintf("component '%s' status is %s [instance: %s].",
|
||||
$result->{componentDisplayName}, $result->{componentStatus},
|
||||
$result->{componentDisplayName}
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'component', value => $result->{componentStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Component '%s' status is %s",
|
||||
$result->{componentDisplayName}, $result->{componentStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,117 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::common::adic::tape::snmp::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'nominal',
|
||||
2 => 'warningLow', 3 => 'warningHigh',
|
||||
4 => 'alarmLow', 5 => 'alarmHigh',
|
||||
6 => 'notInstalled', 7 => 'noData',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
coolingFanName => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.2' },
|
||||
coolingFanStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.3', map => \%map_status },
|
||||
coolingFanRPM => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.4' },
|
||||
coolingFanWarningHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.8' },
|
||||
coolingFanNominalHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.6' },
|
||||
coolingFanNominalLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.5' },
|
||||
coolingFanWarningLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.7' },
|
||||
coolingFanLocation => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.40.1.9' },
|
||||
};
|
||||
my $oid_coolingFanEntry = '.1.3.6.1.4.1.3764.1.1.200.200.40.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_coolingFanEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingFanEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{coolingFanStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingFanEntry}, instance => $instance);
|
||||
|
||||
$result->{coolingFanName} =~ s/\s+/ /g;
|
||||
$result->{coolingFanName} = centreon::plugins::misc::trim($result->{coolingFanName});
|
||||
$result->{coolingFanLocation} =~ s/,/_/g;
|
||||
my $id = $result->{coolingFanName} . '_' . $result->{coolingFanLocation};
|
||||
|
||||
next if ($self->check_filter(section => 'fan', instance => $id));
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$id, $result->{coolingFanStatus}, $id,
|
||||
$result->{coolingFanRPM}));
|
||||
|
||||
my $exit = $self->get_severity(label => 'sensor', section => 'fan', value => $result->{coolingFanStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("fan '%s' status is '%s'", $id, $result->{coolingFanStatus}));
|
||||
next;
|
||||
}
|
||||
|
||||
if (defined($result->{coolingFanRPM}) && $result->{coolingFanRPM} =~ /[0-9]/) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{coolingFanRPM});
|
||||
if ($checked == 0) {
|
||||
$result->{coolingFanNominalLo} = (defined($result->{coolingFanNominalLo}) && $result->{coolingFanNominalLo} =~ /[0-9]/) ?
|
||||
$result->{coolingFanNominalLo} : '';
|
||||
$result->{coolingFanWarningLo} = (defined($result->{coolingFanWarningLo}) && $result->{coolingFanWarningLo} =~ /[0-9]/) ?
|
||||
$result->{coolingFanWarningLo} : '';
|
||||
$result->{coolingFanNominalHi} = (defined($result->{coolingFanNominalHi}) && $result->{coolingFanNominalHi} =~ /[0-9]/) ?
|
||||
$result->{coolingFanNominalHi} : '';
|
||||
$result->{coolingFanWarningHi} = (defined($result->{coolingFanWarningHi}) && $result->{coolingFanWarningHi} =~ /[0-9]/) ?
|
||||
$result->{coolingFanWarningHi} : '';
|
||||
my $warn_th = $result->{coolingFanNominalLo} . ':' . $result->{coolingFanNominalHi};
|
||||
my $crit_th = $result->{coolingFanWarningLo} . ':' . $result->{coolingFanWarningHi};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-fan-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-fan-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$exit = $self->{perfdata}->threshold_check(value => $result->{coolingFanRPM}, threshold => [ { label => 'critical-fan-instance-' . $instance, exit_litteral => 'critical' },
|
||||
{ label => 'warning-fan-instance-' . $instance, exit_litteral => 'warning' } ]);
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-fan-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-fan-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' is %s rpm", $id, $result->{coolingFanRPM}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'fan_' . $id, unit => 'rpm',
|
||||
value => $result->{coolingFanRPM},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -32,16 +32,29 @@ my %map_status = (
|
|||
6 => 'unknown',
|
||||
7 => 'invalid',
|
||||
);
|
||||
my %map_agent_status = (
|
||||
1 => 'other',
|
||||
2 => 'unknown',
|
||||
3 => 'ok',
|
||||
4 => 'non-critical',
|
||||
5 => 'critical',
|
||||
6 => 'non-recoverable',
|
||||
);
|
||||
|
||||
# In MIB 'ADIC-TAPE-LIBRARY-MIB'
|
||||
my $mapping = {
|
||||
libraryGlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status },
|
||||
GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.1.8', map => \%map_status }, # libraryGlobalStatus
|
||||
};
|
||||
# In MIB 'ADIC-INTELLIGENT-STORAGE-MIB'
|
||||
my $mapping2 = {
|
||||
GlobalStatus => { oid => '.1.3.6.1.4.1.3764.1.1.20.1', map => \%map_agent_status }, # agentGlobalStatus
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $mapping->{libraryGlobalStatus}->{oid} };
|
||||
push @{$self->{request}}, { oid => $mapping->{GlobalStatus}->{oid} },
|
||||
{ oid => $mapping2->{GlobalStatus}->{oid} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -52,8 +65,11 @@ sub check {
|
|||
return if ($self->check_filter(section => 'global'));
|
||||
|
||||
my $instance = '0';
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{libraryGlobalStatus}->{oid}}, instance => $instance);
|
||||
if (!defined($result->{libraryGlobalStatus})) {
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{GlobalStatus}->{oid}}, instance => $instance);
|
||||
if (!defined($result->{GlobalStatus})) {
|
||||
$result = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{GlobalStatus}->{oid}}, instance => $instance);
|
||||
}
|
||||
if (!defined($result->{GlobalStatus})) {
|
||||
$self->{output}->output_add(long_msg => "skipping global status: no value.");
|
||||
return ;
|
||||
}
|
||||
|
@ -62,13 +78,13 @@ sub check {
|
|||
$self->{components}->{global}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("library global status is %s [instance: %s].",
|
||||
$result->{libraryGlobalStatus}, $instance
|
||||
$result->{GlobalStatus}, $instance
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{libraryGlobalStatus});
|
||||
my $exit = $self->get_severity(section => 'global', label => 'default', value => $result->{GlobalStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Library global status is %s",
|
||||
$result->{libraryGlobalStatus}));
|
||||
$result->{GlobalStatus}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,18 +34,30 @@ my %map_status = (
|
|||
7 => 'invalid',
|
||||
);
|
||||
|
||||
# In MIB 'ADIC-TAPE-LIBRARY-MIB'
|
||||
my $mapping = {
|
||||
phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' },
|
||||
phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' },
|
||||
phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status },
|
||||
# 'ADIC-TAPE-LIBRARY-MIB'
|
||||
adic_tape => {
|
||||
phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' },
|
||||
phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' },
|
||||
phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status },
|
||||
},
|
||||
# 'ADIC-MANAGEMENT-MIB'
|
||||
adic_management => {
|
||||
phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.8' },
|
||||
phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.7' }, # phDriveProduct
|
||||
phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.31', map => \%map_status },
|
||||
}
|
||||
};
|
||||
my $oid_physicalDriveEntry = '.1.3.6.1.4.1.3764.1.10.10.11.3.1';
|
||||
|
||||
my %oid_table = (
|
||||
adic_tape => '.1.3.6.1.4.1.3764.1.10.10.11.3.1', # physicalDriveEntry
|
||||
adic_management => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1', # phDriveEntry
|
||||
);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_physicalDriveEntry };
|
||||
push @{$self->{request}}, { oid => $oid_table{adic_tape} }, { oid => $oid_table{adic_management} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
|
@ -54,25 +66,29 @@ sub check {
|
|||
$self->{output}->output_add(long_msg => "Checking physical drives");
|
||||
$self->{components}->{physicaldrive} = {name => 'physical drives', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'physicaldrive'));
|
||||
|
||||
foreach my $label (keys %{$mapping}) {
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_table{$label}}})) {
|
||||
next if ($oid !~ /^$mapping->{$label}->{phDriveRasStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$label}, results => $self->{results}->{$oid_table{$label}}, instance => $instance);
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_physicalDriveEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{phDriveRasStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_physicalDriveEntry}, instance => $instance);
|
||||
$result->{phDriveSerialNumber} = centreon::plugins::misc::trim($result->{phDriveSerialNumber});
|
||||
|
||||
next if ($self->check_filter(section => 'physicaldrive', instance => $instance));
|
||||
$self->{components}->{physicaldrive}->{total}++;
|
||||
next if ($self->check_filter(section => 'physicaldrive', instance => $result->{phDriveSerialNumber}));
|
||||
$self->{components}->{physicaldrive}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].",
|
||||
$instance, $result->{phDriveRasStatus},
|
||||
$instance, centreon::plugins::misc::trim($result->{phDriveModel}),
|
||||
centreon::plugins::misc::trim($result->{phDriveSerialNumber})
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', value => $result->{phDriveRasStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Physical drive '%s' status is %s",
|
||||
$instance, $result->{phDriveRasStatus}));
|
||||
$self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].",
|
||||
$result->{phDriveSerialNumber}, $result->{phDriveRasStatus},
|
||||
$result->{phDriveSerialNumber}, centreon::plugins::misc::trim($result->{phDriveModel}),
|
||||
centreon::plugins::misc::trim($result->{phDriveSerialNumber})
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', value => $result->{phDriveRasStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Physical drive '%s' status is %s",
|
||||
$result->{phDriveSerialNumber}, $result->{phDriveRasStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::common::adic::tape::snmp::mode::components::temperature;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'nominal',
|
||||
2 => 'warningLow', 3 => 'warningHigh',
|
||||
4 => 'alarmLow', 5 => 'alarmHigh',
|
||||
6 => 'notInstalled', 7 => 'noData',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
temperatureSensorName => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.2' },
|
||||
temperatureSensorStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.3', map => \%map_status },
|
||||
temperatureSensorDegreesCelsius => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.4' },
|
||||
temperatureSensorWarningHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.8' },
|
||||
temperatureSensorNominalHi => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.6' },
|
||||
temperatureSensorNominalLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.5' },
|
||||
temperatureSensorWarningLo => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.7' },
|
||||
temperatureSensorLocation => { oid => '.1.3.6.1.4.1.3764.1.1.200.200.30.1.9' },
|
||||
};
|
||||
my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.3764.1.1.200.200.30.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_temperatureSensorEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{temperatureSensorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureSensorEntry}, instance => $instance);
|
||||
|
||||
$result->{temperatureSensorName} =~ s/\s+/ /g;
|
||||
$result->{temperatureSensorName} = centreon::plugins::misc::trim($result->{temperatureSensorName});
|
||||
$result->{temperatureSensorLocation} =~ s/,/_/g;
|
||||
my $id = $result->{temperatureSensorName} . '_' . $result->{temperatureSensorLocation};
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $id));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$id, $result->{temperatureSensorStatus}, $id,
|
||||
$result->{temperatureSensorDegreesCelsius}));
|
||||
|
||||
my $exit = $self->get_severity(label => 'sensor', section => 'temperature', value => $result->{temperatureSensorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' status is '%s'", $id, $result->{temperatureSensorStatus}));
|
||||
next;
|
||||
}
|
||||
|
||||
if (defined($result->{temperatureSensorDegreesCelsius}) && $result->{temperatureSensorDegreesCelsius} =~ /[0-9]/) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureSensorDegreesCelsius});
|
||||
if ($checked == 0) {
|
||||
$result->{temperatureSensorNominalLo} = (defined($result->{temperatureSensorNominalLo}) && $result->{temperatureSensorNominalLo} =~ /[0-9]/) ?
|
||||
$result->{temperatureSensorNominalLo} : '';
|
||||
$result->{temperatureSensorWarningLo} = (defined($result->{temperatureSensorWarningLo}) && $result->{temperatureSensorWarningLo} =~ /[0-9]/) ?
|
||||
$result->{temperatureSensorWarningLo} : '';
|
||||
$result->{temperatureSensorNominalHi} = (defined($result->{temperatureSensorNominalHi}) && $result->{temperatureSensorNominalHi} =~ /[0-9]/) ?
|
||||
$result->{temperatureSensorNominalHi} : '';
|
||||
$result->{temperatureSensorWarningHi} = (defined($result->{temperatureSensorWarningHi}) && $result->{temperatureSensorWarningHi} =~ /[0-9]/) ?
|
||||
$result->{temperatureSensorWarningHi} : '';
|
||||
my $warn_th = $result->{temperatureSensorNominalLo} . ':' . $result->{temperatureSensorNominalHi};
|
||||
my $crit_th = $result->{temperatureSensorWarningLo} . ':' . $result->{temperatureSensorWarningHi};
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$exit = $self->{perfdata}->threshold_check(value => $result->{temperatureSensorDegreesCelsius}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' },
|
||||
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]);
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $id, $result->{temperatureSensorDegreesCelsius}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'temp_' . $id, unit => 'C',
|
||||
value => $result->{temperatureSensorDegreesCelsius},
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -28,7 +28,8 @@ use warnings;
|
|||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(global|physicaldrive|subsystem)$';
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(global|physicaldrive|subsystem|component|temperature)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
|
@ -41,11 +42,33 @@ sub set_system {
|
|||
['informational', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
['invalid', 'CRITICAL'],
|
||||
|
||||
['other', 'OK'],
|
||||
['ok', 'OK'],
|
||||
['non-critical', 'WARNING'],
|
||||
['critical', 'CRITICAL'],
|
||||
['non-recoverable', 'CRITICAL'],
|
||||
],
|
||||
component => [
|
||||
['unknown', 'UNKNOWN'],
|
||||
['unused', 'OK'],
|
||||
['ok', 'OK'],
|
||||
['warning', 'WARNING'],
|
||||
['failed', 'CRITICAL'],
|
||||
],
|
||||
sensor => [
|
||||
['nominal', 'OK'],
|
||||
['warningLow', 'WARNING'],
|
||||
['warningHigh', 'CRITICAL'],
|
||||
['alarmLow', 'CRITICAL'],
|
||||
['alarmHigh', 'CRITICAL'],
|
||||
['notInstalled', 'OK'],
|
||||
['noData', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'centreon::common::adic::tape::snmp::mode::components';
|
||||
$self->{components_module} = ['global', 'physicaldrive', 'subsystem'];
|
||||
$self->{components_module} = ['global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan'];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
|
@ -57,7 +80,7 @@ sub snmp_execute {
|
|||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, no_absent => 1);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
|
@ -81,7 +104,7 @@ Check Hardware.
|
|||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'global', 'physicaldrive', 'subsystem'.
|
||||
Can be: 'global', 'physicaldrive', 'subsystem', 'component', 'temperature', 'fan'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
|
@ -99,6 +122,16 @@ Set to overload default threshold values (syntax: section,[instance,]status,rege
|
|||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='physicaldrive,OK,invalid'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold (syntax: type,regexp,threshold)
|
||||
Example: --warning='temperature,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold (syntax: type,regexp,threshold)
|
||||
Example: --critical='temperature,.*,40'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_agentCurrentCPUUtilization = '.1.3.6.1.4.1.14179.1.1.3.1.0';
|
||||
|
|
|
@ -55,7 +55,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_agentTotalMemory = '.1.3.6.1.4.1.14179.1.1.5.2.0'; # in Kbytes
|
||||
|
|
|
@ -164,7 +164,6 @@ sub check_total {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
|
|
|
@ -20,15 +20,21 @@
|
|||
|
||||
package centreon::common::aruba::snmp::mode::apusers;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $maps_counters = {
|
||||
global => {
|
||||
'000_total' => { set => {
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'essid', type => 1, cb_prefix_output => 'prefix_essid_output', message_multiple => 'All users by ESSID are ok' },
|
||||
{ name => 'ap', type => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All users by AP are ok' },
|
||||
];
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'total', set => {
|
||||
key_values => [ { name => 'total' } ],
|
||||
output_template => 'Total Users : %s',
|
||||
perfdatas => [
|
||||
|
@ -37,7 +43,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'001_total-none' => { set => {
|
||||
{ label => 'total-none', set => {
|
||||
key_values => [ { name => 'total_none' } ],
|
||||
output_template => 'Total Auth None : %s',
|
||||
perfdatas => [
|
||||
|
@ -46,7 +52,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'002_total-other' => { set => {
|
||||
{ label => 'total-other', set => {
|
||||
key_values => [ { name => 'total_other' } ],
|
||||
output_template => 'Total Auth Other : %s',
|
||||
perfdatas => [
|
||||
|
@ -55,7 +61,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'003_total-web' => { set => {
|
||||
{ label => 'total-web', set => {
|
||||
key_values => [ { name => 'total_web' } ],
|
||||
output_template => 'Total Auth Web : %s',
|
||||
perfdatas => [
|
||||
|
@ -64,7 +70,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'004_total-dot1x' => { set => {
|
||||
{ label => 'total-dot1x', set => {
|
||||
key_values => [ { name => 'total_dot1x' } ],
|
||||
output_template => 'Total Auth Dot1x : %s',
|
||||
perfdatas => [
|
||||
|
@ -73,7 +79,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'005_total-vpn' => { set => {
|
||||
{ label => 'total-vpn', set => {
|
||||
key_values => [ { name => 'total_vpn' } ],
|
||||
output_template => 'Total Auth Vpn : %s',
|
||||
perfdatas => [
|
||||
|
@ -82,7 +88,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'006_total-mac' => { set => {
|
||||
{ label => 'total-mac', set => {
|
||||
key_values => [ { name => 'total_mac' } ],
|
||||
output_template => 'Total Auth Mac : %s',
|
||||
perfdatas => [
|
||||
|
@ -91,7 +97,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
'007_avg-connection-time' => { set => {
|
||||
{ label => 'avg-connection-time', set => {
|
||||
key_values => [ { name => 'avg_connection_time' } ],
|
||||
output_template => 'Users average connection time : %.3f seconds',
|
||||
perfdatas => [
|
||||
|
@ -100,30 +106,44 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
total_ap => {
|
||||
'000_total-ap' => { set => {
|
||||
key_values => [ { name => 'users' }, { name => 'bssid' } ],
|
||||
output_template => 'Users : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total', value => 'users_absolute', template => '%s',
|
||||
unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'bssid_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
total_essid => {
|
||||
'000_total-essid' => { set => {
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{essid} = [
|
||||
{ label => 'total-essid', set => {
|
||||
key_values => [ { name => 'users' }, { name => 'essid' } ],
|
||||
output_template => 'Users : %s',
|
||||
output_template => 'users : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total', value => 'users_absolute', template => '%s',
|
||||
{ label => 'essid', value => 'users_absolute', template => '%s',
|
||||
unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'essid_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{ap} = [
|
||||
{ label => 'total-ap', set => {
|
||||
key_values => [ { name => 'users' }, { name => 'ap_id' } ],
|
||||
output_template => 'users : %s',
|
||||
perfdatas => [
|
||||
{ label => 'ap', value => 'users_absolute', template => '%s',
|
||||
unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'ap_id_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_essid_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "ESSID '" . $options{instance_value}->{essid} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_ap_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "AP '" . $options{instance_value}->{ap_id} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -134,206 +154,13 @@ sub new {
|
|||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-ip-address:s" => { name => 'filter_ip_address' },
|
||||
"filter-essid:s" => { name => 'filter_essid' },
|
||||
"filter-bssid:s" => { name => 'filter_bssid' },
|
||||
"filter-essid:s" => { name => 'filter_essid' },
|
||||
});
|
||||
|
||||
foreach my $key (('global', 'total_ap', 'total_essid')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
my ($id, $name) = split /_/;
|
||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
}
|
||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output},
|
||||
perfdata => $self->{perfdata},
|
||||
label => $name);
|
||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $key (('global', 'total_ap', 'total_essid')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run_total {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits;
|
||||
foreach (sort keys %{$maps_counters->{global}}) {
|
||||
my $obj = $maps_counters->{global}->{$_}->{obj};
|
||||
|
||||
$obj->set(instance => 'global');
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{global});
|
||||
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $obj->output_error();
|
||||
$long_msg_append = ', ';
|
||||
next;
|
||||
}
|
||||
my $exit2 = $obj->threshold_check();
|
||||
push @exits, $exit2;
|
||||
|
||||
my $output = $obj->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = ', ';
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata();
|
||||
}
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "$short_msg"
|
||||
);
|
||||
} else {
|
||||
$self->{output}->output_add(short_msg => "$long_msg");
|
||||
}
|
||||
}
|
||||
|
||||
sub run_ap {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{ap_selected}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All users by AP are ok');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{ap_selected}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (sort keys %{$maps_counters->{total_ap}}) {
|
||||
my $obj = $maps_counters->{total_ap}->{$_}->{obj};
|
||||
$obj->set(instance => $id);
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{ap_selected}->{$id});
|
||||
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $obj->output_error();
|
||||
$long_msg_append = ', ';
|
||||
next;
|
||||
}
|
||||
my $exit2 = $obj->threshold_check();
|
||||
push @exits, $exit2;
|
||||
|
||||
my $output = $obj->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = ', ';
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "AP '$id' $long_msg");
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "AP '$id' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "AP '$id' $long_msg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run_essid {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{essid_selected}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All users by ESSID are ok');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{essid_selected}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (sort keys %{$maps_counters->{total_essid}}) {
|
||||
my $obj = $maps_counters->{total_essid}->{$_}->{obj};
|
||||
$obj->set(instance => $id);
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{essid_selected}->{$id});
|
||||
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $obj->output_error();
|
||||
$long_msg_append = ', ';
|
||||
next;
|
||||
}
|
||||
my $exit2 = $obj->threshold_check();
|
||||
push @exits, $exit2;
|
||||
|
||||
my $output = $obj->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = ', ';
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "ESSID '$id' $long_msg");
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "ESSID '$id' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "ESSID '$id' $long_msg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
$self->run_total();
|
||||
$self->run_ap();
|
||||
$self->run_essid();
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
my %map_auth_method = (
|
||||
0 => 'none', 1 => 'web',
|
||||
2 => 'mac', 3 => 'vpn',
|
||||
|
@ -361,6 +188,7 @@ my $oid_wlsxUserEntry = '.1.3.6.1.4.1.14823.2.2.1.4.1.2.1';
|
|||
my $oid_wlsxSwitchRole = '.1.3.6.1.4.1.14823.2.2.1.1.1.4';
|
||||
my $oid_apESSID = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.2';
|
||||
my $oid_apIpAddress = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.5';
|
||||
my $oid_wlanAPName = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -368,15 +196,16 @@ sub manage_selection {
|
|||
$self->{global} = { total => 0, total_none => 0, total_web => 0, total_mac => 0, total_vpn => 0,
|
||||
total_dot1x => 0, total_kerberos => 0, total_secureId => 0, total_pubcookie => 0,
|
||||
total_xSec => 0, xSecMachine => 0, 'total_via-vpn' => 0, total_other => 0 };
|
||||
$self->{ap_selected} = {};
|
||||
$self->{essid_selected} = {};
|
||||
$self->{ap} = {};
|
||||
$self->{essid} = {};
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
|
||||
$self->{results} = $options{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_wlsxSwitchRole },
|
||||
{ oid => $oid_wlsxUserEntry, start => $mapping->{nUserUpTime}->{oid}, end => $mapping->{nUserAuthenticationMethod}->{oid} },
|
||||
{ oid => $mapping2->{nUserApBSSID}->{oid} },
|
||||
{ oid => $oid_apESSID },
|
||||
{ oid => $oid_apIpAddress },
|
||||
{ oid => $oid_wlanAPName },
|
||||
],
|
||||
nothing_quit => 1);
|
||||
|
||||
|
@ -398,8 +227,8 @@ sub manage_selection {
|
|||
foreach my $oid (keys %{$self->{results}->{$oid_wlsxUserEntry}}) {
|
||||
next if ($oid !~ /^$mapping->{nUserAuthenticationMethod}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxUserEntry}, instance => $instance);
|
||||
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{nUserApBSSID}->{oid}}, instance => $instance);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_wlsxUserEntry}, instance => $instance);
|
||||
my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{nUserApBSSID}->{oid}}, instance => $instance);
|
||||
|
||||
# security
|
||||
next if (!defined($result2->{nUserApBSSID}));
|
||||
|
@ -408,12 +237,17 @@ sub manage_selection {
|
|||
$map_ap{$bssid}->{ip} !~ /$self->{option_results}->{filter_ip_address}/);
|
||||
next if (defined($self->{option_results}->{filter_essid}) && $self->{option_results}->{filter_essid} ne '' &&
|
||||
$map_ap{$bssid}->{essid} !~ /$self->{option_results}->{filter_essid}/);
|
||||
next if (defined($self->{option_results}->{filter_bssid}) && $self->{option_results}->{filter_bssid} ne '' &&
|
||||
$bssid !~ /$self->{option_results}->{filter_bssid}/);
|
||||
|
||||
$self->{ap_selected}->{$bssid} = { users => 0, bssid => $bssid } if (!defined($self->{ap_selected}->{$bssid}));
|
||||
$self->{ap_selected}->{$bssid}->{users}++;
|
||||
my $ap_id = $bssid;
|
||||
$ap_id = $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}
|
||||
if (defined($self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}) && $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid} ne '');
|
||||
$self->{ap}->{$bssid} = { users => 0, ap_id => $ap_id } if (!defined($self->{ap}->{$bssid}));
|
||||
$self->{ap}->{$bssid}->{users}++;
|
||||
|
||||
$self->{essid_selected}->{$map_ap{$bssid}->{essid}} = { users => 0, essid => $map_ap{$bssid}->{essid} } if (!defined($self->{essid_selected}->{$map_ap{$bssid}->{essid}}));
|
||||
$self->{essid_selected}->{$map_ap{$bssid}->{essid}}->{users}++;
|
||||
$self->{essid}->{$map_ap{$bssid}->{essid}} = { users => 0, essid => $map_ap{$bssid}->{essid} } if (!defined($self->{essid}->{$map_ap{$bssid}->{essid}}));
|
||||
$self->{essid}->{$map_ap{$bssid}->{essid}}->{users}++;
|
||||
|
||||
$self->{global}->{total}++;
|
||||
$self->{global}->{'total_' . $result->{nUserAuthenticationMethod}}++;
|
||||
|
@ -439,13 +273,15 @@ Check total users connected.
|
|||
|
||||
Threshold warning.
|
||||
Can be: 'total', 'total-none', 'total-other', 'total-web',
|
||||
'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds).
|
||||
'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds),
|
||||
'total-ap', 'total-essid'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'total', 'total-none', 'total-other', 'total-web',
|
||||
'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds).
|
||||
'total-dot1x', 'total-vpn', 'total-mac', 'avg-connection-time' (seconds),
|
||||
'total-ap', 'total-essid'.
|
||||
|
||||
=item B<--filter-ip-address>
|
||||
|
||||
|
@ -455,6 +291,10 @@ Filter by ip address (regexp can be used).
|
|||
|
||||
Filter by ESSID (regexp can be used).
|
||||
|
||||
=item B<--filter-bssid>
|
||||
|
||||
Filter by BSSID (regexp can be used).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_wlsxSysExtProcessorEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.13.1';
|
||||
|
|
|
@ -56,7 +56,6 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_wlsxSysExtMemoryEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.15.1';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue