use Time::Seconds;
my @LIST = map {
[ $_->[0], $_->[1], $_->[2], $_->[3], $_->[4], $_->[5],$_->[6] ]
} sort {
$a->[0] cmp $b->[0] || $b->[4] <=> $a->[4] || $a->[1] cmp $b->[1] || $a->[2] cmp $b->[2] || $a->[3] cmp $b->[3]
} map {
my $group = $_;
map {
my $host = $_;
map {
my $service = $_;
map {
my $state = $_;
my $count = keys %{$ERROR1{$group}->{$host}->{$service}->{$state}};
my $ts1 = (sort (keys %{$ERROR1{$group}->{$host}->{$service}->{$state}}))[0];
my $ts2 = (sort(keys %{$ERROR1{$group}->{$host}->{$service}->{$state}}))[-1];
[ $group, $host, $service, $state, $count, Time::Seconds->new($ts2-$ts1)->pretty() ]
} keys %{$ERROR1{$group}->{$host}->{$_}}
} keys %{$ERROR1{$group}->{$_}}
} keys %{$ERROR1{$_}}
} keys %ERROR1;
for $_ (@LIST){
print join("\t", @{$_}) ."\n";
}
####
Oracle server1 FILESYSTEM ALERT WARNING 85% FULL 8 23 hours, 30 minutes, 4 seconds
Oracle server2 FILESYSTEM ALERT WARNING 85% FULL 5 21 hours, 59 minutes, 59 seconds
Oracle server1 BACKUP ALERT DAILY 1 0 seconds
####
my ($ts1,$ts2) = (sort (keys %{$ERROR1{$group}->{$host}->{$service}->{$state}}))[0,-1];