Conmux consumes Bladecenter event logs with repeated login attempts.
That fills up Blade event logs which leads to useful log information
being lost.


Signed-off-by: Roger Mach <bigmach@us.ibm.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2430 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/conmux/drivers/blade b/conmux/drivers/blade
index 76a839a..69510c4 100755
--- a/conmux/drivers/blade
+++ b/conmux/drivers/blade
@@ -166,12 +166,29 @@
 
 # CONSOLE: open a console channel
 if {[string compare $cmd "console"] == 0} {
+	set ts_start 1
+	set ts_cur 1
+	set retry 0;
 	note "connecting to console ..."
-	send "console -o\r"
-	interact {
-		-o -ex $prompt {
-			return
+
+	# Unless console session lasts for more than two seconds, retry every
+	# thirty seconds for up to a day.  This prevents repeated login events
+	# which fill logs and cause loss of useful event log information.
+	while {($ts_cur - $ts_start < 2) && ($retry < 2880)} {
+		# 30 second delay between attempts, except for the first one
+		if {$ts_start != 1} {
+			note "connection failed, retrying after 30 second delay"
+			after 30000
 		}
+		set ts_start [timestamp];
+		send "console -o\r"
+		interact {
+			-o -ex $prompt {
+				return
+			}
+		}
+		set ts_cur [timestamp];
+		incr retry
 	}
 	winge "console lost"
 	exit 0