diff --git a/connectors/vmware/src/centreon/script/centreon_vmware.pm b/connectors/vmware/src/centreon/script/centreon_vmware.pm index 7f9c86410..b18507cbc 100644 --- a/connectors/vmware/src/centreon/script/centreon_vmware.pm +++ b/connectors/vmware/src/centreon/script/centreon_vmware.pm @@ -262,7 +262,7 @@ sub load_module { for (@_) { (my $file = "$_.pm") =~ s{::}{/}g; require $file; - my $obj = $_->new($self->{logger}); + my $obj = $_->new(logger => $self->{logger}); $self->{modules_registry}->{$obj->getCommandName()} = $obj; } } diff --git a/connectors/vmware/src/centreon/vmware/cmdalarmdatacenter.pm b/connectors/vmware/src/centreon/vmware/cmdalarmdatacenter.pm index d05b5e85d..52953906f 100644 --- a/connectors/vmware/src/centreon/vmware/cmdalarmdatacenter.pm +++ b/connectors/vmware/src/centreon/vmware/cmdalarmdatacenter.pm @@ -18,6 +18,8 @@ package centreon::vmware::cmdalarmdatacenter; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; @@ -25,20 +27,15 @@ use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'alarmdatacenter'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -62,12 +59,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => 0); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdalarmhost.pm b/connectors/vmware/src/centreon/vmware/cmdalarmhost.pm index 595db46f8..5a61e69a1 100644 --- a/connectors/vmware/src/centreon/vmware/cmdalarmhost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdalarmhost.pm @@ -18,6 +18,8 @@ package centreon::vmware::cmdalarmhost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; @@ -25,20 +27,15 @@ use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'alarmhost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -62,12 +59,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => 0); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdbase.pm b/connectors/vmware/src/centreon/vmware/cmdbase.pm new file mode 100644 index 000000000..9d33ca6dd --- /dev/null +++ b/connectors/vmware/src/centreon/vmware/cmdbase.pm @@ -0,0 +1,45 @@ +# Copyright 2015 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package centreon::vmware::cmdbase; + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + + $self->{logger} = $options{logger}; + + return $self; +} + +sub getCommandName { + my $self = shift; + return $self->{commandName}; +} + +sub set_connector { + my ($self, %options) = @_; + + $self->{connector} = $options{connector}; +} + +1; diff --git a/connectors/vmware/src/centreon/vmware/cmdcountvmhost.pm b/connectors/vmware/src/centreon/vmware/cmdcountvmhost.pm index 5b0402eb6..b750be4dd 100644 --- a/connectors/vmware/src/centreon/vmware/cmdcountvmhost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdcountvmhost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdcountvmhost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'countvmhost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdcpuhost.pm b/connectors/vmware/src/centreon/vmware/cmdcpuhost.pm index 8db090a67..0cf5a084b 100644 --- a/connectors/vmware/src/centreon/vmware/cmdcpuhost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdcpuhost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdcpuhost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'cpuhost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -76,12 +73,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => $options{arguments}->{critical}); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdcpuvm.pm b/connectors/vmware/src/centreon/vmware/cmdcpuvm.pm index 21828e001..f1bdc0abe 100644 --- a/connectors/vmware/src/centreon/vmware/cmdcpuvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdcpuvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdcpuvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'cpuvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -80,12 +77,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastorecountvm.pm b/connectors/vmware/src/centreon/vmware/cmddatastorecountvm.pm index 352a6e2d5..f7ae0476a 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastorecountvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastorecountvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmddatastorecountvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastorecountvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastorehost.pm b/connectors/vmware/src/centreon/vmware/cmddatastorehost.pm index 11c298d50..b00344914 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastorehost.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastorehost.pm @@ -18,26 +18,23 @@ package centreon::vmware::cmddatastorehost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use File::Basename; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastorehost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -80,12 +77,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastoreio.pm b/connectors/vmware/src/centreon/vmware/cmddatastoreio.pm index 66108d125..ca9f0f6b3 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastoreio.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastoreio.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmddatastoreio; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastoreio'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm b/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm index 5839e28c0..490cbd5e6 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmddatastoreiops; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastoreiops'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastoresnapshot.pm b/connectors/vmware/src/centreon/vmware/cmddatastoresnapshot.pm index cc704846b..45bc17133 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastoresnapshot.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastoresnapshot.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmddatastoresnapshot; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastoresnapshot'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastoreusage.pm b/connectors/vmware/src/centreon/vmware/cmddatastoreusage.pm index 5f80a9fd6..1b78eb6ef 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastoreusage.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastoreusage.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmddatastoreusage; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastoreusage'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -78,12 +75,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmddatastorevm.pm b/connectors/vmware/src/centreon/vmware/cmddatastorevm.pm index 7e2bae5fc..d8d989565 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastorevm.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastorevm.pm @@ -18,26 +18,23 @@ package centreon::vmware::cmddatastorevm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; use File::Basename; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'datastorevm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -86,12 +83,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdgetmap.pm b/connectors/vmware/src/centreon/vmware/cmdgetmap.pm index 3b98a61f2..e6afd9808 100644 --- a/connectors/vmware/src/centreon/vmware/cmdgetmap.pm +++ b/connectors/vmware/src/centreon/vmware/cmdgetmap.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdgetmap; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'getmap'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -58,12 +55,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdhealthhost.pm b/connectors/vmware/src/centreon/vmware/cmdhealthhost.pm index 870ebd91c..0ba3e5397 100644 --- a/connectors/vmware/src/centreon/vmware/cmdhealthhost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdhealthhost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdhealthhost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'healthhost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -66,12 +63,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => 0); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdlimitvm.pm b/connectors/vmware/src/centreon/vmware/cmdlimitvm.pm index 823fbdfff..6c47929fe 100644 --- a/connectors/vmware/src/centreon/vmware/cmdlimitvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdlimitvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdlimitvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'limitvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -82,12 +79,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub display_verbose { my ($self, %options) = @_; diff --git a/connectors/vmware/src/centreon/vmware/cmdlistdatacenters.pm b/connectors/vmware/src/centreon/vmware/cmdlistdatacenters.pm index 577b8d742..79d8407cd 100644 --- a/connectors/vmware/src/centreon/vmware/cmdlistdatacenters.pm +++ b/connectors/vmware/src/centreon/vmware/cmdlistdatacenters.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdlistdatacenters; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'listdatacenters'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -58,12 +55,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdlistdatastores.pm b/connectors/vmware/src/centreon/vmware/cmdlistdatastores.pm index 1575372e6..a221ba219 100644 --- a/connectors/vmware/src/centreon/vmware/cmdlistdatastores.pm +++ b/connectors/vmware/src/centreon/vmware/cmdlistdatastores.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdlistdatastores; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'listdatastores'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -58,12 +55,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdlistnichost.pm b/connectors/vmware/src/centreon/vmware/cmdlistnichost.pm index c9c46c69c..d0f4ef9ce 100644 --- a/connectors/vmware/src/centreon/vmware/cmdlistnichost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdlistnichost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdlistnichost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'listnichost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -58,12 +55,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; my %nic_in_vswitch = (); diff --git a/connectors/vmware/src/centreon/vmware/cmdmaintenancehost.pm b/connectors/vmware/src/centreon/vmware/cmdmaintenancehost.pm index 987fa8adb..2cd2095aa 100644 --- a/connectors/vmware/src/centreon/vmware/cmdmaintenancehost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdmaintenancehost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdmaintenancehost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'maintenancehost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -70,12 +67,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdmemhost.pm b/connectors/vmware/src/centreon/vmware/cmdmemhost.pm index 77d7287c4..42d3f9ca6 100644 --- a/connectors/vmware/src/centreon/vmware/cmdmemhost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdmemhost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdmemhost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'memhost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -76,12 +73,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => $options{arguments}->{critical}); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdmemvm.pm b/connectors/vmware/src/centreon/vmware/cmdmemvm.pm index 9b4e952c9..1aa22444a 100644 --- a/connectors/vmware/src/centreon/vmware/cmdmemvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdmemvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdmemvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'memvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -82,12 +79,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => $options{arguments}->{critical}); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdnethost.pm b/connectors/vmware/src/centreon/vmware/cmdnethost.pm index e7407bad9..52bc4a25f 100644 --- a/connectors/vmware/src/centreon/vmware/cmdnethost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdnethost.pm @@ -18,26 +18,22 @@ package centreon::vmware::cmdnethost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'nethost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - - sub checkArgs { my ($self, %options) = @_; @@ -86,12 +82,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdservicehost.pm b/connectors/vmware/src/centreon/vmware/cmdservicehost.pm index f2ed9d966..c46baf588 100644 --- a/connectors/vmware/src/centreon/vmware/cmdservicehost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdservicehost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdservicehost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'servicehost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -64,12 +61,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdsnapshotvm.pm b/connectors/vmware/src/centreon/vmware/cmdsnapshotvm.pm index ec855e091..da068ac0b 100644 --- a/connectors/vmware/src/centreon/vmware/cmdsnapshotvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdsnapshotvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdsnapshotvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'snapshotvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdstatushost.pm b/connectors/vmware/src/centreon/vmware/cmdstatushost.pm index 46b146e29..1ce5d361c 100644 --- a/connectors/vmware/src/centreon/vmware/cmdstatushost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdstatushost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdstatushost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'statushost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -64,12 +61,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdstatusvm.pm b/connectors/vmware/src/centreon/vmware/cmdstatusvm.pm index d4e389022..eec24446d 100644 --- a/connectors/vmware/src/centreon/vmware/cmdstatusvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdstatusvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdstatusvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'statusvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -64,12 +61,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdswaphost.pm b/connectors/vmware/src/centreon/vmware/cmdswaphost.pm index a2f627e26..58ac8feb8 100644 --- a/connectors/vmware/src/centreon/vmware/cmdswaphost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdswaphost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdswaphost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'swaphost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -76,12 +73,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => $options{arguments}->{critical}); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdswapvm.pm b/connectors/vmware/src/centreon/vmware/cmdswapvm.pm index e75897ab0..a2c28178e 100644 --- a/connectors/vmware/src/centreon/vmware/cmdswapvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdswapvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdswapvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'swapvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -82,12 +79,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => $options{arguments}->{critical}); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdthinprovisioningvm.pm b/connectors/vmware/src/centreon/vmware/cmdthinprovisioningvm.pm index 974cb1e45..dc2f08552 100644 --- a/connectors/vmware/src/centreon/vmware/cmdthinprovisioningvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdthinprovisioningvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdthinprovisioningvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'thinprovisioningvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -71,12 +68,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub display_verbose { my ($self, %options) = @_; diff --git a/connectors/vmware/src/centreon/vmware/cmdtimehost.pm b/connectors/vmware/src/centreon/vmware/cmdtimehost.pm index c531fba61..ed11260f3 100644 --- a/connectors/vmware/src/centreon/vmware/cmdtimehost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdtimehost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdtimehost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'timehost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -74,12 +71,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdtoolsvm.pm b/connectors/vmware/src/centreon/vmware/cmdtoolsvm.pm index 60d4026d7..9ad8aa312 100644 --- a/connectors/vmware/src/centreon/vmware/cmdtoolsvm.pm +++ b/connectors/vmware/src/centreon/vmware/cmdtoolsvm.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmdtoolsvm; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'toolsvm'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -82,12 +79,6 @@ sub initArgs { $self->{manager}->{output}->{plugin} = $options{arguments}->{identity}; } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub display_verbose { my ($self, %options) = @_; diff --git a/connectors/vmware/src/centreon/vmware/cmduptimehost.pm b/connectors/vmware/src/centreon/vmware/cmduptimehost.pm index 25b5b974e..cdd41764f 100644 --- a/connectors/vmware/src/centreon/vmware/cmduptimehost.pm +++ b/connectors/vmware/src/centreon/vmware/cmduptimehost.pm @@ -18,25 +18,22 @@ package centreon::vmware::cmduptimehost; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'uptimehost'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -76,12 +73,6 @@ sub initArgs { $self->{manager}->{perfdata}->threshold_validate(label => 'critical', value => $options{arguments}->{critical}); } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift; diff --git a/connectors/vmware/src/centreon/vmware/cmdvmoperationcluster.pm b/connectors/vmware/src/centreon/vmware/cmdvmoperationcluster.pm index 822a926b3..0548bf0a4 100644 --- a/connectors/vmware/src/centreon/vmware/cmdvmoperationcluster.pm +++ b/connectors/vmware/src/centreon/vmware/cmdvmoperationcluster.pm @@ -18,6 +18,8 @@ package centreon::vmware::cmdvmoperationcluster; +use base qw(centreon::vmware::cmdbase); + use strict; use warnings; use centreon::vmware::common; @@ -25,20 +27,15 @@ use centreon::plugins::statefile; use Digest::MD5 qw(md5_hex); sub new { - my $class = shift; - my $self = {}; - $self->{logger} = shift; + my ($class, %options) = @_; + my $self = $class->SUPER::new(%options); + bless $self, $class; + $self->{commandName} = 'vmoperationcluster'; - bless $self, $class; return $self; } -sub getCommandName { - my $self = shift; - return $self->{commandName}; -} - sub checkArgs { my ($self, %options) = @_; @@ -72,12 +69,6 @@ sub initArgs { } } -sub set_connector { - my ($self, %options) = @_; - - $self->{connector} = $options{connector}; -} - sub run { my $self = shift;