Commit 5aece56b authored by Mac Newbold's avatar Mac Newbold

Big changes. Add idlecheck, sdisrunning and sddeploy to configure and the make...

Big changes. Add idlecheck, sdisrunning and sddeploy to configure and the make files. Install sd* above into sbin dir. Rename sddeploy.pl and isrunning.pl.
parent ae6d6bbd
......@@ -1185,11 +1185,10 @@ outfiles="$outfiles Makeconf GNUmakefile \
capture/GNUmakefile \
db/GNUmakefile db/nalloc db/nfree db/if2port db/backup \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog db/webnodelog db/unixgroups \
db/dbcheck db/interswitch db/dbboot db/schemacheck \
db/grabron \
db/grabron db/idlecheck discvr/GNUmakefile \
ipod/GNUmakefile \
lib/GNUmakefile lib/libtb/GNUmakefile \
os/GNUmakefile os/split-image.sh os/imagezip/GNUmakefile \
......@@ -1198,6 +1197,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
security/GNUmakefile security/paperbag security/lastlog_daemon \
security/plasticwrap \
sensors/GNUmakefile sensors/slothd/GNUmakefile \
sensors/slothd/sdisrunning sensors/slothd/sddeploy \
tbsetup/GNUmakefile tbsetup/console_setup tbsetup/spewlogfile \
tbsetup/console_reset tbsetup/bwconfig tbsetup/power_rpc27.pm \
tbsetup/os_load tbsetup/os_setup tbsetup/power \
......
......@@ -257,11 +257,10 @@ outfiles="$outfiles Makeconf GNUmakefile \
capture/GNUmakefile \
db/GNUmakefile db/nalloc db/nfree db/if2port db/backup \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog db/webnodelog db/unixgroups \
db/dbcheck db/interswitch db/dbboot db/schemacheck \
db/grabron \
db/grabron db/idlecheck discvr/GNUmakefile \
ipod/GNUmakefile \
lib/GNUmakefile lib/libtb/GNUmakefile \
os/GNUmakefile os/split-image.sh os/imagezip/GNUmakefile \
......@@ -270,6 +269,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
security/GNUmakefile security/paperbag security/lastlog_daemon \
security/plasticwrap \
sensors/GNUmakefile sensors/slothd/GNUmakefile \
sensors/slothd/sdisrunning sensors/slothd/sddeploy \
tbsetup/GNUmakefile tbsetup/console_setup tbsetup/spewlogfile \
tbsetup/console_reset tbsetup/bwconfig tbsetup/power_rpc27.pm \
tbsetup/os_load tbsetup/os_setup tbsetup/power \
......
......@@ -8,7 +8,7 @@ SUBDIR = db
include $(OBJDIR)/Makeconf
BIN_SCRIPTS = nalloc nfree nodeip
BIN_SCRIPTS = nalloc nfree nodeip idlecheck
SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
genelists genelists.proxy dhcpd_makeconf nodelog unixgroups \
dbcheck interswitch dbboot grabron
......
#!/usr/bin/perl -w
# idlecheck - See if node/expt is active
# Configure variables
use lib '@prefix@/lib';
use libdb;
use English;
# Turn off line buffering on output
$| = 1;
$d = 0; #debug mode
$h = 0; #help mode
sub help {
die("Usage:\nidlecheck [-h] [-t hours] [-p pid -e eid] [-n node_id]
-h\tThis help message
-t\tNumber of hours of inactiviy required to be considered idle
-p\tSpecify a project
-e\tSpecify an experiment
-n\tSpecify a node
Check activity for the given pid/eid or node, or for all experiments
if no pid/eid is given. Currently the following qualify as activity:
* Packets sent/received on the experimental network
* Use of a tty
Activity does not currently include:
* Computation (non-idle load averages)
* Control net traffic
* Control without the use of a tty\n"
);
}
print "Got ARGV = ",join(" ",@ARGV),"\n" if $d > 1;
my %args = ();
while ($#ARGV >= 0) {
$_ = shift;
$_ =~ /^(.)(.)/;
if ($1 ne '-') { next; }
if ($2 ne 'p' && $2 ne 'e' && $2 ne 'n' &&
$2 ne 'd' && $2 ne 'h' && $2 ne 't') { next; }
my $opt="\L$2";
my $val = shift if ($#ARGV >= 0 && ($ARGV[0] =~ /^[^-]/));
if (!defined($val)) { $val=1; }
$$opt=$val;
if ($d>1) { print "$opt = $$opt\n"; }
}
if ($h) { help(); }
# Only root or admin types!
if (($UID != 0) && (!TBAdmin($UID))) {
die("Only root or TB administrators can run idlecheck.\n");
}
# Configurable parameters
my $idlehours = 24;
my $minpph = 4; # Min packets per hour that an idle interface sends/rcvs
my $minpkts = $idlehours * $minpph;
my $idlesec = $idlehours * 3600;
my $node1="";
my $node2="";
my $node3="";
if ($n) {
$node1="a.node_id,";
$node2="and a.node_id=\"$n\"";
$node3=",node_id";
}
# This query finds how many packets the non-control net interfaces
# have sent in the last $idlesec seconds, and saves it in a temporary
# table. It then aggregates that and shows a list of pid/eid (and
# maybe nodes) whose interfaces have each sent less than $minpkts
# packets in the time period. It also makes sure to only count entries
# since they've been swapped in, and makes sure they were swapped in
# at least $idlesec seconds ago.
for my $cmd ("drop table if exists idletemp;",
"create temporary table idletemp
select r.pid,r.eid, $node1
max(ipkts)-min(ipkts) as idiff , max(opkts)-min(opkts) as odiff
from iface_counters as a
left join reserved as r on a.node_id = r.node_id
left join interfaces as i on a.mac=i.mac
left join experiments as e on e.pid=r.pid and e.eid=r.eid
where tstamp >= expt_swapped
and (unix_timestamp(now())-unix_timestamp(tstamp) <= $idlesec)
and (unix_timestamp(now())-unix_timestamp(expt_swapped) >= $idlesec)
and IP not like \"155.101.%\" $node2
group by r.pid,r.eid,a.mac;",
"select pid,eid, max(idiff), max(odiff) from idletemp
group by pid,eid $node3
having (max(idiff) <= $minpkts) and (max(odiff) <= $minpkts);",
"select r.pid,r.eid,max(last_tty) as lastuse ,max(tstamp) as t
from node_idlestats as n
left join reserved as r on n.node_id=r.node_id
left join experiments as e on e.pid=r.pid and e.eid=r.eid
where tstamp >= expt_swapped and r.pid is not null and r.eid is not null
group by pid,eid
having (unix_timestamp(now())-unix_timestamp(t) <= 7200)
and (unix_timestamp(now())-unix_timestamp(lastuse) >= 86400)
order by pid,eid,last_tty,tstamp;") {
print "Sending cmd:\n$cmd\n" if $d;
my $result = DBQueryFatal($cmd);
print $result->as_string();
if ($cmd =~ /^select /i && $result->numrows() == 0) {
# nothing that has been reporting regularly is idle...
exit(0);
}
}
exit(0);
......@@ -4,6 +4,8 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = sensors/slothd
SBIN_SCRIPTS = sdisrunning sddeploy
include $(OBJDIR)/Makeconf
CC?=gcc
......@@ -37,7 +39,7 @@ islinux:
isfbsd:
@uname -s | grep BSD > /dev/null
install:
install: $(addprefix $(INSTALL_SBINDIR)/, $(SBIN_SCRIPTS))
clean:
rm -f *.o $(PROGS) *~ core *.core
......
#!/usr/bin/perl -w
use lib '/usr/testbed/lib';
use lib '@prefix@/lib';
use libdb;
use English;
......
#!/usr/bin/perl -w
use lib '/usr/testbed/lib';
use lib '@prefix@/lib';
use libdb;
#use Mysql;
......
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