Commit 9ff9ea47 authored by Mac Newbold's avatar Mac Newbold

Add idlecheck to the web pages. To have suexec let us run idlecheck, I had to...

Add idlecheck to the web pages. To have suexec let us run idlecheck, I had to make a wrapper to go in the libexec dir, and add it to the makefile and configure. Added a warning to idlecheck about its output format being the input format for showexp_list.php3, so people change both if they change one.
parent a7cf2831
......@@ -834,6 +834,7 @@ fi
#
# Defaults for for above variables.
#
......@@ -1121,7 +1122,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1124: checking for a BSD compatible install" >&5
echo "configure:1126: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -1226,7 +1227,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tbsetup/webmkproj tbsetup/mkproj tbsetup/libtestbed.pm \
tbsetup/portstats tbsetup/vnode_setup tbsetup/staticroutes \
tbsetup/console_setup.proxy tbsetup/exports_setup.proxy \
tbsetup/checkports \
tbsetup/checkports tbsetup/webidlecheck \
tip/GNUmakefile \
tmcd/GNUmakefile tmcd/freebsd/GNUmakefile tmcd/linux/GNUmakefile \
tmcd/ron/GNUmakefile \
......
......@@ -299,7 +299,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
tbsetup/webmkproj tbsetup/mkproj tbsetup/libtestbed.pm \
tbsetup/portstats tbsetup/vnode_setup tbsetup/staticroutes \
tbsetup/console_setup.proxy tbsetup/exports_setup.proxy \
tbsetup/checkports \
tbsetup/checkports tbsetup/webidlecheck \
tip/GNUmakefile \
tmcd/GNUmakefile tmcd/freebsd/GNUmakefile tmcd/linux/GNUmakefile \
tmcd/ron/GNUmakefile \
......
......@@ -46,13 +46,13 @@ while ($#ARGV >= 0) {
$_ = shift;
$_ =~ /^(.)(.)/;
if ($1 ne '-') { next; }
if ($2 ne 'h' && $2 ne 't' && $2 ne 'p' &&
$2 ne 's' && $2 ne 'u' && $2 ne 'd') { next; }
if ($2 ne 'h' && $2 ne 't' && $2 ne 'p' && $2 ne 'f' &&
$2 ne 'u' && $2 ne 's' && $2 ne 'd') { next; }
my $opt="\L$2";
my $val = shift if ($#ARGV >= 0 && ($ARGV[0] =~ /^[^-]/));
if (!defined($val)) { $val=1; }
# Let -d be used multiple times
if ($2 eq 'd') { $d++; } else {
if ($opt eq 'd') { $d++; } else {
$$opt=$val;
}
if ($d>1) { print "$opt = $$opt\n"; }
......@@ -170,8 +170,11 @@ while(@r=$result->fetchrow()) {
$idle=!defined($active{"$pid/$eid"});
$stale=!defined($fresh{"$pid/$eid"});
print "Checking for $pid/$eid in active list\n" if $d;
# Now output the results
# IMPORTANT: If you make changes to output format, be sure to update
# testbed/www/showexp_list.php3 as well, since it reads this output
my $str= "$pid/$eid";
$str = $str . " " x (30-length($str))."\t";
$str = $str . " " x (36-length($str))." ";
$str .= ($idle? "inactive\t" : "\t\t" );
$str .= ($stale?"stale\t" : "\t" );
$str .= (!$swap? "unswappable\n" : "\n" );
......
......@@ -31,7 +31,8 @@ LIBEXEC_STUFF = rmproj rmacct-ctrl wanlinksolve wanlinkinfo \
assign_wrapper ptopgen webnodeupdate \
webrmgroup webswapexp webnodecontrol \
webmkgroup webmkacct websetgroups webmkproj \
spewlogfile staticroutes routecalc wanassign
spewlogfile staticroutes routecalc wanassign \
webidlecheck
LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_cisco.pm snmpit_lib.pm snmpit_apc.pm power_rpc27.pm \
......
#!/usr/bin/perl -w
use English;
# This gets invoked from the Web interface. Simply a wrapper ...
#
# usage: webidlecheck arguments ...
#
#
# Configure variables
#
my $TB = "@prefix@";
#
# Run the real thing, and never return.
#
exec "$TB/bin/idlecheck", @ARGV;
die("webidlecheck: Could not exec idlecheck: $!");
......@@ -22,15 +22,13 @@ if (! isset($showtype))
$showtype="active";
if (! isset($sortby))
$sortby = "normal";
if (! isset($minidledays))
$minidledays = "2";
echo "<b>Show:
<a href='showexp_list.php3?showtype=active&sortby=$sortby'>active</a>,
<a href='showexp_list.php3?showtype=batch&sortby=$sortby'>batch</a>,";
if ($isadmin)
echo "\n<a href='showexp_list.php3?showtype=idle&sortby=$sortby".
"&minidledays=$minidledays'>idle</a>,";
echo "\n<a href='showexp_list.php3?showtype=idle&sortby=$sortby'".
">idle</a>,";
echo "\n <a href='showexp_list.php3?showtype=all&sortby=$sortby'>all</a>.
</b><br><br>\n";
......@@ -54,7 +52,8 @@ elseif (! strcmp($showtype, "batch")) {
elseif ((!strcmp($showtype, "idle")) && $isadmin ) {
# Do not put active in the clause for same reason as active
$title = "Idle";
$having = "having (lastswap>=$minidledays)";
#$having = "having (lastswap>=1)"; # At least one day since swapin
$having = "having (lastswap>=0)";
$idle = 1;
}
else {
......@@ -102,6 +101,28 @@ if ($isadmin) {
"group by e.pid,e.eid ".
"$having ".
"order by $order");
if ($idle) {
# Run idlecheck and get the info
#print "<pre>Running idlecheck\n";
$x=exec("$TBSUEXEC_PATH $uid flux webidlecheck -s -u",
$l, $rv);
reset($l);
while(list($index,$i) = each ($l)) {
list($ipid,$ieid,$word1, $word2, $word3) = split("[ \t/]+",$i);
#print "$ipid + $ieid + $word1 + $word2 + $word3\n";
$expt = "$ipid/$ieid";
$set = array($word1,$word2,$word3);
while(list($index,$tag) = each($set)) {
if ($tag == "") { break; }
if ($tag == "inactive") { $inactive[$expt]=1; }
elseif ($tag == "stale") { $stale[$expt]=1; }
elseif ($tag == "unswappable") { $unswap[$expt]=1; }
}
}
#print "\nDone idlechecking...\n</pre>";
}
}
else {
if ($clause)
......@@ -135,14 +156,7 @@ if (mysql_num_rows($experiments_result)) {
</center>\n";
if ($idle) {
echo "<center><b>Experiments that have been idle at least $minidledays days</b></center>\n";
echo "<center><h3>This will change soon - Slothd is on the way</h3></center>\n";
echo "<b>\"Days idle\" is defined as:<br>
a) number of days since last login (as reported in last login column)<br>
b) number of days it has been swapped in (if nobody has logged in)<br>
</b><br>
Note that it is not reliable in the case where they're using a special
kernel or logging into the nodes in a way that lastlogins can't detect.<p>\n";
echo "<center><b>Experiments that have been idle at least 1 day</b></center><p>\n";
}
#
......@@ -200,6 +214,7 @@ kernel or logging into the nodes in a way that lastlogins can't detect.<p>\n";
echo "<td width=17% align=center>Last Login</td>\n";
if ($idle)
echo "<td width=4% align=center>Days Idle</td>
<td width=4% align=center>Slothd Info</td>
<td width=4% align=center>Swap Req.</td>\n";
echo " <td width=60%>
......@@ -224,8 +239,8 @@ kernel or logging into the nodes in a way that lastlogins can't detect.<p>\n";
$foo = "&nbsp;";
if ($lastexpnodelogins = TBExpUidLastLogins($pid, $eid)) {
$daysidle=$lastexpnodelogins["daysidle"];
if ($idle && $daysidle<$minidledays)
continue;
#if ($idle && $daysidle < 1)
# continue;
$foo = $lastexpnodelogins["date"] . " " .
"(" . $lastexpnodelogins["uid"] . ")";
} elseif ($state=="active") {
......@@ -236,7 +251,26 @@ kernel or logging into the nodes in a way that lastlogins can't detect.<p>\n";
if ($idle) {
$foo .= "</td><td align=center>$daysidle</td>\n";
if ($swappable) {
$foo .= "</td><td align=left>";
$expt = "$pid/$eid";
$str="";
if ($inactive[$expt]==1) {
if ($stale[$expt]==1 || $unswap[$expt]==1) {
$str .= "possibly inactive";
} else {
$str .= "<b>inactive</b>";
}
}
if ($stale[$expt]==1) { $str .= ", <b>no&nbsp;report</b> "; }
# For now, don't show this tag, it's redundant
#if ($unswap[$expt]==1) { $str .= "unswappable"; }
if ($str=="") { $str="&nbsp;"; }
# sanity check
if ($daysidle==0 && $inactive[$expt]==1) {
$str .= "<b>FAILED SANITY CHECK:</b> has been logged into, but appears inactive. Contact Mac ASAP.";
}
$foo .= "$str</td>\n";
if ($swappable && $inactive[$expt]==1 && $stale[$expt]!=1) {
$foo .= "<td align=center valign=center>
<a href=\"request_swapexp.php3?pid=$pid&eid=$eid\">
<img src=\"redball.gif\"></a>\n";
......
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