WIP centreon compat vmware 3.0.0 connector

This commit is contained in:
garnier-quentin 2019-02-01 15:52:05 +01:00
parent 72b2ccbcc7
commit 4a435c22c9
3 changed files with 27 additions and 13 deletions

View File

@ -224,6 +224,15 @@ sub get_id {
return $self->{connector_hostname} . '.' . $self->{connector_port} . '.' . $self->{container};
}
sub strip_cr {
my ($self, %options) = @_;
$options{value} =~ s/^\s+.*\s+$//mg;
$options{value} =~ s/\r//mg;
$options{value} =~ s/\n/ -- /mg;
return $options{value};
}
sub execute {
my ($self, %options) = @_;

View File

@ -112,17 +112,24 @@ sub set_counters {
sub prefix_vm_output {
my ($self, %options) = @_;
return "Virtual machine '" . $options{instance_value}->{display} . "' : ";
my $msg = "Virtual machine '" . $options{instance_value}->{display} . "'";
if (defined($options{instance_value}->{config_annotation})) {
$msg .= ' [annotation: ' . $options{instance_value}->{config_annotation} . ']';
}
$msg .= ' : ';
return $msg;
}
sub vm_long_output {
my ($self, %options) = @_;
if (!defined($options{instance_value}->{display})) {
use Data::Dumper;
print Data::Dumper::Dumper($options{instance_value});
my $msg = "checking virtual machine '" . $options{instance_value}->{display} . "'";
if (defined($options{instance_value}->{config_annotation})) {
$msg .= ' [annotation: ' . $options{instance_value}->{config_annotation} . ']';
}
return "checking virtual machine '" . $options{instance_value}->{display} . "'";
return $msg;
}
sub prefix_global_cpu_output {
@ -151,7 +158,7 @@ sub new {
"scope-host:s" => { name => 'scope_host' },
"display-description" => { name => 'display_description' },
"filter-description:s" => { name => 'filter_description' },
"unknown-status:s" => { name => 'unknown_status', default => '%{connection_state} !~ /^connected$/ and %{power_state} !~ /^poweredOn$/i' },
"unknown-status:s" => { name => 'unknown_status', default => '%{connection_state} !~ /^connected$/ or %{power_state} !~ /^poweredOn$/i' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '' },
});
@ -189,8 +196,8 @@ sub manage_selection {
},
};
if (defined($self->{options_results}->{display_description})) {
$self->{vm}->{$vm_name}->{config_annotation} = $response->{data}->{$vm_id}->{'config.annotation'};
if (defined($self->{option_results}->{display_description})) {
$self->{vm}->{$vm_name}->{config_annotation} = $options{custom}->strip_cr(value => $response->{data}->{$vm_id}->{'config.annotation'});
}
foreach my $cpu_id (sort keys %{$response->{data}->{$vm_id}->{cpu}}) {
@ -236,7 +243,7 @@ Search in following host(s) (can be a regexp).
=item B<--unknown-status>
Set warning threshold for status (Default: '%{connection_state} !~ /^connected$/ and %{power_state} !~ /^poweredOn$/i').
Set warning threshold for status (Default: '%{connection_state} !~ /^connected$/ or %{power_state} !~ /^poweredOn$/i').
Can used special variables like: %{status}
=item B<--warning-status>

View File

@ -477,10 +477,8 @@ sub run_multiple {
$self->{prefix_multiple_output} = '';
$self->{prefix_multiple_output_done} = { ok => 0, warning => 0, critical => 0, unknown => 0 };
if ($multiple == 0) {
$self->{prefix_multiple_output} = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$instance})
if (defined($options{config}->{cb_prefix_output}));
}
$self->{prefix_multiple_output} = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$instance})
if (defined($options{config}->{cb_prefix_output}));
foreach my $group (@{$options{config}->{group}}) {
$self->{$group->{name}} = $self->{$options{config}->{name}}->{$instance}->{$group->{name}};