From: <buc...@us...> - 2009-01-22 16:35:27
|
Revision: 118 http://devmon.svn.sourceforge.net/devmon/?rev=118&view=rev Author: buchanmilne Date: 2009-01-22 16:35:15 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Support BBDATEFORMAT (should provide better dates in Hobbit/BB status messages by default), from W.J.M Nelis Modified Paths: -------------- trunk/devmon.cfg trunk/modules/dm_config.pm trunk/modules/dm_tests.pm Modified: trunk/devmon.cfg =================================================================== --- trunk/devmon.cfg 2009-01-22 16:11:37 UTC (rev 117) +++ trunk/devmon.cfg 2009-01-22 16:35:15 UTC (rev 118) @@ -101,6 +101,11 @@ # [DEFAULT: 1984 or BBPORT environment variable if set] #DISPPORT=1984 +# BBDATEFORMAT: This is the format string that devmon should use in +# date/time strings sent to Hobbit/BB in the status message. +# [DEFAULT: '', or the value of the BBDATEFORMAT enviroment variable if set] +#BBDATEFORMAT= + # MSGSIZE: Sets the max message size in bytes of the datagrams that Devmon # sends to the bb display server [DEFAULT: 8096] MSGSIZE=8096 Modified: trunk/modules/dm_config.pm =================================================================== --- trunk/modules/dm_config.pm 2009-01-22 16:11:37 UTC (rev 117) +++ trunk/modules/dm_config.pm 2009-01-22 16:35:15 UTC (rev 118) @@ -182,6 +182,10 @@ 'regex' => '\d+', 'set' => 0, 'case' => 0 }, + 'bbdateformat' => { 'default' => ($ENV{'BBDATEFORMAT'} ne '') ? $ENV{'BBDATEFORMAT'} : '', + 'regex' => '.+', + 'set' => 0, + 'case' => 1 }, 'msgsize' => { 'default' => 8096, 'regex' => '\d+', 'set' => 0, Modified: trunk/modules/dm_tests.pm =================================================================== --- trunk/modules/dm_tests.pm 2009-01-22 16:11:37 UTC (rev 117) +++ trunk/modules/dm_tests.pm 2009-01-22 16:35:15 UTC (rev 118) @@ -23,6 +23,7 @@ use strict; use dm_config; use Math::BigInt::Calc; + use POSIX qw/ strftime / ; # Our global variable hash use vars qw(%g); @@ -1667,10 +1668,13 @@ do_log("DEBUG TEST: Rendering $test message for $device") if $g{'debug'}; + # Build readable timestamp + my $now= $g{'bbdateformat'} ? strftime($g{'bbdateformat'},localtime) : scalar(localtime) ; + # No message template? if(!defined $msg_template) { - return "status $bb_host.$test clear " . (scalar localtime) . + return "status $bb_host.$test clear $now" . "\n\nCould not locate template for this device.\n" . "Please check devmon logs.\n\n" . "Devmon version $g{'version'} running on $g{'nodename'}\n"; @@ -1679,7 +1683,7 @@ # Do we have a hobbit color, and if so, is it green? elsif(defined $g{'hobbit_color'}{$device} and $g{'hobbit_color'}{$device} ne 'green') { - return "status $bb_host.$test clear " . (scalar localtime) . + return "status $bb_host.$test clear $now" . "\n\nHobbit reports this device is unreachable.\n" . "Suspending this test until reachability is restored\n\n" . "Devmon version $g{'version'} running on $g{'nodename'}\n"; @@ -2140,7 +2144,7 @@ $msg = join "\n", ($errors, $msg) if $errors ne ''; # Now add our header so bb/hobbit can determine the page color - $msg = "status $bb_host.$test $worst_color " . (scalar localtime) . + $msg = "status $bb_host.$test $worst_color $now" . "\n\n$msg"; # Add our oh-so-stylish devmon footer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |