Commit 23796494 authored by Russ Fish's avatar Russ Fish

Enable slothd on Windows.

parent 30b2e1f0
......@@ -14,17 +14,26 @@ TBLIB = $(OBJDIR)/lib/libtb/libtb.a
SBIN_SCRIPTS = sdisrunning sddeploy
SDPROGS = sdcollectd slothd
SYSTEM := $(shell uname -s)
include $(OBJDIR)/Makeconf
CC?=gcc
## For debug compilation
##CFLAGS+= -g
CFLAGS+= -Wall -I${OBJDIR} -I/usr/local/include -I$(TESTBED_SRCDIR)/lib/libtb \
-DCLIENT_BINDIR='"$(CLIENT_BINDIR)"' \
-DLOG_TESTBED=$(LOG_TESTBED)
LDFLAGS+= -L${OBJDIR}/lib/libtb -L/usr/local/lib/mysql
SDLIBS+= -ltb -lmysqlclient
LIBS=
LIBS= $(MLIBS)
CP= cp -pf
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
# Cygwin on Windows XP (a.k.a. NT 5.1).
MLIBS += -liphlpapi
endif
all: $(SDPROGS) client
include ${TESTBED_SRCDIR}/GNUmakerules
......@@ -49,7 +58,7 @@ install: $(addprefix $(INSTALL_SBINDIR)/, $(SBIN_SCRIPTS) sdcollectd) webfeedbac
$(INSTALL_PROGRAM) webfeedback $(INSTALL_LIBEXECDIR)
client-install: client
$(INSTALL_PROGRAM) slothd$(EXE) $(DESTDIR)$(CLIENT_BINDIR)$(EXE)
$(INSTALL_PROGRAM) slothd$(EXE) $(DESTDIR)$(CLIENT_BINDIR)/slothd$(EXE)
control-install:
......
This diff is collapsed.
......@@ -45,7 +45,7 @@
#define PIDFILE "/var/run/slothd.pid"
#define MACADDRLEN 18
#define MAXNUMIFACES 10
#define MAXIFNAMELEN 10
#define MAXIFNAMELEN 30 /* On Windows, "Local Area Connection 16". */
#define LINEBUFLEN 256
#define MAXTTYS 2000
#define MAXDEVLEN 50
......@@ -65,16 +65,6 @@
#define LOG_TESTBED LOG_DAEMON
#endif
#ifdef __FreeBSD__
#define CNTFMTSTR "%s %*s %*s %s %lu %*s %lu"
#define NUMSCAN 4
#endif
#ifdef __linux__
#define CNTFMTSTR "%s %*s %*s %lu %*s %*s %*s %lu"
#define NUMSCAN 3
#endif
#define TTYACT (1<<0)
#define LOADACT (1<<1)
#define PKTACT (1<<2)
......@@ -86,6 +76,9 @@ typedef struct {
#endif
u_int cnt;
char *cifname;
#ifdef __CYGWIN__
char *cifaddr;
#endif /* __CYGWIN__ */
u_char dolast;
time_t lastrpt;
time_t startup;
......
......@@ -21,7 +21,17 @@ uname -r > $iscygwin
chmod g+w $iscygwin
chmod -f g-w /etc/emulab
# Make sure the computer name is right, reboots to change it if necessary.
# NetBT (Netbios over TCP) chatters, messes up slothd, and is not needed for
# SMB, so disable it. This doesn't take effect until TCP/IP is restarted, so
# do it before the computer name change below, which reboots the first time.
svcs=/HKLM/SYSTEM/CurrentControlSet/Services pi=Parameters/Interfaces
nbtif=$svcs/NetBT/$pi
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Disable (2.)
regtool set -i $nbtif/$ifc/NetbiosOptions 2
done
# Make sure the computer name is right. Reboots to change it if necessary.
nodeid=
while [ -z $nodeid ]; do
nodeid=`tmcc nodeid`
......@@ -74,7 +84,7 @@ else
# Last resort!!! tsshutdn
datehost="`date`: Host name '$hostname'"
# msg="$datehost didn't /bin/shutdown changing to '$nodeid'! Trying tsshutdn."
msg="$datehost didn't reboot changing to '$nodeid'! Trying reboot."
msg="$datehost didn't reboot changing to '$nodeid'! Trying tsshutdn."
echo "$msg" >> $logfile
echo "$msg"
tsshutdn 1 /REBOOT /DELAY:1
......@@ -98,6 +108,16 @@ ipconfig /all | awk \
'/^ *Connection-specific DNS Suffix/{print "search", $NF} \
/^ *DNS Servers/{print "nameserver", $NF}' > /etc/resolv.conf
# Remember the control net interface MAC address and Local Area Connection name for
# slothd. It's the one whose IP address is returned by looking up the nodeid (pc%d).
cif=/var/emulab/boot/controlif
nodeid=`cat /var/emulab/boot/nodeid`
ipaddr=`nslookup $nodeid | awk 'NR>2 && /Address:/{print $2}'`
ipconfig /all | tr -d '\r' | awk \
'/^Ethernet adapter/{ ifc = gensub("Ethernet adapter (.*):", "\\1", 1); next }\
/Physical Address/{ gsub("-", ":"); mac = tolower($NF); next}\
/IP Address/ && $NF=="'$ipaddr'"{ print mac, ifc > "'$cif'"; exit }'
# Start up the service which will deliver a SHUTDOWN state event on reboot.
cygrunsrv -S EmulabShutdown
......
*** openssh-4.1p1-2/channels.h.orig Tue Mar 1 03:24:33 2005
--- openssh-4.1p1-2/channels.h Thu Aug 11 14:43:12 2005
***************
*** 183,188 ****
--- 183,193 ----
void channel_input_port_open(int, u_int32_t, void *);
void channel_input_window_adjust(int, u_int32_t, void *);
+ #ifdef HAVE_CYGWIN
+ /* Emulab patch - Touch a file so we know when input happens. */
+ void input_occurred();
+ #endif
+
/* file descriptor handling (read/write) */
void channel_prepare_select(fd_set **, fd_set **, int *, u_int*, int);
*** openssh-4.1p1-2/channels.c.orig Mon Mar 14 05:22:26 2005
--- openssh-4.1p1-2/channels.c Thu Aug 11 17:13:33 2005
***************
*** 1896,1902 ****
--- 1896,1936 ----
packet_check_eom();
buffer_append(&c->output, data, data_len);
xfree(data);
+ #ifdef HAVE_CYGWIN
+ input_occurred();
+ #endif
}
+
+ #ifdef HAVE_CYGWIN
+ /* Emulab patch - Touch a file so we know when input happens. */
+ char *ssh_time_file = "/var/run/ssh_input";
+ int input_occurred_fd = 0;
+ time_t last_time = 0;
+ void
+ input_occurred()
+ {
+ if (input_occurred_fd == 0)
+ /* No init yet. */
+ input_occurred_fd = open(
+ ssh_time_file, O_CREAT | O_TRUNC | O_WRONLY, 0666);
+ if (input_occurred_fd == -1) {
+ logit("Failed to open ssh_time_file %s.", ssh_time_file);
+ input_occurred_fd = -2;
+ }
+ if (input_occurred_fd > 0
+ /* Don't do it more than once a second. */
+ && time(NULL) != last_time) {
+ last_time = time(NULL);
+
+ /* It would be nice to use futimes(), but there's not one
+ * on Cygwin. Instead, use ftruncate() to set the modtime.
+ */
+ if (ftruncate(input_occurred_fd, 0))
+ logit("Error touching ssh input time file, %s.",
+ strerror(errno));
+ }
+ }
+ #endif
void
channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
*** openssh-4.1p1-2/serverloop.c.orig Fri Aug 13 05:18:01 2004
--- openssh-4.1p1-2/serverloop.c Thu Aug 11 15:52:45 2005
***************
*** 821,826 ****
--- 821,829 ----
buffer_append(&stdin_buffer, data, data_len);
memset(data, 0, data_len);
xfree(data);
+ #ifdef HAVE_CYGWIN
+ input_occurred();
+ #endif
}
static void
......@@ -83,9 +83,10 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
. Mirror is http://mirrors.xmission.com .
. Click [View] to "Not Installed" (alphabetical.)
Click on the Skip in the "New" column to add a binary version of:
agetty, bison, cvs, cygrunsrv, ed, file, flex, gcc, gdb, make, minires-devel, nano,
openssh, openssl-devel, patch, perl, perl-libwin32, python, rpm, rpm-build,
rsync, shutdown, tcsh, vim, wget, zip .
agetty, bison, cvs, cygrunsrv, ed, file, flex, gcc, gdb, inetutils,
make, minires-devel, nano, openssh, openssl-devel,
patch, perl, perl-libwin32, python, rpm, rpm-build, rsync,
shutdown, tcsh, vim, wget, zip .
. Don't "Create an icon on the Desktop", do "Add icon to Start Menu".
. Add ;C:\cygwin\bin to the end of the System PATH in
......@@ -127,6 +128,16 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
cp -p /etc/passwd{.new,}
chown root /etc/{passwd,group}*
. Set up the syslog daemon. (See usr/share/doc/Cygwin/inetutils-1.3.2.README)
# Make sure /etc isn't owned by SYSTEM, which will prevent making syslogd.conf .
chown root /etc
syslogd-config -y
# Start the daemon. It starts automatically at reboot.
net start syslogd
# Test.
logger "Test syslogd."
tail /var/log/messages
. Set up sshd.
- Edit /bin/ssh-host-config to add a -i argument to the "cygrunsrv -I sshd" lines.
grep cygrunsrv /bin/ssh-host-config
......@@ -136,9 +147,10 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
w
q
- Then start a cygwin shell, stop sshd and remove its entry, run ssh-host-config:
cygrunsrv -VQ sshd
cygrunsrv -E sshd
cygrunsrv -R sshd
(You must be logged in as root over RDP, not ssh when you do this.)
cygrunsrv -VQ sshd
cygrunsrv -E sshd
cygrunsrv -R sshd
# May need to do some unmounts before running ssh-host-config.
# It does a mount, and there's a hard-wired limit of 31 mount table entries.
......@@ -146,7 +158,7 @@ alias rootrd 'rd -K -g 1280x1024 -u root pc\!^.$en &'
## mount: /ssh-host-config.3048: Too many mount entries
for s in /users/s*; do umount $s; done
# Should be NO ssh processes running.
# Should be NO ssh processes running, not even ssh-agent!
ps -Welf | grep ssh
# Make sure /etc is writable by root.
......@@ -183,8 +195,9 @@ q
kill -HUP `cat /var/run/sshd.pid`
. LogLevel defaults to INFO, can be set to VERBOSE, DEBUG1, etc.
Debug events are logged under Event View / Application / sshd,
One line per event (ugh.) Refresh to see new events with F5.
With the syslogd service running, debug events are logged to /var/log/messages .
[Otherwise, they show up under Event Viewer / Application / sshd,
with one line per event (ugh.) Refresh to see new events with F5.]
## sshd service debugging.
ls -l /etc/sshd_config
# Check.
......@@ -514,29 +527,27 @@ daFluxGroup
ssh $cvs_login id
ssh -v $cvs_login id
export CVSROOT=$cvs_login:/usr/flux/CVS CVS_RSH=ssh
mkdir ~/flux
cd ~/flux
export CVSROOT=$cvs_login:/usr/flux/CVS CVS_RSH=ssh
# First time only
mkdir CVS; touch CVS/Entries; echo . > CVS/Repository
# Any time the testbed tree needs to be re-created.
cvs -Q co testbed
# Updates After that.
cat CVS/Entries
cvs -n -q update testbed
cvs -Q update -d testbed
# Some dotfiles for Root.
# Install some dotfiles for Root.
cp -p testbed/tmcd/cygwinxp/cygwin.root.bashrc ~root/.bashrc
cp -p testbed/tmcd/cygwinxp/cygwin.root.bash_profile ~root/.bash_profile
cp -p testbed/tmcd/cygwinxp/cygwin.root.emacs ~root/.emacs
# No HOME envar is set for root's desktop, so Emacs defaults it to C:/ .
cp -p ~root/.emacs C:/.emacs
# Site-lisp files for Emacs.
# Install site-lisp files for Emacs.
cp -rp testbed/tmcd/cygwinxp/site-lisp/* c:/emacs-21.3/site-lisp
ls -l c:/emacs-21.3/site-lisp
......@@ -680,6 +691,7 @@ if [ ]; then
v C:/WINDOWS/system32/setx.exe
. Patch sshd so that shares (including /users homedirs) work with public-key logins.
Also touches a file when client input is received, so slothd will know.
- RDP into a node as root and shut down all ssh processes before update.
net stop sshd
......@@ -690,14 +702,23 @@ if [ ]; then
/cygdrive/c/software/cygwin/setup.exe &
When base dll's are updated, it will tell you to reboot. Do it.
- Install the source patch.
- Install the source patches.
(cd ~/flux; cvs update testbed/tmcd/cygwinxp)
(cd ~/flux; cvs co testbed/tmcd/cygwinxp)
cd /usr/src/openssh*
# Enable no-password ssh logins which can access shared homedirs.
cp -p uidswap.c{,.orig}
patch -p1 --dry-run < ~/flux/testbed/tmcd/cygwinxp/uidswap.c.patch
patch -p1 -b < ~/flux/testbed/tmcd/cygwinxp/uidswap.c.patch
# Enable slothd to know of the last SSH client input time.
foreach f ( channels.{h,c} serverloop.c )
cp -p $f{,.orig}
end
patch -p1 --dry-run < ~/flux/testbed/tmcd/cygwinxp/sshd-client-input-time.patch
patch -p1 -b < ~/flux/testbed/tmcd/cygwinxp/sshd-client-input-time.patch
- Configure. Takes a while.
# These are the options that contrib/cygwin/README specifies:
prefix=/usr sbindir=/usr/sbin datadir=$prefix/share
......@@ -721,6 +742,42 @@ if [ ]; then
/usr/bin/install -c -m 0755 -s sshd /usr/sbin/sshd.exe
net start sshd
. Make a load average log, averaged over a 1 minute period, for slothd's use.
- /proc/loadavg is hard-wired to "0.00 0.00 0.00" on Cygwin now.
- All attempts to script this setup to reproduce it on another computer have
failed so far, including using its own "Save/Restore Settings" and
transplanting the registry subtree.
- Click into Computer Management / Performance Logs and Alerts / Counter Logs.
Right-click "New Log Settings..." in the logs pane,
Name: "ldavg", OK.
General tab,
Counters list, "Add Counters...",
check "Use local computer counters",
click "Add" to add % total processor (the default),
click "Close".
Sample data every: Interval: "60" seconds.
Log Files tab,
Log file type: "Text File (Comma delimited)",
Uncheck "End file names with" so the result goes into C:\cygwin\var\run\ldavg.csv .
Configure... Log file size: "Limit of: 1 MB", OK.
Schedule tab,
Start Log: Click "At" (which defaults to the current time, as well as the future.)
Stop Log: Click "When the 1-MB log file is full.",
When a log file closes: "Start a new log file", OK.
OK.
# ldavg should start out red (stopped) and turn green (stated.)
# It will start again after reboot.
# You can turn it off and on with the right-click menu on "ldavg" in the logs pane.
tail -f /var/run/ldavg.csv
================================================================
Making images
......
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