Commit 4963660a authored by Leigh Stoller's avatar Leigh Stoller

The Robot Lab Monitor Daemon. A very silly script that looks at some

sitevars to determine if the Robot Lab is open or closed. The sitevars:

* 'robotlab/override' - Override other settings and forcibly turn the lab
  "on" or "off" (open or close). When the lab is turned off, new
  experiments cannot swap in and the current experiment is immediately
  swapped out.

* 'robotlab/exclusive' - The robot lab is exclusive use. Best to not mess
  with this sitevar :-)

* 'robotlab/opentime' - The time that the robot lab opens in the
  morning. The default is 07:00, but feel free to change this as you like.

* 'robotlab/closetime' - The time that the robot lab closes in the
  evening. The default is 18:00, but feel free to change this as you like.

* 'robotlab/open' - The robot lab is open or closed. DO NOT MESS WITH THIS!
  It is updated by the robomonitord script and intended to be used by
  admission control (not done yet).

The robomonitord script runs and periodically (every 2 minutes) wakes up
and looks at the various sitevars above. The lab is open during the day,
Monday through Friday, and closed on weekends. It is also supposed to be
closed on holidays, but I have not added that yet.

15 minutes before the lab is to be closed, a warning message is sent to the
swapper of the experiment running on the robot testbed, that their
experiment is going to be swapped soon. When the Robot lab is closed
(either cause the close time was reached, or because the lab was forcibly
closed with the override), the current experiment is immediately swapped
out.

