aboutsummaryrefslogtreecommitdiffstats
path: root/hostclass-summary
diff options
context:
space:
mode:
Diffstat (limited to 'hostclass-summary')
-rwxr-xr-xhostclass-summary28
1 files changed, 28 insertions, 0 deletions
diff --git a/hostclass-summary b/hostclass-summary
new file mode 100755
index 0000000..c62615c
--- /dev/null
+++ b/hostclass-summary
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use SiteSummary;
+
+my %hostclasses;
+
+for_all_hosts(\&handle_host);
+
+print_summary();
+
+sub handle_host {
+ my $hostid = shift;
+ #print "$hostid\n";
+ for my $hostclass (get_hostclass($hostid)) {
+ $hostclass = "" unless defined $hostclass;
+ $hostclasses{$hostclass}++;
+ }
+}
+
+sub print_summary {
+ printf(" %-20s %5s\n", "hostclass", "count");
+ for my $hostclass (sort keys %hostclasses) {
+ printf(" %-20s %5d\n", $hostclass, $hostclasses{$hostclass});
+ }
+}