From 3b6eb9765854cd90836e0618b569fa24c2deb940 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Tue, 9 Sep 2014 17:21:12 +0200 Subject: [PATCH] Fix #5518 --- network/citrix/netscaler/8000/plugin.pm | 19 +- .../common/mode/certificatesexpire.pm | 125 +++++++ .../netscaler/common/mode/listvservers.pm | 174 +++++++++ .../citrix/netscaler/common/mode/memory.pm | 3 - .../netscaler/common/mode/vserverstatus.pm | 351 ++++++++++++++++++ 5 files changed, 661 insertions(+), 11 deletions(-) create mode 100644 network/citrix/netscaler/common/mode/certificatesexpire.pm create mode 100644 network/citrix/netscaler/common/mode/listvservers.pm create mode 100644 network/citrix/netscaler/common/mode/vserverstatus.pm diff --git a/network/citrix/netscaler/8000/plugin.pm b/network/citrix/netscaler/8000/plugin.pm index 2453f8721..374558432 100644 --- a/network/citrix/netscaler/8000/plugin.pm +++ b/network/citrix/netscaler/8000/plugin.pm @@ -47,13 +47,16 @@ 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', + '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', + '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', + 'traffic' => 'snmp_standard::mode::traffic', ); return $self; @@ -65,6 +68,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Citrix NetScaler 8000x Family in SNMP. +Check Citrix NetScaler 8000 Family in SNMP. =cut diff --git a/network/citrix/netscaler/common/mode/certificatesexpire.pm b/network/citrix/netscaler/common/mode/certificatesexpire.pm new file mode 100644 index 000000000..17a394591 --- /dev/null +++ b/network/citrix/netscaler/common/mode/certificatesexpire.pm @@ -0,0 +1,125 @@ +################################################################################ +# 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::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) = @_; + # $options{snmp} = snmp object + $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 + diff --git a/network/citrix/netscaler/common/mode/listvservers.pm b/network/citrix/netscaler/common/mode/listvservers.pm new file mode 100644 index 000000000..102e53571 --- /dev/null +++ b/network/citrix/netscaler/common/mode/listvservers.pm @@ -0,0 +1,174 @@ +################################################################################ +# 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::listvservers; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $oid_vsvrName = '.1.3.6.1.4.1.5951.4.1.3.1.1.1'; +my $oid_vsvrEntityType = '.1.3.6.1.4.1.5951.4.1.3.1.1.64'; + +my %map_vs_type = ( + 0 => 'unknown', + 1 => 'loadbalancing', + 2 => 'loadbalancinggroup', + 3 => 'sslvpn', + 4 => 'contentswitching', + 5 => 'cacheredirection', +); + +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' }, + }); + $self->{vs_id_selected} = []; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{results} = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_vsvrName}, { oid => $oid_vsvrEntityType } ], nothing_quit => 1); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vsvrName}})) { + next if ($oid !~ /^$oid_vsvrName\.(.*)$/); + my $instance = $1; + my $name = $self->{results}->{$oid_vsvrName}->{$oid}; + my $type = $self->{results}->{$oid_vsvrEntityType}->{$oid_vsvrEntityType . '.' . $instance}; + + next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && + $map_vs_type{$type} !~ /$self->{option_results}->{filter_type}/); + + # Get all without a name + if (!defined($self->{option_results}->{name})) { + push @{$self->{vs_id_selected}}, $instance; + next; + } + + $name = $self->{output}->to_utf8($name); + if (!defined($self->{option_results}->{use_regexp}) && $name eq $self->{option_results}->{name}) { + push @{$self->{vs_id_selected}}, $instance; + next; + } + if (defined($self->{option_results}->{use_regexp}) && $name =~ /$self->{option_results}->{name}/) { + push @{$self->{vs_id_selected}}, $instance; + next; + } + + $self->{output}->output_add(long_msg => "Skipping virtual server '" . $name . "': no matching filter name"); + } +} + +sub run { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + foreach my $instance (sort @{$self->{vs_id_selected}}) { + my $name = $self->{results}->{$oid_vsvrName}->{$oid_vsvrName . '.' . $instance}; + my $type = $self->{results}->{$oid_vsvrEntityType}->{$oid_vsvrEntityType . '.' . $instance}; + + $self->{output}->output_add(long_msg => "'" . $name . "' [type = '" . $map_vs_type{$type} . "']"); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List Virtual Servers:'); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'type']); +} + +sub disco_show { + my ($self, %options) = @_; + # $options{snmp} = snmp object + $self->{snmp} = $options{snmp}; + + $self->manage_selection(); + foreach my $instance (sort @{$self->{vs_id_selected}}) { + my $name = $self->{results}->{$oid_vsvrName}->{$oid_vsvrName . '.' . $instance}; + my $type = $self->{results}->{$oid_vsvrEntityType}->{$oid_vsvrEntityType . '.' . $instance}; + + $self->{output}->add_disco_entry(name => $name, type => $map_vs_type{$type}); + } +} + +1; + +__END__ + +=head1 MODE + +List Virtual Servers. + +=over 8 + +=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). + +=back + +=cut + \ No newline at end of file diff --git a/network/citrix/netscaler/common/mode/memory.pm b/network/citrix/netscaler/common/mode/memory.pm index 7db917323..c5eb78a21 100644 --- a/network/citrix/netscaler/common/mode/memory.pm +++ b/network/citrix/netscaler/common/mode/memory.pm @@ -103,9 +103,6 @@ sub run { $self->{output}->display(); $self->{output}->exit(); - - - } 1; diff --git a/network/citrix/netscaler/common/mode/vserverstatus.pm b/network/citrix/netscaler/common/mode/vserverstatus.pm new file mode 100644 index 000000000..31817759a --- /dev/null +++ b/network/citrix/netscaler/common/mode/vserverstatus.pm @@ -0,0 +1,351 @@ +################################################################################ +# Copyright 2005-2014 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::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 treshold-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 treshold-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) = @_; + # $options{snmp} = snmp object + $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