From 01ff8c68ae653bec81797870d9c38495627e81bd Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 10 May 2017 10:48:59 +0200 Subject: [PATCH] + add filter for hyper-v modes --- .../2012/local/mode/nodeintegrationservice.pm | 26 +++++++++---- apps/hyperv/2012/local/mode/nodesnapshot.pm | 16 ++++++-- apps/hyperv/2012/local/mode/nodevmstatus.pm | 20 +++++++--- .../local/mode/scvmmintegrationservice.pm | 2 +- apps/hyperv/2012/local/mode/scvmmsnapshot.pm | 39 ++++++++++--------- apps/hyperv/2012/local/mode/scvmmvmstatus.pm | 36 +++++++++-------- .../hyperv/2012/nodeintegrationservice.pm | 4 +- .../powershell/hyperv/2012/nodesnapshot.pm | 4 +- .../powershell/hyperv/2012/nodevmstatus.pm | 4 +- .../powershell/hyperv/2012/scvmmsnapshot.pm | 4 +- .../powershell/hyperv/2012/scvmmvmstatus.pm | 4 +- 11 files changed, 102 insertions(+), 57 deletions(-) diff --git a/apps/hyperv/2012/local/mode/nodeintegrationservice.pm b/apps/hyperv/2012/local/mode/nodeintegrationservice.pm index 49042c056..3d5554d18 100644 --- a/apps/hyperv/2012/local/mode/nodeintegrationservice.pm +++ b/apps/hyperv/2012/local/mode/nodeintegrationservice.pm @@ -160,6 +160,7 @@ sub new { "no-ps" => { name => 'no_ps' }, "ps-exec-only" => { name => 'ps_exec_only' }, "filter-vm:s" => { name => 'filter_vm' }, + "filter-note:s" => { name => 'filter_note' }, "filter-status:s" => { name => 'filter_status', default => 'running' }, "warning-global-status:s" => { name => 'warning_global_status', default => '%{integration_service_state} =~ /Update required/i' }, "critical-global-status:s" => { name => 'critical_global_status', default => '' }, @@ -205,14 +206,14 @@ sub manage_selection { $self->{output}->exit(); } - #[name= test1 ][state= Running ][IntegrationServicesState= Update required ][IntegrationServicesVersion= 3.1 ] + #[name= test1 ][state= Running ][IntegrationServicesState= Update required ][IntegrationServicesVersion= 3.1 ][note= ] #[service= Time Synchronization ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= Heartbeat ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= Key-Value Pair Exchange ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= Shutdown ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= VSS ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= Guest Service Interface ][enabled= False][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ] - #[name= test2 ][state= Running ][IntegrationServicesState= ][IntegrationServicesVersion= ] + #[name= test2 ][state= Running ][IntegrationServicesState= ][IntegrationServicesVersion= ][note= ] #[service= Time Synchronization ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= Heartbeat ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] #[service= Key-Value Pair Exchange ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ] @@ -220,8 +221,8 @@ sub manage_selection { $self->{vm} = {}; my $id = 1; - while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[IntegrationServicesState=\s*(.*?)\s*\]\[IntegrationServicesVersion=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) { - my ($name, $status, $integration_service_state, $integration_service_version, $content) = ($1, $2, $3, $4, $5); + while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[IntegrationServicesState=\s*(.*?)\s*\]\[IntegrationServicesVersion=\s*(.*?)\s*\]\[note=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) { + my ($name, $status, $integration_service_state, $integration_service_version, $note, $content) = ($1, $2, $3, $4, $5, $6); if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' && $name !~ /$self->{option_results}->{filter_vm}/i) { @@ -233,6 +234,11 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $status . "': no matching filter.", debug => 1); next; } + if (defined($self->{option_results}->{filter_note}) && $self->{option_results}->{filter_note} ne '' && + $note !~ /$self->{option_results}->{filter_note}/i) { + $self->{output}->output_add(long_msg => "skipping '" . $note . "': no matching filter.", debug => 1); + next; + } $self->{vm}->{$id} = { display => $name, vm => $name, service => {} }; $self->{vm}->{$id}->{global} = { @@ -283,14 +289,18 @@ Command options (Default: '-InputFormat none -NoLogo -EncodedCommand'). Print powershell output. -=item B<--filter-status> - -Filter virtual machine status (can be a regexp) (Default: 'running'). - =item B<--filter-vm> Filter virtual machines (can be a regexp). +=item B<--filter-note> + +Filter by VM notes (can be a regexp). + +=item B<--filter-status> + +Filter virtual machine status (can be a regexp) (Default: 'running'). + =item B<--warning-global-status> Set warning threshold for status (Default: '%{integration_service_state} =~ /Update required/i'). diff --git a/apps/hyperv/2012/local/mode/nodesnapshot.pm b/apps/hyperv/2012/local/mode/nodesnapshot.pm index 64d09c053..4aab7d77c 100644 --- a/apps/hyperv/2012/local/mode/nodesnapshot.pm +++ b/apps/hyperv/2012/local/mode/nodesnapshot.pm @@ -71,6 +71,7 @@ sub new { "no-ps" => { name => 'no_ps' }, "ps-exec-only" => { name => 'ps_exec_only' }, "filter-vm:s" => { name => 'filter_vm' }, + "filter-note:s" => { name => 'filter_note' }, "filter-status:s" => { name => 'filter_status', default => 'running' }, }); return $self; @@ -94,14 +95,14 @@ sub manage_selection { $self->{output}->exit(); } - #[name= ISC1-SV04404 ][state= Running ] + #[name= ISC1-SV04404 ][state= Running ][note= ] #[checkpointCreationTime= 1475502921.28734 ] #[checkpointCreationTime= 1475503073.81975 ] $self->{vm} = {}; my $id = 1; - while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) { - my ($name, $status, $content) = ($1, $2, $3); + while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[note=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) { + my ($name, $status, $note, $content) = ($1, $2, $3, $4); my $chkpt = -1; while ($content =~ /\[checkpointCreationTime=s*(.*?)\s*\]/msig) { $chkpt = $1 if ($chkpt == -1 || $chkpt > $1); @@ -112,6 +113,11 @@ sub manage_selection { $name !~ /$self->{option_results}->{filter_vm}/i) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); next; + } + if (defined($self->{option_results}->{filter_note}) && $self->{option_results}->{filter_note} ne '' && + $note !~ /$self->{option_results}->{filter_note}/i) { + $self->{output}->output_add(long_msg => "skipping '" . $note . "': no matching filter.", debug => 1); + next; } if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' && $status !~ /$self->{option_results}->{filter_status}/i) { @@ -167,6 +173,10 @@ Filter virtual machine status (can be a regexp) (Default: 'running'). Filter virtual machines (can be a regexp). +=item B<--filter-note> + +Filter by VM notes (can be a regexp). + =item B<--warning-*> Threshold warning. diff --git a/apps/hyperv/2012/local/mode/nodevmstatus.pm b/apps/hyperv/2012/local/mode/nodevmstatus.pm index 4749f4cfe..15c801354 100644 --- a/apps/hyperv/2012/local/mode/nodevmstatus.pm +++ b/apps/hyperv/2012/local/mode/nodevmstatus.pm @@ -109,6 +109,7 @@ sub new { "no-ps" => { name => 'no_ps' }, "ps-exec-only" => { name => 'ps_exec_only' }, "filter-vm:s" => { name => 'filter_vm' }, + "filter-note:s" => { name => 'filter_note' }, "warning-status:s" => { name => 'warning_status', default => '' }, "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Operating normally/i' }, }); @@ -151,20 +152,25 @@ sub manage_selection { $self->{output}->exit(); } - #[name= XXXX1 ][state= Running ][status= Operating normally ][IsClustered= True ] - #[name= XXXX2 ][state= Running ][status= Operating normally ][IsClustered= False ] - #[name= XXXX3 ][state= Running ][status= Operating normally ][IsClustered= False ] + #[name= XXXX1 ][state= Running ][status= Operating normally ][IsClustered= True ][note= ] + #[name= XXXX2 ][state= Running ][status= Operating normally ][IsClustered= False ][note= ] + #[name= XXXX3 ][state= Running ][status= Operating normally ][IsClustered= False ][note= ] $self->{vm} = {}; my $id = 1; - while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[IsClustered=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) { - my ($name, $state, $status, $is_clustered) = ($1, $2, $3, $4); + while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[IsClustered=\s*(.*?)\s*\]\[note=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) { + my ($name, $state, $status, $is_clustered, $note) = ($1, $2, $3, $4, $5); if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' && $name !~ /$self->{option_results}->{filter_vm}/i) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); next; } + if (defined($self->{option_results}->{filter_note}) && $self->{option_results}->{filter_note} ne '' && + $note !~ /$self->{option_results}->{filter_note}/i) { + $self->{output}->output_add(long_msg => "skipping '" . $note . "': no matching filter.", debug => 1); + next; + } $self->{vm}->{$id} = { display => $name, vm => $name, status => $status, state => $state, is_clustered => $is_clustered }; $id++; @@ -210,6 +216,10 @@ Print powershell output. Filter virtual machines (can be a regexp). +=item B<--filter-note> + +Filter by VM notes (can be a regexp). + =item B<--warning-status> Set warning threshold for status (Default: ''). diff --git a/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm b/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm index fbaf574c5..dfc96d8e0 100644 --- a/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm +++ b/apps/hyperv/2012/local/mode/scvmmintegrationservice.pm @@ -183,7 +183,7 @@ sub manage_selection { $values{hostgroup} =~ s/\\/\//g; my $filtered = 0; - foreach (('name', 'description', 'status', 'hostgroup')) { + foreach (('vm', 'description', 'status', 'hostgroup')) { if (defined($self->{option_results}->{'filter_' . $_}) && $self->{option_results}->{'filter_' . $_} ne '' && $values{$_} !~ /$self->{option_results}->{'filter_' . $_}/i) { $self->{output}->output_add(long_msg => "skipping '" . $values{$_} . "': no matching filter.", debug => 1); diff --git a/apps/hyperv/2012/local/mode/scvmmsnapshot.pm b/apps/hyperv/2012/local/mode/scvmmsnapshot.pm index 16db4947b..44d2e0573 100644 --- a/apps/hyperv/2012/local/mode/scvmmsnapshot.pm +++ b/apps/hyperv/2012/local/mode/scvmmsnapshot.pm @@ -75,6 +75,7 @@ sub new { "no-ps" => { name => 'no_ps' }, "ps-exec-only" => { name => 'ps_exec_only' }, "filter-vm:s" => { name => 'filter_vm' }, + "filter-description:s"=> { name => 'filter_description' }, "filter-hostgroup:s" => { name => 'filter_hostgroup' }, "filter-status:s" => { name => 'filter_status', default => 'running' }, }); @@ -117,38 +118,34 @@ sub manage_selection { $self->{output}->exit(); } - #[name= test-server ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server ] + #[name= test-server ][description= ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server ] #[checkpointAddedTime= 1475502741.957 ] #[checkpointAddedTime= 1475502963.21 ] $self->{vm} = {}; my $id = 1; - while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[cloud=\s*(.*?)\s*\]\[hostgrouppath=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) { - my ($name, $status, $cloud, $hg, $content) = ($1, $2, $3, $4, $5); + while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[description=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[cloud=\s*(.*?)\s*\]\[hostgrouppath=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) { + my %values = (vm => $1, description => $2, status => $3, cloud => $4, hostgroup => $5); + my $content = $6; + my $chkpt = -1; while ($content =~ /\[checkpointAddedTime=s*(.*?)\s*\]/msig) { $chkpt = $1 if ($chkpt == -1 || $chkpt > $1); } next if ($chkpt == -1); - $hg =~ s/\\/\//g; - if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' && - $name !~ /$self->{option_results}->{filter_vm}/i) { - $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); - next; - } - if (defined($self->{option_results}->{filter_hostgroup}) && $self->{option_results}->{filter_hostgroup} ne '' && - $hg !~ /$self->{option_results}->{filter_hostgroup}/i) { - $self->{output}->output_add(long_msg => "skipping '" . $hg . "': no matching filter.", debug => 1); - next; - } - if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' && - $status !~ /$self->{option_results}->{filter_status}/i) { - $self->{output}->output_add(long_msg => "skipping '" . $status . "': no matching filter.", debug => 1); - next; + my $filtered = 0; + $values{hostgroup} =~ s/\\/\//g; + foreach (('vm', 'description', 'status', 'hostgroup')) { + if (defined($self->{option_results}->{'filter_' . $_}) && $self->{option_results}->{'filter_' . $_} ne '' && + $values{$_} !~ /$self->{option_results}->{'filter_' . $_}/i) { + $self->{output}->output_add(long_msg => "skipping '" . $values{$_} . "': no matching filter.", debug => 1); + $filtered = 1; + last; + } } - $self->{vm}->{$id} = { display => $name, snapshot => time() - $chkpt }; + $self->{vm}->{$id} = { display => $values{vm}, snapshot => time() - $chkpt } if ($filtered == 0); $id++; } } @@ -212,6 +209,10 @@ Filter virtual machine status (can be a regexp) (Default: 'running'). Filter virtual machines (can be a regexp). +=item B<--filter-description> + +Filter by description (can be a regexp). + =item B<--filter-hostgroup> Filter hostgroup (can be a regexp). diff --git a/apps/hyperv/2012/local/mode/scvmmvmstatus.pm b/apps/hyperv/2012/local/mode/scvmmvmstatus.pm index bcfa068ec..326b7bd0e 100644 --- a/apps/hyperv/2012/local/mode/scvmmvmstatus.pm +++ b/apps/hyperv/2012/local/mode/scvmmvmstatus.pm @@ -112,6 +112,7 @@ sub new { "no-ps" => { name => 'no_ps' }, "ps-exec-only" => { name => 'ps_exec_only' }, "filter-vm:s" => { name => 'filter_vm' }, + "filter-description:s"=> { name => 'filter_description' }, "filter-hostgroup:s" => { name => 'filter_hostgroup' }, "warning-status:s" => { name => 'warning_status', default => '' }, "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Running|Stopped/i' }, @@ -168,27 +169,26 @@ sub manage_selection { $self->{output}->exit(); } - #[name= test-server ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server ] - #[name= test-server2 ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server2 ] + #[name= test-server ][description= ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server ] + #[name= test-server2 ][description= ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server2 ] $self->{vm} = {}; my $id = 1; - while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[cloud=\s*(.*?)\s*\]\[hostgrouppath=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) { - my ($name, $status, $cloud, $hg) = ($1, $2, $3, $4); - - $hg =~ s/\\/\//g; - if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' && - $name !~ /$self->{option_results}->{filter_vm}/i) { - $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); - next; - } - if (defined($self->{option_results}->{filter_hostgroup}) && $self->{option_results}->{filter_hostgroup} ne '' && - $hg !~ /$self->{option_results}->{filter_hostgroup}/i) { - $self->{output}->output_add(long_msg => "skipping '" . $hg . "': no matching filter.", debug => 1); - next; + while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[description=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[cloud=\s*(.*?)\s*\]\[hostgrouppath=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) { + my %values = (vm => $1, description => $2, status => $3, cloud => $4, hostgroup => $5); + + my $filtered = 0; + $values{hostgroup} =~ s/\\/\//g; + foreach (('vm', 'description', 'hostgroup')) { + if (defined($self->{option_results}->{'filter_' . $_}) && $self->{option_results}->{'filter_' . $_} ne '' && + $values{$_} !~ /$self->{option_results}->{'filter_' . $_}/i) { + $self->{output}->output_add(long_msg => "skipping '" . $values{$_} . "': no matching filter.", debug => 1); + $filtered = 1; + last; + } } - $self->{vm}->{$id} = { display => $name, vm => $name, status => $status, hostgroup => $hg }; + $self->{vm}->{$id} = { display => $values{vm}, vm => $values{vm}, status => $values{status}, hostgroup => $values{hostgroup} }; $id++; } } @@ -252,6 +252,10 @@ Filter virtual machines (can be a regexp). Filter hostgroup (can be a regexp). +=item B<--filter-description> + +Filter by description (can be a regexp). + =item B<--warning-status> Set warning threshold for status (Default: ''). diff --git a/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm b/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm index e6fcaf461..e165bef1c 100644 --- a/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm +++ b/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm @@ -40,7 +40,9 @@ Try { $vms = Get-VM Foreach ($vm in $vms) { - Write-Host "[name=" $vm.VMName "][state=" $vm.State "][IntegrationServicesState=" $vm.IntegrationServicesState "][IntegrationServicesVersion=" $vm.IntegrationServicesVersion "]" + $note = $vm.Notes -replace "\r","" + $note = $note -replace "\n"," - " + Write-Host "[name=" $vm.VMName "][state=" $vm.State "][IntegrationServicesState=" $vm.IntegrationServicesState "][IntegrationServicesVersion=" $vm.IntegrationServicesVersion "][note=" $note "]" Foreach ($service in $VM.VMIntegrationService) { Write-Host "[service=" $service.Name "][enabled=" $service.Enabled "][primaryOperationalStatus=" $service.PrimaryOperationalStatus "][secondaryOperationalStatus=" $service.SecondaryOperationalStatus "]" } diff --git a/centreon/common/powershell/hyperv/2012/nodesnapshot.pm b/centreon/common/powershell/hyperv/2012/nodesnapshot.pm index 805d4a77a..5d1f55157 100644 --- a/centreon/common/powershell/hyperv/2012/nodesnapshot.pm +++ b/centreon/common/powershell/hyperv/2012/nodesnapshot.pm @@ -44,10 +44,12 @@ Try { Foreach ($vm in $vms) { $i=0 + $note = $vm.Notes -replace "\r","" + $note = $note -replace "\n"," - " Foreach ($snap in $snapshots) { if ($snap.VMName -eq $vm.VMName) { if ($i -eq 0) { - Write-Host "[name=" $vm.VMName "][state=" $vm.State "]" + Write-Host "[name=" $vm.VMName "][state=" $vm.State "][note=" $note "]" } Write-Host "[checkpointCreationTime=" (get-date -date $snap.CreationTime -UFormat ' . "'%s'" . ') "]" $i=1 diff --git a/centreon/common/powershell/hyperv/2012/nodevmstatus.pm b/centreon/common/powershell/hyperv/2012/nodevmstatus.pm index 7c0c39abc..23ac2ced5 100644 --- a/centreon/common/powershell/hyperv/2012/nodevmstatus.pm +++ b/centreon/common/powershell/hyperv/2012/nodevmstatus.pm @@ -40,7 +40,9 @@ Try { $vms = Get-VM Foreach ($vm in $vms) { - Write-Host "[name=" $vm.VMName "][state=" $vm.State "][status=" $vm.Status "][IsClustered=" $vm.IsClustered "]" + $note = $vm.Notes -replace "\r","" + $note = $note -replace "\n"," - " + Write-Host "[name=" $vm.VMName "][state=" $vm.State "][status=" $vm.Status "][IsClustered=" $vm.IsClustered "][note=" $note "]" } } Catch { Write-Host $Error[0].Exception diff --git a/centreon/common/powershell/hyperv/2012/scvmmsnapshot.pm b/centreon/common/powershell/hyperv/2012/scvmmsnapshot.pm index be9017857..9e7918f15 100644 --- a/centreon/common/powershell/hyperv/2012/scvmmsnapshot.pm +++ b/centreon/common/powershell/hyperv/2012/scvmmsnapshot.pm @@ -49,9 +49,11 @@ Try { Foreach ($vm in $vms) { $i = 0 $checkpoints = Get-SCVMCheckpoint -VMMServer $connection -Vm $vm + $desc = $vm.description -replace "\r","" + $desc = $desc -replace "\n"," - " foreach ($checkpoint in $checkpoints) { if ($i -eq 0) { - Write-Host "[name=" $vm.Name "][status=" $vm.Status "][cloud=" $vm.Cloud "][hostgrouppath=" $vm.HostGroupPath "]" + Write-Host "[name=" $vm.Name "][description=" $desc "][status=" $vm.Status "][cloud=" $vm.Cloud "][hostgrouppath=" $vm.HostGroupPath "]" } Write-Host "[checkpointAddedTime=" (get-date -date $checkpoint.AddedTime -UFormat ' . "'%s'" . ') "]" $i = 1 diff --git a/centreon/common/powershell/hyperv/2012/scvmmvmstatus.pm b/centreon/common/powershell/hyperv/2012/scvmmvmstatus.pm index be9ec4c6a..fb1cb74ff 100644 --- a/centreon/common/powershell/hyperv/2012/scvmmvmstatus.pm +++ b/centreon/common/powershell/hyperv/2012/scvmmvmstatus.pm @@ -47,7 +47,9 @@ Try { $vms = Get-SCVirtualMachine -VMMServer $connection Foreach ($vm in $vms) { - Write-Host "[name=" $vm.Name "][status=" $vm.Status "][cloud=" $vm.Cloud "][hostgrouppath=" $vm.HostGroupPath "]" + $desc = $vm.description -replace "\r","" + $desc = $desc -replace "\n"," - " + Write-Host "[name=" $vm.Name "][description=" $desc "][status=" $vm.Status "][cloud=" $vm.Cloud "][hostgrouppath=" $vm.HostGroupPath "]" } } Catch { Write-Host $Error[0].Exception