[debian-edu-commits] [Git][debian-edu/upstream/sitesummary][master] 2 commits: Added debian-version-summary script to list Debian version info.
Petter Reinholdtsen (@pere)
gitlab at salsa.debian.org
Sat Sep 9 18:21:36 BST 2023
Petter Reinholdtsen pushed to branch master at Debian Edu / upstream / sitesummary
Commits:
707fffd1 by Petter Reinholdtsen at 2023-09-09T19:08:06+02:00
Added debian-version-summary script to list Debian version info.
- - - - -
54892d8a by Petter Reinholdtsen at 2023-09-09T19:19:47+02:00
Added host listing support (-l) for hostclass-summary and debian_edu-summary.
- - - - -
4 changed files:
- Makefile
- + debian-version-summary
- debian_edu-summary
- hostclass-summary
Changes:
=====================================
Makefile
=====================================
@@ -25,6 +25,7 @@ COLLECTORS = \
SUMMARYSCRIPTS = \
agesinceseen-summary \
+ debian-version-summary \
site-summary \
hardware-model-summary \
hostclass-summary \
=====================================
debian-version-summary
=====================================
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use SiteSummary;
+use Getopt::Std;
+
+my %vers;
+my %hostmap;
+my %opts;
+
+sub usage {
+ my $retval = shift;
+ print <<EOF;
+Usage: $0 [-l]
+ -l list hosts with the given version
+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 $ver (get_debian_ver($hostid)) {
+ $ver = "NoDebianVersion" unless defined $ver;
+ $vers{$ver}++;
+ $hostmap{$ver} = [] unless exists $hostmap{$ver};
+ push @{$hostmap{$ver}}, $hostid ;
+ }
+}
+
+sub print_summary {
+ printf(" %-20s %5s\n", "version", "count");
+ for my $ver (sort keys %vers) {
+ printf(" %-20s %5d\n", $ver, $vers{$ver});
+ if (exists $opts{l}) {
+ for my $hostid (sort @{$hostmap{$ver}}) {
+ my $hostname = get_hostname($hostid);
+ printf " %s %s %s\n", $hostname, $ver, $hostid;
+ }
+ }
+ }
+}
=====================================
debian_edu-summary
=====================================
@@ -3,8 +3,24 @@
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);
@@ -16,17 +32,37 @@ sub handle_host {
my $hostid = shift;
my $profile = get_debian_edu_profile($hostid);
my $version = get_debian_edu_ver($hostid);
- $profiles{$profile}++ if (defined $profile);
- $versions{$version}++ if (defined $version);
+ 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 ( keys %profiles ) {
- printf(" %30s %5s\n", $_ || "n/a", $profiles{$_});
+ 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 ( keys %versions ) {
- printf(" %30s %5s\n", $_ || "n/a", $versions{$_});
+ 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;
+ }
+ }
}
}
=====================================
hostclass-summary
=====================================
@@ -4,8 +4,22 @@ use strict;
use warnings;
use SiteSummary;
+use Getopt::Std;
my %hostclasses;
+my %hostmap;
+my %opts;
+
+sub usage {
+ my $retval = shift;
+ print <<EOF;
+Usage: $0 [-l]
+ -l list hosts with the host class version
+EOF
+ exit $retval;
+}
+
+getopt("l", \%opts) || usage(1);
for_all_hosts(\&handle_host);
@@ -17,6 +31,8 @@ sub handle_host {
for my $hostclass (get_hostclass($hostid)) {
$hostclass = "" unless defined $hostclass;
$hostclasses{$hostclass}++;
+ $hostmap{$hostclass} = [] unless exists $hostmap{$hostclass};
+ push @{$hostmap{$hostclass}}, $hostid ;
}
}
@@ -24,5 +40,11 @@ sub print_summary {
printf(" %-20s %5s\n", "hostclass", "count");
for my $hostclass (sort keys %hostclasses) {
printf(" %-20s %5d\n", $hostclass, $hostclasses{$hostclass});
+ if (exists $opts{l}) {
+ for my $hostid (sort @{$hostmap{$hostclass}}) {
+ my $hostname = get_hostname($hostid);
+ printf " %s %s %s\n", $hostname, $hostclass, $hostid;
+ }
+ }
}
}
View it on GitLab: https://salsa.debian.org/debian-edu/upstream/sitesummary/-/compare/baf877a27a0d122d859f782ffc5811216cd87300...54892d8a0864f8403ca974ad59517e9c41903ce7
--
View it on GitLab: https://salsa.debian.org/debian-edu/upstream/sitesummary/-/compare/baf877a27a0d122d859f782ffc5811216cd87300...54892d8a0864f8403ca974ad59517e9c41903ce7
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20230909/33318440/attachment-0001.htm>
More information about the debian-edu-commits
mailing list