in reply to Re^3: Need help with complex hash of hashes.
in thread Need help with complex hash of hashes.
So there are 250K CI records. You have CI's for devices with their IP addresses where 'name' is the hostname and a referral CI ( 'u_application_id' )to the application they are children of, and you have CI's that are the application, where 'name' is the application name. You have no control of the order of the records. If the class name 'sys_class_name' is equal to 'cmdb_ci_appl' then it is an application name. If not then it is probably a device and if its 'u_application_id' CI matches and application CI 'u_ci_id' then its 'ip_address' is a member of that application. Now all lines have a CI 'u_ci_id' something like CI10001127. I hope this helps. We are trying to end up with a hash that looks like this.
my %application = ( 'CI10335478' => { name => 'app_name1', member => [ 'MemberIP1', 'MemberIP2', 'MemberIP6', ], }, 'CI10334984' => { name => 'app_name2', member => [ 'MemberIP4', 'MemberIP2', ], },
But are ending up with this.
{ CI10001127 => { name => "Exchange 2003" }, CI10004051 => { name => "Centralized Payment Services Group (CPSG)" +}, CI10047601 => { name => "PGP Desktop" } }
With no members.....
if ( $class eq 'cmdb_ci_appl'){ $arx_data{$u_ci}{'name'} = $name; } else { next if $seen{$app}{$ip}++; push @{$arx_data{$app}{'members'}},$ip; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Need help with complex hash of hashes.
by jcb (Parson) on Jan 29, 2016 at 04:05 UTC |