mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-09-26 03:08:39 +02:00
fix(apps::microsoft::hyperv::2012::local): fix discovery stats in scvmm-discovery (#5707)
Refs: CTOR-1852
This commit is contained in:
parent
bd768b768a
commit
6773f1c644
@ -146,6 +146,10 @@ sub powershell_exec {
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $disco_data;
|
||||
my $disco_stats;
|
||||
$disco_stats->{start_time} = time();
|
||||
|
||||
my $decoded = $self->powershell_exec();
|
||||
|
||||
my $hosts = {};
|
||||
@ -154,8 +158,6 @@ sub run {
|
||||
$hosts->{ $entry->{id} } = { cluster_name => $entry->{clusterName}, name => $entry->{name} };
|
||||
}
|
||||
|
||||
my $disco_data;
|
||||
my $disco_stats;
|
||||
foreach my $entry (@$decoded) {
|
||||
my $item = {};
|
||||
|
||||
@ -215,63 +217,63 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Resources discovery.
|
||||
SCVMM resources discovery.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--prettify>
|
||||
|
||||
Prettify JSON output.
|
||||
Prettify the JSON output.
|
||||
|
||||
=item B<--resource-type>
|
||||
|
||||
Choose the type of resources
|
||||
to discover (can be: 'host', 'vm') (mandatory).
|
||||
Choose the type of resources to discover (can be: C<host>, C<vm>) (required).
|
||||
|
||||
=item B<--scvmm-hostname>
|
||||
|
||||
SCVMM hostname.
|
||||
Set the SCVMM hostname.
|
||||
|
||||
=item B<--scvmm-username>
|
||||
|
||||
SCVMM username (required).
|
||||
Set the SCVMM username (required).
|
||||
|
||||
=item B<--scvmm-password>
|
||||
|
||||
SCVMM password (required).
|
||||
Set the SCVMM password (required).
|
||||
|
||||
=item B<--scvmm-port>
|
||||
|
||||
SCVMM port (default: 8100).
|
||||
Set the SCVMM port (default: 8100).
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout time for command execution (default: 90 sec)
|
||||
Set timeout time for command execution (default: 90 sec).
|
||||
|
||||
=item B<--no-ps>
|
||||
|
||||
Don't encode powershell. To be used with --command and 'type' command.
|
||||
Don't encode powershell. To be used with C<--command> and 'type' command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (default: 'powershell.exe').
|
||||
Can be changed if you have output in a file. To be used with --no-ps option!!!
|
||||
Set the command to get information (default: 'powershell.exe').
|
||||
It can be used if you have the information in a file.
|
||||
This option should be used with C<--no-ps> option!!!
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (default: none).
|
||||
Set the command path (default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (default: '-InputFormat none -NoLogo -EncodedCommand').
|
||||
Set the command options (default: C<-InputFormat none -NoLogo -EncodedCommand>).
|
||||
|
||||
=item B<--ps-display>
|
||||
|
||||
Display powershell script.
|
||||
Display the powershell script.
|
||||
|
||||
=item B<--ps-exec-only>
|
||||
|
||||
Print powershell output.
|
||||
Print the powershell output.
|
||||
|
||||
=back
|
||||
|
||||
|
25
tests/apps/microsoft/hyperv/2012/local/scvmmdiscovery.json
Normal file
25
tests/apps/microsoft/hyperv/2012/local/scvmmdiscovery.json
Normal file
@ -0,0 +1,25 @@
|
||||
[
|
||||
{
|
||||
"description":"description",
|
||||
"type":"vm",
|
||||
"computerName":"computer1.centreon.local",
|
||||
"vmId":"VM-123",
|
||||
"ipv4Addresses":"10.0.0.1",
|
||||
"name":"Computer1",
|
||||
"hostGroupPath":"Hostgroup1",
|
||||
"tag":"(aucun)",
|
||||
"vmHostId":"DEF-456",
|
||||
"status":0,
|
||||
"operatingSystem":"Windows Server 2022 Standard",
|
||||
"enabled":true
|
||||
},
|
||||
{
|
||||
"description":"description",
|
||||
"type":"host",
|
||||
"clusterName":"cluster.centreon.local",
|
||||
"id":"CL-456",
|
||||
"name": "host.centreon.local",
|
||||
"fqdn":"host.centreon.local",
|
||||
"operatingSystem":"Windows Server 2022 Standard"
|
||||
}
|
||||
]
|
35
tests/apps/microsoft/hyperv/2012/local/scvmmdiscovery.robot
Normal file
35
tests/apps/microsoft/hyperv/2012/local/scvmmdiscovery.robot
Normal file
@ -0,0 +1,35 @@
|
||||
*** Settings ***
|
||||
Documentation Application Microsoft HyperV 2022
|
||||
|
||||
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||
|
||||
Test Timeout 120s
|
||||
|
||||
|
||||
*** Variables ***
|
||||
${CMD} ${CENTREON_PLUGINS}
|
||||
... --plugin=apps::microsoft::hyperv::2012::local::plugin
|
||||
... --mode=scvmm-discovery
|
||||
... --scvmm-username='username'
|
||||
... --scvmm-password='password'
|
||||
... --command=cat
|
||||
... --command-path=/usr/bin
|
||||
... --no-ps
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
HyperV 2022-2 ${tc}
|
||||
[Documentation] Apps Microsoft HyperV 2022
|
||||
[Tags] applications microsoft hyperv virtualization
|
||||
${command} Catenate
|
||||
... ${CMD}
|
||||
... --command-options=${CURDIR}/scvmmdiscovery.json
|
||||
... --resource-type='${resource_type}'
|
||||
... | jq -c --sort-keys
|
||||
|
||||
Ctn Run Command And Check Result As Regexp ${command} ${expected_result}
|
||||
|
||||
Examples: tc resource_type expected_result --
|
||||
... 1 ${EMPTY} \\\\{"discovered_items":1,"duration":0,"end_time":\\\\d+,"results":\\\\[\\\\{"cluster_name":null,"computer_name":"computer1.centreon.local","description":"description","enabled":"yes","hostgroup_path":"Hostgroup1","id":"VM-123","ipv4_address":"10.0.0.1","ipv4_addresses":\\\\["10.0.0.1"\\\\],"name":"Computer1","operating_system":"Windows Server 2022 Standard","status":"Running","tag":"\\\\(aucun\\\\)","type":"vm","vmhost_name":null\\\\}\\\\],"start_time":\\\\d+\\\\}
|
||||
... 2 vm \\\\{"discovered_items":1,"duration":0,"end_time":\\\\d+,"results":\\\\[\\\\{"cluster_name":null,"computer_name":"computer1.centreon.local","description":"description","enabled":"yes","hostgroup_path":"Hostgroup1","id":"VM-123","ipv4_address":"10.0.0.1","ipv4_addresses":\\\\["10.0.0.1"\\\\],"name":"Computer1","operating_system":"Windows Server 2022 Standard","status":"Running","tag":"\\\\(aucun\\\\)","type":"vm","vmhost_name":null\\\\}\\\\],"start_time":\\\\d+\\\\}
|
||||
... 3 host \\\\{"discovered_items":1,"duration":0,"end_time":\\\\d+,"results":\\\\[\\\\{"cluster_name":"cluster.centreon.local","description":"description","fqdn":null,"id":"CL-456","name":"host.centreon.local","operating_system":"Windows Server 2022 Standard","type":"host"\\\\}\\\\],"start_time":\\\\d+\\\\}
|
@ -276,6 +276,7 @@ snmp
|
||||
snmpd.conf
|
||||
space-usage-prct
|
||||
--sql-errors-exit
|
||||
SCVMM
|
||||
SRX
|
||||
SSDCapacity
|
||||
SSG
|
||||
|
Loading…
x
Reference in New Issue
Block a user