/usr/lib/sitesummary/site-summary is in sitesummary 0.1.28+deb9u1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #!/usr/bin/perl
use strict;
use warnings;
use SiteSummary;
use Getopt::Std;
my %sites;
my %sitegroups;
my %hostmap;
my %sitegroupmap;
my %opts;
sub usage {
my $retval = shift;
print <<EOF;
Usage: $0 [-l]
-l list hosts with the given site/sitegroup
EOF
exit $retval;
}
getopt("l", \%opts) || usage(1);
for_all_hosts(\&handle_host);
print_summary();
sub handle_host {
my $hostid = shift;
#print "$hostid\n";
for my $site (get_site($hostid)) {
$site = "SiteMissing" unless defined $site;
$sites{$site}++;
$hostmap{$site} = [] unless exists $hostmap{$site};
my $sitegroup = get_sitegroup($hostid);
if ($sitegroup) {
$sitegroups{$site}{$sitegroup}++;
if (exists $sitegroupmap{$site} && exists $sitegroupmap{$site}{$sitegroup}) {
push @{$sitegroupmap{$site}{$sitegroup}}, $hostid ;
} else {
$sitegroupmap{$site}{$sitegroup} = [$hostid];
}
} else {
push @{$hostmap{$site}}, $hostid ;
}
}
}
sub print_summary {
printf(" %-20s %5s\n", "site", "count");
for my $site (sort keys %sites) {
printf(" %-20s %5d\n", $site, $sites{$site});
if (exists $opts{l}) {
for my $hostid (sort @{$hostmap{$site}}) {
my $hostname = get_hostname($hostid);
my $site = get_site($hostid) || "";
my $sitegroup = get_sitegroup($hostid) || "";
printf " %s %s/%s %s\n", $hostname, $site, $sitegroup, $hostid;
}
}
for my $sitegroup (sort keys %{$sitegroups{$site}}) {
printf(" %-18s %5d\n", $sitegroup, $sitegroups{$site}{$sitegroup});
if (exists $opts{l}) {
for my $hostid (sort @{$sitegroupmap{$site}{$sitegroup}}) {
my $hostname = get_hostname($hostid);
my $site = get_site($hostid) || "";
my $sitegroup = get_sitegroup($hostid) || "";
printf " %s %s/%s %s\n", $hostname, $site, $sitegroup, $hostid;
}
}
}
}
}
|