Add number of distinct element, and top10 for each catagory

master
Daniel Berteaud 4 years ago
parent 732b72bdf1
commit 2f250fbd56
  1. 25
      samba/autdit.pl

@ -82,4 +82,29 @@ while (<STDIN>){
} }
} }
$result->{distinct} = {
users => scalar keys %{$result->{users}},
machines => scalar keys %{$result->{machines}},
ip => scalar keys %{$result->{ip}},
files => scalar keys %{$result->{files}},
};
$result->{top10} = {
users => get_top($result->{users}),
machines => get_top($result->{machines}),
ip => get_top($result->{ip}),
files => get_top($result->{files}),
operations => get_top($result->{operations})
};
print to_json($result, { pretty => 1}); print to_json($result, { pretty => 1});
sub get_top {
my $hash = shift;
my $res = [];
foreach my $item (sort { $hash->{$b} <=> $hash->{$a} } keys %{$hash}){
push @{$res}, $item . " ($hash->{$item})";
last if (scalar(@{$res}) ge 010);
}
return $res;
}

Loading…
Cancel
Save