+ WIP on centreon vmware connector

This commit is contained in:
Quentin Garnier 2014-10-28 17:33:55 +01:00
parent 93bf4e63ce
commit 24cf004c64
8 changed files with 819 additions and 21 deletions

View File

@ -65,6 +65,9 @@ sub new {
{
"connector-hostname:s@" => { name => 'connector_hostname' },
"connector-port:s@" => { name => 'connector_port' },
"vsphere-address:s@" => { name => 'vsphere_address' },
"vsphere-username:s@" => { name => 'vsphere_username' },
"vsphere-password:s@" => { name => 'vsphere_password' },
"container:s@" => { name => 'container' },
"timeout:s@" => { name => 'timeout' },
});
@ -114,7 +117,10 @@ sub check_options {
$self->{connector_port} = (defined($self->{option_results}->{connector_port})) ? shift(@{$self->{option_results}->{connector_port}}) : 5700;
$self->{container} = (defined($self->{option_results}->{container})) ? shift(@{$self->{option_results}->{container}}) : 'default';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : undef;
$self->{vsphere_address} = (defined($self->{option_results}->{vsphere_address})) ? shift(@{$self->{option_results}->{vsphere_address}}) : undef;
$self->{vsphere_username} = (defined($self->{option_results}->{vsphere_username})) ? shift(@{$self->{option_results}->{vsphere_username}}) : undef;
$self->{vsphere_password} = (defined($self->{option_results}->{vsphere_password})) ? shift(@{$self->{option_results}->{vsphere_password}}) : undef;
if (!defined($self->{connector_hostname})) {
$self->{output}->add_option_msg(short_msg => "Please set option --connector-hostname.");
$self->{output}->option_exit();
@ -201,7 +207,10 @@ sub run {
$self->{json_send}->{identity} = 'client-' . unpack('H*', $self->{uuid});
$self->{json_send}->{connector_hostname} = $self->{connector_hostname};
$self->{json_send}->{connector_port} = $self->{connector_port};
$self->{json_send}->{container} = $self->{container};
$self->{json_send}->{container} = $self->{container};
$self->{json_send}->{vsphere_address} = $self->{vsphere_address};
$self->{json_send}->{vsphere_username} = $self->{vsphere_username};
$self->{json_send}->{vsphere_password} = $self->{vsphere_password};
# Init
my $context = zmq_init();
@ -276,6 +285,18 @@ Connector port (default: 5700).
Container to use (it depends of the connector configuration).
=item B<--vsphere-address>
Address of vpshere/ESX to connect.
=item B<--vsphere-username>
Username of vpshere/ESX connection (with --vsphere-address).
=item B<--vsphere-password>
Password of vpshere/ESX connection (with --vsphere-address).
=item B<--timeout>
Set global execution timeout (Default: 50)

View File

@ -0,0 +1,131 @@
################################################################################
# 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 <http://www.gnu.org/licenses>.
#
# 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 <qgarnier@merethis.com>
#
####################################################################################
package apps::vmware::connector::mode::datastorehost;
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 =>
{
"esx-hostname:s" => { name => 'esx_hostname' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
"datastore-name:s" => { name => 'datastore_name' },
"filter-datastore:s" => { name => 'filter_datastore' },
});
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();
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'datastorehost');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check ESX datastore latency.
=over 8
=item B<--esx-hostname>
ESX hostname to check.
If not set, we check all ESX.
=item B<--filter>
ESX hostname is a regexp.
=item B<--datastore-name>
Datastore to check.
If not set, we check all datastores.
=item B<--filter-datastore>
Datastore name is a regexp.
=item B<--disconnect-status>
Status if ESX host disconnected (default: 'unknown').
=item B<--warning>
Threshold warning in ms.
=item B<--critical>
Threshold critical in ms.
=back
=cut

View File

@ -0,0 +1,119 @@
################################################################################
# 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 <http://www.gnu.org/licenses>.
#
# 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 <qgarnier@merethis.com>
#
####################################################################################
package apps::vmware::connector::mode::datastoreio;
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 =>
{
"datastore-name:s" => { name => 'datastore_name' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"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();
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'datastoreio');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check datastore IO.
=over 8
=item B<--datastore-name>
datastore name to list.
=item B<--filter>
Datastore name is a regexp.
=item B<--disconnect-status>
Status if datastore disconnected (default: 'unknown').
=item B<--warning>
Threshold warning in bytes per seconds.
=item B<--critical>
Threshold critical in bytes per seconds.
=back
=cut

View File

@ -0,0 +1,124 @@
################################################################################
# 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 <http://www.gnu.org/licenses>.
#
# 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 <qgarnier@merethis.com>
#
####################################################################################
package apps::vmware::connector::mode::datastoreiops;
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 =>
{
"datastore-name:s" => { name => 'datastore_name' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
"detail-iops-min:s" => { name => 'detail_iops_min', default => 50 },
});
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();
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'datastoreiops');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check datastore IOPs.
=over 8
=item B<--datastore-name>
datastore name to list.
=item B<--filter>
Datastore name is a regexp.
=item B<--disconnect-status>
Status if datastore disconnected (default: 'unknown').
=item B<--detail-iops-min>
Only display VMs with iops higher value (default: 50).
=item B<--warning>
Threshold warning in IOPs.
=item B<--critical>
Threshold critical in IOPs.
=back
=cut

View File

@ -0,0 +1,133 @@
################################################################################
# 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 <http://www.gnu.org/licenses>.
#
# 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 <qgarnier@merethis.com>
#
####################################################################################
package apps::vmware::connector::mode::datastoreusage;
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 =>
{
"datastore-name:s" => { name => 'datastore_name' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
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();
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{units}) || $self->{option_results}->{units} !~ /^(%|B)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong units option '" . $self->{option_results}->{units} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'datastoreusage');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check datastore usage.
=over 8
=item B<--datastore-name>
datastore name to list.
=item B<--filter>
Datastore name is a regexp.
=item B<--disconnect-status>
Status if datastore disconnected (default: 'unknown').
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=back
=cut

View File

@ -0,0 +1,141 @@
################################################################################
# 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 <http://www.gnu.org/licenses>.
#
# 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 <qgarnier@merethis.com>
#
####################################################################################
package apps::vmware::connector::mode::datastorevm;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"vm-hostname:s" => { name => 'vm_hostname' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"nopoweredon-status:s" => { name => 'nopoweredon_status', default => 'unknown' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"datastore-name:s" => { name => 'datastore_name' },
"filter-datastore:s" => { name => 'filter_datastore' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach my $label (('warning', 'critical')) {
if (($self->{perfdata}->threshold_validate(label => $label, value => $self->{option_results}->{$label})) == 0) {
my ($label_opt) = $label;
$label_opt =~ tr/_/-/;
$self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'.");
$self->{output}->option_exit();
}
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{nopoweredon_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong nopoweredon-status option '" . $self->{option_results}->{nopoweredon_status} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'datastorevm');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check virtual machine IOPs on datastore(s).
=over 8
=item B<--vm-hostname>
VM hostname to check.
If not set, we check all VMs.
=item B<--filter>
VM hostname is a regexp.
=item B<--datastore-name>
Datastore to check.
If not set, we check all datastores.
=item B<--filter-datastore>
Datastore name is a regexp.
=item B<--disconnect-status>
Status if VM disconnected (default: 'unknown').
=item B<--nopoweredon-status>
Status if VM is not poweredOn (default: 'unknown').
=item B<--warning>
Threshold warning in IOPs.
=item B<--critical>
Threshold critical in IOPs.
=back
=cut

View File

@ -0,0 +1,123 @@
################################################################################
# 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 <http://www.gnu.org/licenses>.
#
# 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 <qgarnier@merethis.com>
#
####################################################################################
package apps::vmware::connector::mode::thinprovisioningvm;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"vm-hostname:s" => { name => 'vm_hostname' },
"filter" => { name => 'filter' },
"disconnect-status:s" => { name => 'disconnect_status', default => 'unknown' },
"thinprovisioning-status:s" => { name => 'thinprovisioning_status' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if ($self->{output}->is_litteral_status(status => $self->{option_results}->{disconnect_status}) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong disconnect-status option '" . $self->{option_results}->{disconnect_status} . "'.");
$self->{output}->option_exit();
}
if (defined($self->{option_results}->{thinprovisioning_status}) && $self->{option_results}->{thinprovisioning_status} ne '') {
my ($entry, $status) = split /,/, $self->{option_results}->{thinprovisioning_status};
if ($entry !~ /^(notactive|active)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong thinprovisioning-status option. Can only be 'active' or 'noactive'. Not: '" . $entry . "'.");
$self->{output}->option_exit();
}
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong thinprovisioning-status option. Not a good status: '" . $status . "'.");
$self->{output}->option_exit();
}
}
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->add_params(params => $self->{option_results},
command => 'thinprovisioningvm');
$self->{connector}->run();
}
1;
__END__
=head1 MODE
Check virtual machine thin provisioning option.
=over 8
=item B<--vm-hostname>
VM hostname to check.
If not set, we check all VMs.
=item B<--filter>
VM hostname is a regexp.
=item B<--disconnect-status>
Status if VM disconnected (default: 'unknown').
=item B<--nopoweredon-skip>
Skip check if VM is not poweredOn.
=item B<--thinprovisioning-status>
Thinprovisioning status (default: none)
Example: 'active,CRITICAL' or 'notactive,WARNING'
=back
=cut

View File

@ -47,25 +47,31 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'countvm-host' => 'apps::vmware::connector::mode::countvmhost',
'cpu-host' => 'apps::vmware::connector::mode::cpuhost',
'cpu-vm' => 'apps::vmware::connector::mode::cpuvm',
'getmap' => 'apps::vmware::connector::mode::getmap',
'health-host' => 'apps::vmware::connector::mode::healthhost',
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
'list-nichost' => 'apps::vmware::connector::mode::listnichost',
'maintenance-host' => 'apps::vmware::connector::mode::maintenancehost',
'memory-host' => 'apps::vmware::connector::mode::memoryhost',
'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
'net-host' => 'apps::vmware::connector::mode::nethost',
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
'status-host' => 'apps::vmware::connector::mode::statushost',
'swap-host' => 'apps::vmware::connector::mode::swaphost',
'swap-vm' => 'apps::vmware::connector::mode::swapvm',
'tools-vm' => 'apps::vmware::connector::mode::toolsvm',
'uptime-host' => 'apps::vmware::connector::mode::uptimehost',
'countvm-host' => 'apps::vmware::connector::mode::countvmhost',
'cpu-host' => 'apps::vmware::connector::mode::cpuhost',
'cpu-vm' => 'apps::vmware::connector::mode::cpuvm',
'datastore-host' => 'apps::vmware::connector::mode::datastorehost',
'datastore-io' => 'apps::vmware::connector::mode::datastoreio',
'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops',
'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage',
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
'getmap' => 'apps::vmware::connector::mode::getmap',
'health-host' => 'apps::vmware::connector::mode::healthhost',
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
'list-nichost' => 'apps::vmware::connector::mode::listnichost',
'maintenance-host' => 'apps::vmware::connector::mode::maintenancehost',
'memory-host' => 'apps::vmware::connector::mode::memoryhost',
'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
'net-host' => 'apps::vmware::connector::mode::nethost',
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
'status-host' => 'apps::vmware::connector::mode::statushost',
'swap-host' => 'apps::vmware::connector::mode::swaphost',
'swap-vm' => 'apps::vmware::connector::mode::swapvm',
'thinprovisioning-vm' => 'apps::vmware::connector::mode::thinprovisioningvm',
'tools-vm' => 'apps::vmware::connector::mode::toolsvm',
'uptime-host' => 'apps::vmware::connector::mode::uptimehost',
);
$self->{custom_modes}{connector} = 'apps::vmware::connector::custom::connector';