Commit bc2b571d authored by Leigh Stoller's avatar Leigh Stoller

Just for Mike ... add a console log icon and add option to show last N

lines of console log.
parent 1174c5e7
......@@ -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));
......@@ -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);
}
......
......@@ -1203,7 +1203,8 @@ function SHOWNODES($pid, $eid, $sortby) {
<th>Last Log Message</th>\n";
}
echo " <th><a href=\"docwrapper.php3?docname=ssh-mime.html\">SSH</a></th>
<th><a href=\"faq.php3#tiptunnel\">Console</a></th>";
<th><a href=\"faq.php3#tiptunnel\">Console</a></th> .
<th>Log</th>";
# 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) {
<A href='nodetipacl.php3?node_id=$node_id'>
<img src=\"console.gif\" alt=c></A>
</td>\n";
echo " <td align=center>
<A href='showconlog.php3?node_id=$node_id".
"&linecount=200'>
<img src=\"/icons/f.gif\" alt='console log'></A>
</td>\n";
}
if ($iswindowsnode) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment