+ Refactorize netscaler code
This commit is contained in:
parent
4282ea807e
commit
bd63481afc
|
@ -1,109 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::common::mode::certificatesexpire;
|
||||
|
||||
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->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_sslCertKeyName = '.1.3.6.1.4.1.5951.4.1.1.56.1.1.1';
|
||||
my $oid_sslDaysToExpire = '.1.3.6.1.4.1.5951.4.1.1.56.1.1.5';
|
||||
my $result = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_sslCertKeyName }, { oid => $oid_sslDaysToExpire } ], nothing_quit => 1);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All certificates are ok.');
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$result->{$oid_sslCertKeyName}})) {
|
||||
$oid =~ /^$oid_sslCertKeyName\.(.*)$/;
|
||||
my $name = $result->{$oid_sslCertKeyName}->{$oid};
|
||||
my $days = $result->{$oid_sslDaysToExpire}->{$oid_sslDaysToExpire . '.' . $1};
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $days,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Certificate '%s': %d days remaining before expiration",
|
||||
$name, $days));
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Certificate '%s': %d days remaining before expiration",
|
||||
$name, $days));
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check number of days remaining before the expiration of certificates (NS-MIB-smiv2).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning in days.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical in days.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::common::mode::connections;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $maps_counters = {
|
||||
global => {
|
||||
'000_active' => { set => {
|
||||
key_values => [ { name => 'active' } ],
|
||||
output_template => 'Active Server TCP connections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'active_server', value => 'active_absolute', template => '%s',
|
||||
unit => 'con', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
'001_server' => { set => {
|
||||
key_values => [ { name => 'server' } ],
|
||||
output_template => 'Server TCP connections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'server', value => 'server_absolute', template => '%s',
|
||||
unit => 'con', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
'002_client' => { set => {
|
||||
key_values => [ { name => 'client' } ],
|
||||
output_template => 'Client TCP connections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'client', value => 'client_absolute', template => '%s',
|
||||
unit => 'con', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
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 =>
|
||||
{
|
||||
});
|
||||
|
||||
foreach my $key (('global')) {
|
||||
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')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run_global {
|
||||
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 {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
$self->run_global();
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{global} = { client => 0, server => 0, active => 0 };
|
||||
my $oid_tcpCurServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.1.0';
|
||||
my $oid_tcpCurClientConn = '.1.3.6.1.4.1.5951.4.1.1.46.2.0';
|
||||
my $oid_tcpActiveServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.8.0';
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_tcpCurServerConn, $oid_tcpCurClientConn, $oid_tcpActiveServerConn ], nothing_quit => 1);
|
||||
$self->{global}->{client} = $result->{$oid_tcpCurClientConn};
|
||||
$self->{global}->{server} = $result->{$oid_tcpCurServerConn};
|
||||
$self->{global}->{active} = $result->{$oid_tcpActiveServerConn};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check connections usage (Client, Server, ActiveServer) (NS-ROOT-MIBv2).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'server', 'active', 'client'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'server', 'active', 'client'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,358 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::common::mode::health;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
|
||||
my $oid_sysHealthCounterName = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1';
|
||||
my $oid_sysHealthCounterValue = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2';
|
||||
|
||||
my $thresholds = {
|
||||
psu => [
|
||||
['normal', 'OK'],
|
||||
['not present', 'OK'],
|
||||
['failed', 'CRITICAL'],
|
||||
['not supported', 'UNKNOWN'],
|
||||
],
|
||||
};
|
||||
|
||||
my %map_psu_status = (
|
||||
0 => 'normal',
|
||||
1 => 'not present',
|
||||
2 => 'failed',
|
||||
3 => 'not supported',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"component:s" => { name => 'component', default => 'all' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ('psu', $1, $2);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->{result} = $self->{snmp}->get_table(oid => $oid_nsSysHealthEntry);
|
||||
|
||||
if ($self->{option_results}->{component} eq 'all') {
|
||||
$self->check_psu();
|
||||
$self->check_fanspeed();
|
||||
$self->check_temperature();
|
||||
$self->check_voltage();
|
||||
} elsif ($self->{option_results}->{component} eq 'psu') {
|
||||
$self->check_psu();
|
||||
} elsif ($self->{option_results}->{component} eq 'fanspeed') {
|
||||
$self->check_fanspeed();
|
||||
} elsif ($self->{option_results}->{component} eq 'temperature') {
|
||||
$self->check_temperature();
|
||||
} elsif ($self->{option_results}->{component} eq 'voltage') {
|
||||
$self->check_voltage();
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $total_components = 0;
|
||||
my $display_by_component = '';
|
||||
my $display_by_component_append = '';
|
||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||
# Skipping short msg when no components
|
||||
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
|
||||
$display_by_component_append = ', ';
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok [%s].",
|
||||
$total_components,
|
||||
$display_by_component,
|
||||
)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
||||
sub absent_problem {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{absent}) &&
|
||||
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Component '%s' instance '%s' is not present",
|
||||
$options{section}, $options{instance}));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub check_fanspeed {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fanspeed");
|
||||
$self->{components}->{fanspeed} = {name => 'fanspeed', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'fanspeed'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
|
||||
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /Speed|Fan/i);
|
||||
my $name = $self->{result}->{$oid};
|
||||
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
|
||||
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1};
|
||||
|
||||
if ($value == 0) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping Fanspeed '%s' (counter is 0)",
|
||||
$name));
|
||||
next;
|
||||
}
|
||||
|
||||
next if ($self->check_exclude(section => 'fanspeed', instance => $name));
|
||||
$self->{components}->{fanspeed}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' speed is %s (rpm)",
|
||||
$name, $value));
|
||||
|
||||
$self->{output}->perfdata_add(label => "speed_" . $name, unit => 'rpm',
|
||||
value => $value,
|
||||
min => 0);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_psu {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
|
||||
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /PowerSupply(.)FailureStatus/i);
|
||||
my $instance = $1;
|
||||
my $name = $self->{result}->{$oid};
|
||||
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
|
||||
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1};
|
||||
|
||||
next if ($map_psu_status{$value} eq 'not present' &&
|
||||
$self->absent_problem(section => 'psu', instance => $instance));
|
||||
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s",
|
||||
$instance, $map_psu_status{$value}));
|
||||
my $exit = $self->get_severity(section => 'psu', value => $map_psu_status{$value});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power Supply '%s' status is %s",
|
||||
$instance, $map_psu_status{$value}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_voltage {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'voltage'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
|
||||
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /Voltage|IntelCPUVttPower/i);
|
||||
my $name = $self->{result}->{$oid};
|
||||
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
|
||||
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1} / 1000; # in mv
|
||||
|
||||
if ($value == 0) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping voltage '%s' (counter is 0)",
|
||||
$name));
|
||||
next;
|
||||
}
|
||||
|
||||
next if ($self->check_exclude(section => 'voltage', instance => $name));
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' is %.2f V",
|
||||
$name, $value));
|
||||
|
||||
$self->{output}->perfdata_add(label => "volt_" . $name, unit => 'V',
|
||||
value => sprintf("%.2f", $value),
|
||||
min => 0);
|
||||
}
|
||||
}
|
||||
|
||||
sub check_temperature {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'temperature'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
|
||||
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /temperature/i);
|
||||
my $name = $self->{result}->{$oid};
|
||||
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
|
||||
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1}; # in C
|
||||
|
||||
if ($value == 0) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping temperature '%s' (counter is 0)",
|
||||
$name));
|
||||
next;
|
||||
}
|
||||
|
||||
next if ($self->check_exclude(section => 'temperature', instance => $name));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s C",
|
||||
$name, $value));
|
||||
|
||||
$self->{output}->perfdata_add(label => "temp_" . $name, unit => 'C',
|
||||
value => $value,
|
||||
min => 0);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check System Health Status (temperatures, voltages, power supplies, fanspeed).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: 'all').
|
||||
Can be: 'temperature', 'voltage', 'fanspeed', 'psu'.
|
||||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=psu)
|
||||
Can also exclude specific instance: --exclude='psu#1#'
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--absent-problem>
|
||||
|
||||
Return an error if an entity is not 'present' (default is 'ok') (only for psu)
|
||||
Can be specific or global: --exclude=psu#1#
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: status,regexp).
|
||||
It used before default thresholds (order stays) (only for psu).
|
||||
Example: --threshold-overload='CRITICAL,^(?!(normal)$)'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,127 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::common::mode::storage;
|
||||
|
||||
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->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_nsSysHealthDiskEntry = '.1.3.6.1.4.1.5951.4.1.1.41.8.1';
|
||||
my $oid_sysHealthDiskName = '.1.3.6.1.4.1.5951.4.1.1.41.8.1.1';
|
||||
my $oid_sysHealthDiskSize = '.1.3.6.1.4.1.5951.4.1.1.41.8.1.2'; # in MB
|
||||
my $oid_sysHealthDiskUsed = '.1.3.6.1.4.1.5951.4.1.1.41.8.1.4'; # in MB
|
||||
my $result = $self->{snmp}->get_table(oid => $oid_nsSysHealthDiskEntry, nothing_quit => 1);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All storages are ok.');
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($oid !~ /^$oid_sysHealthDiskName\.(.*)$/);
|
||||
my $name = $result->{$oid};
|
||||
my $total_used = $result->{$oid_sysHealthDiskUsed . '.' . $1} * 1024 * 1024;
|
||||
my $total_size = $result->{$oid_sysHealthDiskSize . '.' . $1} * 1024 * 1024;
|
||||
my $total_free = $total_size - $total_used;
|
||||
my $prct_used = $total_used * 100 / $total_size;
|
||||
my $prct_free = 100 - $prct_used;
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $total_size);
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $total_used);
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $total_free);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Storage '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $name,
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $prct_used,
|
||||
$total_free_value . " " . $total_free_unit, $prct_free));
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Storage '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $name,
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $prct_used,
|
||||
$total_free_value . " " . $total_free_unit, $prct_free));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'used_' . $name, unit => 'B',
|
||||
value => $total_used,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
|
||||
min => 0, max => $total_size);
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check disk usages (NS-MIB-smiv2).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Threshold warning in percent.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical in percent.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -1,335 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::common::mode::vserverstatus;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $maps_counters = {
|
||||
status => { class => 'centreon::plugins::values', obj => undef,
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'state' },
|
||||
],
|
||||
closure_custom_calc => \&custom_status_calc,
|
||||
closure_custom_output => \&custom_status_output,
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&custom_threshold_output,
|
||||
}
|
||||
},
|
||||
health => { class => 'centreon::plugins::values', obj => undef,
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'health' }, { name => 'display' },
|
||||
],
|
||||
output_template => 'Health: %.2f %%', output_error_template => 'Health: %s',
|
||||
output_use => 'health_absolute', threshold_use => 'health_absolute',
|
||||
perfdatas => [
|
||||
{ value => 'health_absolute', label => 'health', template => '%.2f',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
my $overload_th = {};
|
||||
my $oid_vsvrName = '.1.3.6.1.4.1.5951.4.1.3.1.1.1';
|
||||
my $oid_vsvrState = '.1.3.6.1.4.1.5951.4.1.3.1.1.5';
|
||||
my $oid_vsvrHealth = '.1.3.6.1.4.1.5951.4.1.3.1.1.62';
|
||||
my $oid_vsvrEntityType = '.1.3.6.1.4.1.5951.4.1.3.1.1.64';
|
||||
|
||||
my $thresholds = {
|
||||
vs => [
|
||||
['unknown', 'UNKNOWN'],
|
||||
['down|outOfService|transitionToOutOfService|transitionToOutOfServiceDown', 'CRITICAL'],
|
||||
['up', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
my %map_vs_type = (
|
||||
0 => 'unknown',
|
||||
1 => 'loadbalancing',
|
||||
2 => 'loadbalancinggroup',
|
||||
3 => 'sslvpn',
|
||||
4 => 'contentswitching',
|
||||
5 => 'cacheredirection',
|
||||
);
|
||||
|
||||
my %map_vs_status = (
|
||||
1 => 'down',
|
||||
2 => 'unknown',
|
||||
3 => 'busy',
|
||||
4 => 'outOfService',
|
||||
5 => 'transitionToOutOfService',
|
||||
7 => 'up',
|
||||
8 => 'transitionToOutOfServiceDown',
|
||||
);
|
||||
|
||||
sub get_severity {
|
||||
my (%options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($overload_th->{$options{section}})) {
|
||||
foreach (@{$overload_th->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return get_severity(section => 'vs', value => $map_vs_status{$self->{result_values}->{state}});
|
||||
}
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
my $msg = 'State : ' . $map_vs_status{$self->{result_values}->{state}};
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
|
||||
return 0;
|
||||
}
|
||||
|
||||
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-type:s" => { name => 'filter_type' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
|
||||
$self->{vs_id_selected} = {};
|
||||
|
||||
foreach (keys %{$maps_counters}) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $_ . ':s' => { name => 'warning-' . $_ },
|
||||
'critical-' . $_ . ':s' => { name => 'critical-' . $_ },
|
||||
});
|
||||
my $class = $maps_counters->{$_}->{class};
|
||||
$maps_counters->{$_}->{obj} = $class->new(output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $_);
|
||||
$maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}});
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach (keys %{$maps_counters}) {
|
||||
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ('vs', $1, $2);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$overload_th->{$section} = [] if (!defined($overload_th->{$section}));
|
||||
push @{$overload_th->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{vs_id_selected}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Virtual Servers are ok.');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{vs_id_selected}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits;
|
||||
foreach (sort keys %{$maps_counters}) {
|
||||
$maps_counters->{$_}->{obj}->set(instance => $id);
|
||||
|
||||
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{vs_id_selected}->{$id});
|
||||
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error();
|
||||
$long_msg_append = ', ';
|
||||
next;
|
||||
}
|
||||
my $exit2 = $maps_counters->{$_}->{obj}->threshold_check();
|
||||
push @exits, $exit2;
|
||||
|
||||
my $output = $maps_counters->{$_}->{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 = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Virtual Server '" . $self->{vs_id_selected}->{$id}->{display} . "' $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 => "Virtual Server '" . $self->{vs_id_selected}->{$id}->{display} . "' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "Virtual Server '" . $self->{vs_id_selected}->{$id}->{display} . "' $long_msg");
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub add_result {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{vs_id_selected}->{$options{instance}} = {};
|
||||
$self->{vs_id_selected}->{$options{instance}}->{display} = $self->{results}->{$oid_vsvrName}->{$oid_vsvrName . '.' . $options{instance}};
|
||||
$self->{vs_id_selected}->{$options{instance}}->{health} = $self->{results}->{$oid_vsvrHealth}->{$oid_vsvrHealth . '.' . $options{instance}};
|
||||
$self->{vs_id_selected}->{$options{instance}}->{state} = $self->{results}->{$oid_vsvrState}->{$oid_vsvrState . '.' . $options{instance}};
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_vsvrName },
|
||||
{ oid => $oid_vsvrState },
|
||||
{ oid => $oid_vsvrHealth },
|
||||
{ oid => $oid_vsvrEntityType },
|
||||
],
|
||||
, nothing_quit => 1);
|
||||
|
||||
foreach my $oid (keys %{$self->{results}->{$oid_vsvrName}}) {
|
||||
$oid =~ /^$oid_vsvrName\.(.*)$/;
|
||||
my $instance = $1;
|
||||
my $filter_name = $self->{results}->{$oid_vsvrName}->{$oid};
|
||||
my $filter_type = $self->{results}->{$oid_vsvrEntityType}->{$oid_vsvrEntityType . '.' . $instance};
|
||||
|
||||
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||
$map_vs_type{$filter_type} !~ /$self->{option_results}->{filter_type}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping Virtual Server '" . $filter_name . "'.");
|
||||
next;
|
||||
}
|
||||
if (!defined($self->{option_results}->{name})) {
|
||||
$self->add_result(instance => $instance);
|
||||
next;
|
||||
}
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $filter_name eq $self->{option_results}->{name}) {
|
||||
$self->add_result(instance => $instance);
|
||||
}
|
||||
if (defined($self->{option_results}->{use_regexp}) && $filter_name =~ /$self->{option_results}->{name}/) {
|
||||
$self->add_result(instance => $instance);
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{vs_id_selected}}) <= 0) {
|
||||
if (defined($self->{option_results}->{name})) {
|
||||
$self->{output}->add_option_msg(short_msg => "No Virtual Server found '" . $self->{option_results}->{name} . "'.");
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "No Virtual Server found.");
|
||||
}
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check vservers status and health.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-health>
|
||||
|
||||
Threshold warning in percent.
|
||||
|
||||
=item B<--critical-health>
|
||||
|
||||
Threshold critical in percent.
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Set the virtual server name.
|
||||
|
||||
=item B<--regexp>
|
||||
|
||||
Allows to use regexp to filter virtual server name (with option --name).
|
||||
|
||||
=item B<--filter-type>
|
||||
|
||||
Filter which type of vserver (can be a regexp).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='CRITICAL,^(?!(green)$)'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,125 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::certificatesexpire;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'certificates', type => 1, cb_prefix_output => 'prefix_certificates_output', message_multiple => 'All certificates are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{volume} = [
|
||||
{ label => 'health', set => {
|
||||
key_values => [ { name => 'days' }, { name => 'display' } ],
|
||||
output_template => '%d days remaining before expiration',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_certificates_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Certificate '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
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-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
sslCertKeyName => { oid => '.1.3.6.1.4.1.5951.4.1.1.56.1.1.1' },
|
||||
sslDaysToExpire => { oid => '.1.3.6.1.4.1.5951.4.1.1.56.1.1.5' },
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{certificates} = {};
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{sslCertKeyName}->{oid} }, { oid => $mapping->{sslDaysToExpire}->{oid} } ],
|
||||
return_type => 1, nothing_quit => 1);
|
||||
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{sslCertKeyName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$result->{sslCertKeyName} !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{sslCertKeyName} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{certificates}->{$instance} = {
|
||||
display => $result->{sslCertKeyName},
|
||||
days => $result->{sslDaysToExpire},
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{certificates}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No certificate found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check number of days remaining before the expiration of certificates (NS-MIB-smiv2).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter by name (can be a regexp).
|
||||
|
||||
=item B<--warning-days>
|
||||
|
||||
Threshold warning in days.
|
||||
|
||||
=item B<--critical-days>
|
||||
|
||||
Threshold critical in days.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::fanspeed;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $mapping = {
|
||||
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
|
||||
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' },
|
||||
};
|
||||
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fanspeed} = {name => 'fans', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'fanspeed'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /Speed|Fan/i);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'fanspeed', instance => $instance));
|
||||
if ($result->{sysHealthCounterValue} == 0) {
|
||||
$self->{output}->output_add(long_msg => sprintf("skipping fan '%s' (counter is 0)",
|
||||
$result->{sysHealthCounterName}));
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{components}->{fanspeed}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("fan '%s' speed is %s C [instance = %s]",
|
||||
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance));
|
||||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fanspeed', instance => $instance, value => $result->{sysHealthCounterValue});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fan '%s' speed is %s rpm", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'speed_' . $result->{sysHealthCounterName}, unit => 'rpm',
|
||||
value => $result->{sysHealthCounterValue},
|
||||
warning => $warn,
|
||||
critical => $crit, min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_psu_status = (
|
||||
0 => 'normal',
|
||||
1 => 'not present',
|
||||
2 => 'failed',
|
||||
3 => 'not supported',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
|
||||
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2', map => \%map_psu_status },
|
||||
};
|
||||
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /PowerSupply(.)FailureStatus/i);
|
||||
my $power_num = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
|
||||
|
||||
next if ($result->{sysHealthCounterValue} eq 'not present' &&
|
||||
$self->absent_problem(section => 'psu', instance => $power_num));
|
||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||
|
||||
$self->{components}->{psu}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]",
|
||||
$power_num, $result->{sysHealthCounterValue}, $power_num));
|
||||
$exit = $self->get_severity(section => 'psu', value => $result->{sysHealthCounterValue});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power supply '%s' status is '%s'", $power_num, $result->{sysHealthCounterValue}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::temperature;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $mapping = {
|
||||
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
|
||||
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' },
|
||||
};
|
||||
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
|
||||
|
||||
sub load {}
|
||||
|
||||
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_nsSysHealthEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /temperature/i);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
if ($result->{sysHealthCounterValue} == 0) {
|
||||
$self->{output}->output_add(long_msg => sprintf("skipping temperature '%s' (counter is 0)",
|
||||
$result->{sysHealthCounterName}));
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s C [instance = %s]",
|
||||
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance));
|
||||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{sysHealthCounterValue});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' is %s C", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'temp_' . $result->{sysHealthCounterName}, unit => 'C',
|
||||
value => $result->{sysHealthCounterValue},
|
||||
warning => $warn,
|
||||
critical => $crit, min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,72 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::voltage;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $mapping = {
|
||||
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
|
||||
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' },
|
||||
};
|
||||
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking voltages");
|
||||
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'voltage'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /Voltage|IntelCPUVttPower/i);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'voltage', instance => $instance));
|
||||
if ($result->{sysHealthCounterValue} == 0) {
|
||||
$self->{output}->output_add(long_msg => sprintf("skipping voltage '%s' (counter is 0)",
|
||||
$result->{sysHealthCounterName}));
|
||||
next;
|
||||
}
|
||||
|
||||
$result->{sysHealthCounterValue} = $result->{sysHealthCounterValue} / 1000; # in mv
|
||||
$self->{components}->{voltage}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("voltage '%s' is %s V [instance = %s]",
|
||||
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance));
|
||||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{sysHealthCounterValue});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Voltage '%s' is %s V", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue}));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'volt_' . $result->{sysHealthCounterName}, unit => 'V',
|
||||
value => $result->{sysHealthCounterValue},
|
||||
warning => $warn,
|
||||
critical => $crit, min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,114 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::connections;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, message_separator => ' - ' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{volume} = [
|
||||
{ label => 'active', set => {
|
||||
key_values => [ { name => 'active' } ],
|
||||
output_template => 'Active Server TCP connections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'active_server', value => 'active_absolute', template => '%s',
|
||||
unit => 'con', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'server', set => {
|
||||
key_values => [ { name => 'server' } ],
|
||||
output_template => 'Server TCP connections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'server', value => 'server_absolute', template => '%s',
|
||||
unit => 'con', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'client', set => {
|
||||
key_values => [ { name => 'client' } ],
|
||||
output_template => 'Client TCP connections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'client', value => 'client_absolute', template => '%s',
|
||||
unit => 'con', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 =>
|
||||
{
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{global} = { client => 0, server => 0, active => 0 };
|
||||
my $oid_tcpCurServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.1.0';
|
||||
my $oid_tcpCurClientConn = '.1.3.6.1.4.1.5951.4.1.1.46.2.0';
|
||||
my $oid_tcpActiveServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.8.0';
|
||||
my $result = $options{snmp}->get_leef(oids => [$oid_tcpCurServerConn, $oid_tcpCurClientConn, $oid_tcpActiveServerConn ], nothing_quit => 1);
|
||||
$self->{global}->{client} = $result->{$oid_tcpCurClientConn};
|
||||
$self->{global}->{server} = $result->{$oid_tcpCurServerConn};
|
||||
$self->{global}->{active} = $result->{$oid_tcpActiveServerConn};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check connections usage (Client, Server, ActiveServer) (NS-ROOT-MIBv2).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'server', 'active', 'client'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'server', 'active', 'client'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::citrix::netscaler::common::mode::cpu;
|
||||
package network::citrix::netscaler::snmp::mode::cpu;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::citrix::netscaler::common::mode::hastate;
|
||||
package network::citrix::netscaler::snmp::mode::hastate;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::health;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(psu)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fanspeed|voltage)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
psu => [
|
||||
['normal', 'OK'],
|
||||
['not present', 'OK'],
|
||||
['failed', 'CRITICAL'],
|
||||
['not supported', 'UNKNOWN'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'network::citrix::netscaler::snmp::mode::components';
|
||||
$self->{components_module} = ['psu', 'fanspeed', 'temperature', 'voltage'];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
|
||||
push @{$self->{request}}, { oid => $oid_nsSysHealthEntry };
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
}
|
||||
|
||||
my $oid_sysHealthCounterName = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1';
|
||||
my $oid_sysHealthCounterValue = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2';
|
||||
|
||||
my %map_psu_status = (
|
||||
0 => 'normal',
|
||||
1 => 'not present',
|
||||
2 => 'failed',
|
||||
3 => 'not supported',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check System Health Status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'temperature', 'voltage', 'fanspeed', 'psu'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=psu)
|
||||
Can also exclude specific instance: --filter=fan,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--absent-problem>
|
||||
|
||||
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
|
||||
Can be specific or global: --absent-problem=psu,1
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'temperature', 'fanspeed', 'voltage' (syntax: type,regexp,threshold)
|
||||
Example: --warning='temperature,.,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for 'temperature', 'fanspeed', 'voltage'(syntax: type,regexp,threshold)
|
||||
Example: --critical='temperature,.*,40'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::citrix::netscaler::common::mode::listvservers;
|
||||
package network::citrix::netscaler::snmp::mode::listvservers;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::citrix::netscaler::common::mode::memory;
|
||||
package network::citrix::netscaler::snmp::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::storage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $instance_mode;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'storage', type => 1, cb_prefix_output => 'prefix_storage_output', message_multiple => 'All storages are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{storage} = [
|
||||
{ label => 'usage', set => {
|
||||
key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ],
|
||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub custom_usage_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'used';
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
if (defined($instance_mode->{option_results}->{free})) {
|
||||
$label = 'free';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
my %total_options = ();
|
||||
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||
$total_options{total} = $self->{result_values}->{total};
|
||||
$total_options{cast_int} = 1;
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
||||
min => 0, max => $self->{result_values}->{total});
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($exit, $threshold_value);
|
||||
$threshold_value = $self->{result_values}->{used};
|
||||
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
|
||||
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||
$threshold_value = $self->{result_values}->{prct_used};
|
||||
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
||||
return $exit;
|
||||
}
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_usage_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
|
||||
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
|
||||
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
|
||||
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
|
||||
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_volume_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Storage '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
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-name:s" => { name => 'filter_name' },
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
"free" => { name => 'free' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$instance_mode = $self;
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
sysHealthDiskName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.1' },
|
||||
sysHealthDiskSize => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.2' }, # in MB
|
||||
sysHealthDiskUsed => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.4' }, # in MB
|
||||
};
|
||||
my $oid_nsSysHealthDiskEntry = '.1.3.6.1.4.1.5951.4.1.1.41.8.1';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{storage} = {};
|
||||
my $snmp_result = $options{snmp}->get_table(oid => $oid_nsSysHealthDiskEntry,
|
||||
nothing_quit => 1);
|
||||
|
||||
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{sysHealthDiskName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$result->{sysHealthDiskName} !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{sysHealthDiskName} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$result->{sysHealthDiskSize} *= 1024 * 1024;
|
||||
$result->{sysHealthDiskUsed} *= 1024 * 1024;
|
||||
$self->{storage}->{$instance} = {
|
||||
display => $result->{sysHealthDiskName},
|
||||
total => $result->{sysHealthDiskSize},
|
||||
used => $result->{sysHealthDiskUsed}
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{storage}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No storage found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check disk usages (NS-MIB-smiv2).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter storage name (can be a regexp).
|
||||
|
||||
=item B<--warning-usage>
|
||||
|
||||
Threshold warning.
|
||||
|
||||
=item B<--critical-usage>
|
||||
|
||||
Threshold critical.
|
||||
|
||||
=item B<--units>
|
||||
|
||||
Units of thresholds (Default: '%') ('%', 'B').
|
||||
|
||||
=item B<--free>
|
||||
|
||||
Thresholds are on free space left.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
#
|
||||
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::vserverstatus;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $instance_mode;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'vservers', type => 1, cb_prefix_output => 'prefix_vservers_output', message_multiple => 'All Virtual Servers are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{volume} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'state' } ],
|
||||
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_threshold_output'),
|
||||
}
|
||||
},
|
||||
{ label => 'health', set => {
|
||||
key_values => [ { name => 'health' }, { name => 'display' } ],
|
||||
output_template => 'Health: %.2f %%', output_error_template => 'Health: %s',
|
||||
perfdatas => [
|
||||
{ value => 'health_absolute', label => 'health', template => '%.2f',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_vservers_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Virtual Server '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
my $overload_th = {};
|
||||
|
||||
my $thresholds = {
|
||||
vs => [
|
||||
['unknown', 'UNKNOWN'],
|
||||
['down|outOfService|transitionToOutOfService|transitionToOutOfServiceDown', 'CRITICAL'],
|
||||
['up', 'OK'],
|
||||
],
|
||||
};
|
||||
|
||||
sub get_severity {
|
||||
my (%options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($overload_th->{$options{section}})) {
|
||||
foreach (@{$overload_th->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return get_severity(section => 'vs', value => $self->{result_values}->{state});
|
||||
}
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
my $msg = 'State : ' . $self->{result_values}->{state};
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
|
||||
return 0;
|
||||
}
|
||||
|
||||
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-type:s" => { name => 'filter_type' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
my ($section, $status, $filter) = ('vs', $1, $2);
|
||||
if ($self->{output}->is_litteral_status(status => $status) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
$overload_th->{$section} = [] if (!defined($overload_th->{$section}));
|
||||
push @{$overload_th->{$section}}, {filter => $filter, status => $status};
|
||||
}
|
||||
}
|
||||
|
||||
sub add_result {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{vservers}->{$options{instance}} = {
|
||||
display => $options{result}->{vsvrName},
|
||||
health => $options{result}->{vsvrHealth},
|
||||
state => $options{result}->{vsvrState},
|
||||
};
|
||||
}
|
||||
|
||||
my %map_vs_type = (
|
||||
0 => 'unknown',
|
||||
1 => 'loadbalancing',
|
||||
2 => 'loadbalancinggroup',
|
||||
3 => 'sslvpn',
|
||||
4 => 'contentswitching',
|
||||
5 => 'cacheredirection',
|
||||
);
|
||||
|
||||
my %map_vs_status = (
|
||||
1 => 'down',
|
||||
2 => 'unknown',
|
||||
3 => 'busy',
|
||||
4 => 'outOfService',
|
||||
5 => 'transitionToOutOfService',
|
||||
7 => 'up',
|
||||
8 => 'transitionToOutOfServiceDown',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
vsvrName => { oid => '.1.3.6.1.4.1.5951.4.1.3.1.1.1' },
|
||||
vsvrState => { oid => '.1.3.6.1.4.1.5951.4.1.3.1.1.5', map => \%map_vs_status },
|
||||
vsvrHealth => { oid => '.1.3.6.1.4.1.5951.4.1.3.1.1.62' },
|
||||
vsvrEntityType => { oid => '.1.3.6.1.4.1.5951.4.1.3.1.1.64', map => \%map_vs_type },
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $mapping->{vsvrName}->{oid} },
|
||||
{ oid => $mapping->{vsvrState}->{oid} },
|
||||
{ oid => $mapping->{vsvrHealth}->{oid} },
|
||||
{ oid => $mapping->{vsvrEntityType}->{oid} },
|
||||
], return_type => 1, nothing_quit => 1);
|
||||
$self->{vservers} = {};
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{vsvrName}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||
$result->{vsvrEntityType} !~ /$self->{option_results}->{filter_type}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping Virtual Server '" . $result->{vsvrName} . "'.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (!defined($self->{option_results}->{name})) {
|
||||
$self->add_result(instance => $instance, result => $result);
|
||||
next;
|
||||
}
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $result->{vsvrName} eq $self->{option_results}->{name}) {
|
||||
$self->add_result(instance => $instance, result => $result);
|
||||
}
|
||||
if (defined($self->{option_results}->{use_regexp}) && $result->{vsvrName} =~ /$self->{option_results}->{name}/) {
|
||||
$self->add_result(instance => $instance, result => $result);
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{vservers}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No virtual server found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check vservers status and health.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-health>
|
||||
|
||||
Threshold warning in percent.
|
||||
|
||||
=item B<--critical-health>
|
||||
|
||||
Threshold critical in percent.
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Set the virtual server name.
|
||||
|
||||
=item B<--regexp>
|
||||
|
||||
Allows to use regexp to filter virtual server name (with option --name).
|
||||
|
||||
=item B<--filter-type>
|
||||
|
||||
Filter which type of vserver (can be a regexp).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='CRITICAL,^(?!(green)$)'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::citrix::netscaler::mpx8000::plugin;
|
||||
package network::citrix::netscaler::snmp::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -29,19 +29,19 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.5';
|
||||
$self->{version} = '0.6';
|
||||
%{$self->{modes}} = (
|
||||
'certificates-expire' => 'network::citrix::netscaler::common::mode::certificatesexpire',
|
||||
'cpu' => 'network::citrix::netscaler::common::mode::cpu',
|
||||
'storage' => 'network::citrix::netscaler::common::mode::storage',
|
||||
'health' => 'network::citrix::netscaler::common::mode::health',
|
||||
'ha-state' => 'network::citrix::netscaler::common::mode::hastate',
|
||||
'certificates-expire' => 'network::citrix::netscaler::snmp::mode::certificatesexpire',
|
||||
'cpu' => 'network::citrix::netscaler::snmp::mode::cpu',
|
||||
'storage' => 'network::citrix::netscaler::snmp::mode::storage',
|
||||
'health' => 'network::citrix::netscaler::snmp::mode::health',
|
||||
'ha-state' => 'network::citrix::netscaler::snmp::mode::hastate',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'list-vservers' => 'network::citrix::netscaler::common::mode::listvservers',
|
||||
'vserver-status' => 'network::citrix::netscaler::common::mode::vserverstatus',
|
||||
'memory' => 'network::citrix::netscaler::common::mode::memory',
|
||||
'connections' => 'network::citrix::netscaler::common::mode::connections',
|
||||
'list-vservers' => 'network::citrix::netscaler::snmp::mode::listvservers',
|
||||
'vserver-status' => 'network::citrix::netscaler::snmp::mode::vserverstatus',
|
||||
'memory' => 'network::citrix::netscaler::snmp::mode::memory',
|
||||
'connections' => 'network::citrix::netscaler::snmp::mode::connections',
|
||||
);
|
||||
|
||||
return $self;
|
||||
|
@ -53,6 +53,6 @@ __END__
|
|||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Citrix NetScaler MPX 8000 Series in SNMP.
|
||||
Check Citrix NetScaler Series in SNMP.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue