File: debian_edu-summary

package info (click to toggle)
sitesummary 0.1.61
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 580 kB
  • sloc: perl: 1,929; sh: 805; makefile: 86
file content (68 lines) | stat: -rwxr-xr-x 1,762 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

use strict;

use SiteSummary;
use Getopt::Std;

my %profiles;
my %versions;
my %phostmap;
my %vhostmap;
my %opts;

sub usage {
    my $retval = shift;
    print <<EOF;
Usage: $0 [-l]
   -l   list hosts with the debian-edu version
EOF
    exit $retval;
}

getopt("l", \%opts) || usage(1);

for_all_hosts(\&handle_host);

print_summary();

exit 0;

sub handle_host {
    my $hostid = shift;
    my $profile = get_debian_edu_profile($hostid);
    my $version = get_debian_edu_ver($hostid);
    if ($profile) {
        $profiles{$profile}++ if (defined $profile);
        $phostmap{$profile} = [] unless exists $phostmap{$profile};
        push @{$phostmap{$profile}}, $hostid ;
    }
    if ($version) {
        $versions{$version}++ if (defined $version);
        $vhostmap{$version} = [] unless exists $vhostmap{$version};
        push @{$vhostmap{$version}}, $hostid ;
    }
}

sub print_summary {
    printf("  %-30s %5s\n", "debian-edu-profile", "count");
    foreach my $profile ( keys %profiles ) {
        printf(" %30s %5s\n", $profile || "n/a", $profiles{$profile});
        if (exists $opts{l}) {
            for my $hostid (sort @{$phostmap{$profile}}) {
                my $hostname = get_hostname($hostid);
                printf "    %s %s %s\n", $hostname, $profile, $hostid;
            }
        }
    }
    printf("  %-30s %5s\n", "debian-edu-version", "count");
    foreach my $version ( keys %versions ) {
        printf(" %30s %5s\n", $version || "n/a", $versions{$version});
        if (exists $opts{l}) {
            for my $hostid (sort @{$vhostmap{$version}}) {
                my $hostname = get_hostname($hostid);
                printf "    %s %s %s\n", $hostname, $version, $hostid;
            }
        }
    }
}