From bc2b571ddf80f3baff503b435b34fe653043f37a Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" Date: Wed, 31 Aug 2005 23:58:03 +0000 Subject: [PATCH] Just for Mike ... add a console log icon and add option to show last N lines of console log. --- utils/spewconlog.in | 29 +++++++++++++++++++++++++---- www/showconlog.php3 | 15 ++++++++++++++- www/showstuff.php3 | 9 ++++++++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/utils/spewconlog.in b/utils/spewconlog.in index ce2e7b8ad..303815b3f 100644 --- a/utils/spewconlog.in +++ b/utils/spewconlog.in @@ -12,12 +12,14 @@ use Getopt::Std; # sub usage() { - print(STDOUT "Usage: spewconlog node\n"); + print(STDOUT "Usage: spewconlog [-l linecount] node\n"); exit(-1); } -my $optlist = ""; -my $logdir = "/var/log/tiplogs"; +my $optlist = "l:"; +my $linecount = 0; +my $logdir = "/var/log/tiplogs"; my $logname; +my $cmd; # # Configure variables @@ -74,6 +76,18 @@ my $logfile; if (! getopts($optlist, \%options)) { usage(); } +if (defined($options{"l"})) { + $linecount = $options{"l"}; + + # Untaint of course. + if ($linecount =~ /^([\d]+)$/) { + $linecount = $1; + } + else { + die("*** $0:\n". + " Bad data in linecount: $linecount\n"); + } +} usage() if (@ARGV != 1); my $node = $ARGV[0]; @@ -117,6 +131,13 @@ else { $logname = "$logdir/${node}.log" } +if ($linecount) { + $cmd = "tail -". $linecount +} +else { + $cmd = "cat"; +} + # # Run an ssh command in a child process, protected by an alarm to # ensure that the ssh is not hung up forever if the machine is in @@ -144,6 +165,6 @@ if ($syspid) { # Now we want to ssh over and cat the file. # $UID = 0; -system("sshtb -host $tipserver cat $logname"); +system("sshtb -host $tipserver $cmd $logname"); $UID = $SAVEUID; exit(($? == 0 ? 0 : 1)); diff --git a/www/showconlog.php3 b/www/showconlog.php3 index 1f550b5ac..6d2915d15 100644 --- a/www/showconlog.php3 +++ b/www/showconlog.php3 @@ -40,6 +40,19 @@ else { PAGEARGERROR("Must specify a node ID!"); } +# +# Look for linecount argument +# +if (isset($linecount) && $linecount != "") { + if (! TBvalid_integer($linecount)) { + PAGEARGERROR("Illegal characters in linecount!"); + } + $optarg = "-l $linecount"; +} +else { + $optarg = ""; +} + # # A cleanup function to keep the child from becoming a zombie. # @@ -56,7 +69,7 @@ function SPEWCLEANUP() } register_shutdown_function("SPEWCLEANUP"); -$fp = popen("$TBSUEXEC_PATH $uid nobody webspewconlog $node_id", "r"); +$fp = popen("$TBSUEXEC_PATH $uid nobody webspewconlog $optarg $node_id", "r"); if (! $fp) { USERERROR("Spew console log failed!", 1); } diff --git a/www/showstuff.php3 b/www/showstuff.php3 index 7cd1c0240..986c3949d 100644 --- a/www/showstuff.php3 +++ b/www/showstuff.php3 @@ -1203,7 +1203,8 @@ function SHOWNODES($pid, $eid, $sortby) { Last Log Message\n"; } echo " SSH - Console"; + Console . + Log"; # Only put out a RDP column header if there are any Windows nodes. $windows_query_result = DBQueryFatal("SELECT r.pid,r.eid,n.node_id,oi.OS ". @@ -1294,6 +1295,12 @@ function SHOWNODES($pid, $eid, $sortby) { c \n"; + + echo " + + console log + \n"; } if ($iswindowsnode) { -- GitLab