[Fai-commit] r4638 - people/eartoast/addons/class-reference

glaweh-guest at alioth.debian.org glaweh-guest at alioth.debian.org
Fri Oct 19 14:18:52 UTC 2007


Author: glaweh-guest
Date: 2007-10-19 14:18:52 +0000 (Fri, 19 Oct 2007)
New Revision: 4638

Modified:
   people/eartoast/addons/class-reference/fai-classes-log
Log:
re-introduce the 'full' display mode, changes semantics a bit


Modified: people/eartoast/addons/class-reference/fai-classes-log
===================================================================
--- people/eartoast/addons/class-reference/fai-classes-log	2007-10-18 23:06:38 UTC (rev 4637)
+++ people/eartoast/addons/class-reference/fai-classes-log	2007-10-19 14:18:52 UTC (rev 4638)
@@ -14,7 +14,8 @@
 use File::Basename;
 
 my $log_topdir;
-our ($opt_F,$opt_h);
+my $listingtype;
+our ($opt_h);
 
 # Dirs within the logdirs to be ignored
 my @ignore_dirs = qw'backup ssh .ssh';
@@ -74,10 +75,21 @@
 		$log_topdir);
 }
 
-# print the classes and the places referencing them to stdout (alphanum sorted)
+# print the classes and the places referencing them
 sub dump_class_refs_full {
 	foreach my $class (sort keys %config_classes) {
 		print "class: $class\n";
+		foreach my $file (sort @{$config_classes{$class}}) {
+			print "  $file\n";
+		}
+	}
+}
+
+# print the classes and the hosts in them with the respective last-seen times
+sub dump_class_refs_host_last_seen {
+	my $type = shift;
+	foreach my $class (sort keys %config_classes) {
+		print "class: $class\n";
 		my %last_seen;
 		my @output;
 
@@ -111,23 +123,33 @@
 sub HELP_MESSAGE {
 	my $name = basename($0);
 	print << "EOF";
-Usage: $name [OPTION] ... <fai-log-topdir>
+Usage: $name <listingtype> <fai-log-topdir>
 
-Options:
-    -F print a full listing of all dates on all hosts when a class was found
+listingtypes:
+  last_seen
+    just class and last-seen-date
+  host_last_seen
+    hostname and the date this class was last seen on it
+  full
+    all times a class was defined by any host, together with the hostnames
 EOF
 	exit 1;
 }
 
-getopts('Fh');
-HELP_MESSAGE() unless ($ARGV[0]);
+getopts('h');
 HELP_MESSAGE() if ($opt_h);
+HELP_MESSAGE() if ($#ARGV < 1);
 
-$log_topdir=$ARGV[0];
+$listingtype=$ARGV[0];
+$log_topdir=$ARGV[1];
 scan_log();
 
-if ($opt_F) {
+if ($listingtype eq "full") {
 	dump_class_refs_full();
+} elsif ($listingtype eq "last_seen") {
+	dump_class_refs_last_seen();
+} elsif ($listingtype eq "host_last_seen") {
+	dump_class_refs_host_last_seen();
 } else {
-	dump_class_refs_last_seen();
+	HELP_MESSAGE();
 }




More information about the Fai-commit mailing list