diff --git a/centreon-plugins/network/citrix/netscaler/8000/plugin.pm b/centreon-plugins/network/citrix/netscaler/8000/plugin.pm index 9a77c603f..2453f8721 100644 --- a/centreon-plugins/network/citrix/netscaler/8000/plugin.pm +++ b/centreon-plugins/network/citrix/netscaler/8000/plugin.pm @@ -48,7 +48,9 @@ sub new { $self->{version} = '0.5'; %{$self->{modes}} = ( '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', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'memory' => 'network::citrix::netscaler::common::mode::memory', 'traffic' => 'snmp_standard::mode::traffic', diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm b/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm index 66fd2478b..c83f52ba6 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/cpu.pm @@ -48,8 +48,8 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning:s" => { name => 'warning', default => '' }, - "critical:s" => { name => 'critical', default => '' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); return $self; @@ -59,12 +59,12 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warning} . "'."); + 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->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'."); + 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(); } } diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm b/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm new file mode 100644 index 000000000..0d047b0c9 --- /dev/null +++ b/centreon-plugins/network/citrix/netscaler/common/mode/hastate.pm @@ -0,0 +1,180 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +package network::citrix::netscaler::common::mode::hastate; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $oid_haPeerState = '.1.3.6.1.4.1.5951.4.1.1.23.3.0'; +my $oid_haCurState = '.1.3.6.1.4.1.5951.4.1.1.23.24.0'; + +my $thresholds = { + peerstate => [ + ['standalone', 'OK'], + ['primary', 'OK'], + ['secondary', 'OK'], + ['unknown', 'UNKNOWN'], + ], + hastate => [ + ['unknown', 'UNKNOWN'], + ['down|partialFail|monitorFail|completeFail|partialFailSsl|routemonitorFail', 'CRITICAL'], + ['init|up|monitorOk|dump|disabled', 'OK'], + ], +}; + +my %map_hastate_status = ( + 0 => 'unknown', + 1 => 'init', + 2 => 'down', + 3 => 'up', + 4 => 'partialFail', + 5 => 'monitorFail', + 6 => 'monitorOk', + 7 => 'completeFail', + 8 => 'dumb', + 9 => 'disabled', + 10 => 'partialFailSsl', + 11 => 'routemonitorFail', +); + +my %map_peerstate_status = ( + 0 => 'standalone', + 1 => 'primary', + 2 => 'secondary', + 3 => 'unknown', +); + +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 => + { + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ($1, $2, $3); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong treshold-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) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->{result} = $self->{snmp}->get_leef(oids => [$oid_haPeerState, $oid_haCurState], nothing_quit => 1); + + my $exit = $self->get_severity(section => 'peerstate', value => $map_peerstate_status{$self->{result}->{$oid_haPeerState}}); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Peer State is '%s'", + $map_peerstate_status{$self->{result}->{$oid_haPeerState}} + ) + ); + $exit = $self->get_severity(section => 'hastate', value => $map_hastate_status{$self->{result}->{$oid_haCurState}}); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("High Availibility Status is '%s'", + $map_hastate_status{$self->{result}->{$oid_haCurState}} + ) + ); + + $self->{output}->display(); + $self->{output}->exit(); +} + +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; +} + +1; + +__END__ + +=head1 MODE + +Check High Availability Status. + +=over 8 + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp). +It used before default thresholds (order stays). +Example: --threshold-overload='hastate,CRITICAL,^(?!(up)$)' + +=back + +=cut + \ No newline at end of file diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/health.pm b/centreon-plugins/network/citrix/netscaler/common/mode/health.pm index 16e5df015..76a868d82 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/health.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/health.pm @@ -96,7 +96,7 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'."); $self->{output}->option_exit(); } - my ($section, $status, $filter) = ('node', $1, $2); + my ($section, $status, $filter) = ('psu', $1, $2); if ($self->{output}->is_litteral_status(status => $status) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'."); $self->{output}->option_exit(); diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm b/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm index ca603d36c..7db917323 100644 --- a/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm +++ b/centreon-plugins/network/citrix/netscaler/common/mode/memory.pm @@ -48,8 +48,8 @@ sub new { $self->{version} = '1.0'; $options{options}->add_options(arguments => { - "warning:s" => { name => 'warning', default => '' }, - "critical:s" => { name => 'critical', default => '' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, }); return $self; @@ -59,12 +59,12 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warning} . "'."); + 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->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'."); + 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(); } } diff --git a/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm b/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm new file mode 100644 index 000000000..2c96cec8e --- /dev/null +++ b/centreon-plugins/network/citrix/netscaler/common/mode/storage.pm @@ -0,0 +1,143 @@ +################################################################################ +# Copyright 2005-2013 MERETHIS +# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# GPL Licence 2.0. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation ; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, see . +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU +# General Public License cover the whole combination. +# +# As a special exception, the copyright holders of this program give MERETHIS +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of MERETHIS choice, provided that +# MERETHIS also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this +# exception to your version of the program, but you are not obliged to do so. If you +# do not wish to do so, delete this exception statement from your version. +# +# For more information : contact@centreon.com +# Authors : Quentin Garnier +# +#################################################################################### + +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) = @_; + # $options{snmp} = snmp object + $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 +