I know, this is hopelessly bogus, but it will do until we feel like adding
a "Lab" datatype to the system.
parent 389af08b
......@@ -2018,7 +2018,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
robots/mezzanine/libfg/GNUmakefile \
robots/mezzanine/libmezz/GNUmakefile \
robots/mezzanine/mezzanine/GNUmakefile \
robots/mezzanine/mezzcal/GNUmakefile "
robots/mezzanine/mezzcal/GNUmakefile robots/robomonitord"
#
# Do this for easy distclean.
......
......@@ -725,7 +725,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
robots/mezzanine/libfg/GNUmakefile \
robots/mezzanine/libmezz/GNUmakefile \
robots/mezzanine/mezzanine/GNUmakefile \
robots/mezzanine/mezzcal/GNUmakefile "
robots/mezzanine/mezzcal/GNUmakefile robots/robomonitord "
#
# Do this for easy distclean.
......
......@@ -181,7 +181,7 @@ use vars qw(@ISA @EXPORT);
TBDB_WIDEAREA_LOCALNODE
TBWideareaNodeID TBTipServers
TBSiteVarExists TBGetSiteVar
TBSiteVarExists TBGetSiteVar TBSetSiteVar
TBActivityReport GatherSwapStats GatherAssignStats
TBAvailablePCs
......@@ -207,6 +207,8 @@ use vars qw(@ISA @EXPORT);
TB_NODEHISTORY_OP_FREE TB_NODEHISTORY_OP_ALLOC TB_NODEHISTORY_OP_MOVE
TBSetNodeHistory
TBRobotLabExpt
);
# Must come after package declaration!
......@@ -2177,10 +2179,10 @@ sub UserDBInfo ($$$) {
my($dbuid, $username, $useremail) = @_;
my $query_result =
DBQueryFatal("select usr_name,usr_email from users ".
"where uid='$dbuid'");
DBQueryWarn("select usr_name,usr_email from users ".
"where uid='$dbuid'");
if ($query_result->num_rows < 1) {
if (!$query_result || $query_result->num_rows < 1) {
return 0;
}
......@@ -3039,6 +3041,49 @@ sub TBGetSiteVar($;$)
" Attempted to fetch unknown site variable $name\n");
}
#
# Set a sitevar. Assumed to be a real sitevar.
#
# usage: TBSetSiteVar($name, $value)
#
sub TBSetSiteVar($$)
{
my ($name, $value) = @_;
$name = DBQuoteSpecial($name);
$value = DBQuoteSpecial($value);
my $query_result =
DBQueryWarn("update sitevariables set value=$value where name=$name");
return 0
if (!$query_result);
return 1;
}
#
# Get pid,eid of current experiment using the robot lab. This is just
# plain silly for now.
#
sub TBRobotLabExpt($$)
{
my ($ppid, $peid) = @_;
my $query_result =
DBQueryWarn("select r.pid,r.eid from reserved as r ".
"left join nodes as n on n.node_id=r.node_id ".
"left join node_types as nt on nt.type=n.type ".
"where nt.class='robot' and r.pid!='$TBOPSPID'");
return 0
if (!$query_result || !$query_result->numrows);
my ($pid, $eid) = $query_result->fetchrow_array();
$$ppid = $pid;
$$peid = $eid;
return 1;
}
#
# List of tables used for experiment removal/backup/restore.
#
......
......@@ -71,6 +71,11 @@ case "$1" in
@prefix@/sbin/reload_daemon
fi
if [ -x @prefix@/sbin/robomonitord ]; then
echo -n " robomonitord"
@prefix@/sbin/robomonitord
fi
#
# Could trigger experiment creation, so make sure everything
# else is setup first; i.e., run this last!
......
......@@ -25,16 +25,19 @@ endif
SUBDIRS = tbsetdest $(MEZZDIR) mtp $(EMCDIR) vmcd primotion rmcd
all: all-subdirs
all: robomonitord all-subdirs
client: client-subdirs
client-install: client-install-subdirs
check: check-subdirs
install: install-subdirs
install: install-subdirs install-scripts
boss-install: install
include $(TESTBED_SRCDIR)/GNUmakerules
clean: clean-subdirs
install-scripts: $(addprefix $(INSTALL_SBINDIR)/, robomonitord)
# How to recursively descend into subdirectories to make general
# targets such as `all'.
%.MAKE:
......
......@@ -252,33 +252,10 @@ while (1) {
}
skip:
sleep(10);
sleep(60);
}
exit(0);
#
# Get pid,eid of current experiment using the robot lab. This is just
# plain silly for now.
#
sub TBRobotLabExpt($$)
{
my ($ppid, $peid) = @_;
my $query_result =
DBQueryWarn("select r.pid,r.eid from reserved as r ".
"left join nodes as n on n.node_id=r.node_id ".
"left join node_types as nt on nt.type=n.type ".
"where nt.class='robot' and r.pid!='$TBOPSPID'");
return 0
if (!$query_result || !$query_result->numrows);
my ($pid, $eid) = $query_result->fetchrow_array();
$$ppid = $pid;
$$peid = $eid;
return 1;
}
#
# Notify current user of the robot lab that they are going to get swapped.
#
......@@ -301,14 +278,19 @@ sub SwapWarn($$$)
print "Sending swap warning email to $swapper at ".
TBDateTimeFSSafe() . "\n";
SENDMAIL("$user_name <stoller>",
SENDMAIL("$user_name <$user_email>",
"Robot Lab Monitor Daemon Message",
"Your experiment running on the robot testbed, $pid/$eid, \n".
"will soon be swapped out when the robot testbed closes for \n".
"for the night.\n".
"\n".
"You have " . $timeleft / 60 . " minutes befor that happens!\n".
"\n",
"You have " . int($timeleft / 60) .
" minutes before that happens!\n".
"\n".
"Please save your data and swap your experiment out to avoid\n".
"losing any work.\n".
"\n".
"Thanks!\n",
$TBOPS,
"Cc: $TBOPS");
......
......@@ -44,3 +44,8 @@ INSERT INTO sitevariables VALUES ('general/autoswap_mode',NULL,'0','Control whet
INSERT INTO sitevariables VALUES ('webcam/anyone_can_view',NULL,'0','Turn webcam viewing on/off for mere users; default is off');
INSERT INTO sitevariables VALUES ('webcam/admins_can_view',NULL,'1','Turn webcam viewing on/off for admin users; default is on');
INSERT INTO sitevariables VALUES ('swap/use_admission_control',NULL,'1','Use admission control when swapping in experiments');
INSERT INTO sitevariables VALUES ('robotlab/override',NULL,'','Turn the Robot Lab on/off (open/close). This is an override over other settings');
INSERT INTO sitevariables VALUES ('robotlab/exclusive',NULL,'1','Only one experiment at a time; do not turn this off!');
INSERT INTO sitevariables VALUES ('robotlab/opentime',NULL,'07:00','Time the Robot lab opens for use.');
INSERT INTO sitevariables VALUES ('robotlab/closetime',NULL,'18:00','Time the Robot lab closes down for the night.');
INSERT INTO sitevariables VALUES ('robotlab/open',NULL,'0','Turn the Robot Lab on/off for weekends and holidays. Overrides the open/close times.');
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