From 2f250fbd5608a6839c02e39cb3b13c06f3821682 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 14 Jan 2021 08:15:04 +0100 Subject: [PATCH] Add number of distinct element, and top10 for each catagory --- samba/autdit.pl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/samba/autdit.pl b/samba/autdit.pl index c09ed54..afc631e 100644 --- a/samba/autdit.pl +++ b/samba/autdit.pl @@ -82,4 +82,29 @@ while (){ } } +$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}); + +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; +}