mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-22 21:24:53 +02:00
fix disco output format (#3574)
Co-authored-by: Cloud User <centos@ip-10-25-4-175.eu-west-1.compute.internal>
This commit is contained in:
parent
ba119ccb3b
commit
4d62a19070
@ -45,7 +45,7 @@ sub check_options {
|
|||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $disco_data = {};
|
my @disco_data;
|
||||||
my $disco_stats;
|
my $disco_stats;
|
||||||
|
|
||||||
$disco_stats->{start_time} = time();
|
$disco_stats->{start_time} = time();
|
||||||
@ -75,16 +75,16 @@ sub manage_selection {
|
|||||||
query_form_post => $disco_raw_form_post
|
query_form_post => $disco_raw_form_post
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach my $device (@{$disco_api_results->{data}}) {
|
foreach my $host (@{$disco_api_results->{data}}) {
|
||||||
$disco_data->{$device->{id}} = {
|
my %device;
|
||||||
id => $device->{id},
|
$device{id} = $host->{id};
|
||||||
hostname => $device->{hostname},
|
$device{hostname} = $host->{hostname};
|
||||||
loginIp => $device->{loginIp},
|
$device{loginIp} = $host->{loginIp};
|
||||||
siteName => $device->{siteName},
|
$device{siteName} = $host->{siteName};
|
||||||
vendor => $device->{vendor},
|
$device{vendor} = $host->{vendor};
|
||||||
family => $device->{family},
|
$device{family} = $host->{family};
|
||||||
snmp_community => undef
|
$device{snmp_community} = undef;
|
||||||
};
|
push @disco_data, \%device;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $snmp_req_data_raw = {
|
my $snmp_req_data_raw = {
|
||||||
@ -108,17 +108,18 @@ sub manage_selection {
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach my $snmp_device (@{$snmp_community_api_results->{data}}) {
|
foreach my $snmp_device (@{$snmp_community_api_results->{data}}) {
|
||||||
foreach my $id (keys %$disco_data) {
|
for my $index (0 .. $#disco_data){
|
||||||
if ($snmp_device->{hostname} eq $disco_data->{$id}->{hostname}){
|
next if (!defined($disco_data[$index]->{hostname}));
|
||||||
$disco_data->{$id}->{snmp_community} = $snmp_device->{name}->{data};
|
if ($snmp_device->{hostname} eq $disco_data[$index]->{hostname}){
|
||||||
|
$disco_data[$index]->{snmp_community} = $snmp_device->{name}->{data};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$disco_stats->{end_time} = time();
|
$disco_stats->{end_time} = time();
|
||||||
$disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time};
|
$disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time};
|
||||||
$disco_stats->{discovered_items} = $disco_data;
|
$disco_stats->{discovered_items} = @disco_data;
|
||||||
$disco_stats->{results} = $disco_data;
|
$disco_stats->{results} = \@disco_data;
|
||||||
|
|
||||||
return $disco_stats;
|
return $disco_stats;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user