diff --git a/pelab/libnetmon/GNUmakefile b/pelab/libnetmon/GNUmakefile index 52587bf69f12c86c174f33aadfed819f57255363..b5193d9333b9d5e431b19bf2d65f0e9dbf770dad 100644 --- a/pelab/libnetmon/GNUmakefile +++ b/pelab/libnetmon/GNUmakefile @@ -15,10 +15,10 @@ else LD_FLAGS= endif -all: libnetmon.so netmond +all: libnetmon.so netmond netmonup %.so: %.c %.h $(CC) $(CFLAGS) $(LD_FLAGS) -shared -o $@ $< clean: - -rm *.so netmond + -rm *.so netmond netmonup diff --git a/pelab/libnetmon/netmonup.c b/pelab/libnetmon/netmonup.c new file mode 100644 index 0000000000000000000000000000000000000000..b4df33528c2c4e265e5716244025093c62be8b02 --- /dev/null +++ b/pelab/libnetmon/netmonup.c @@ -0,0 +1,19 @@ +#include <stdlib.h> +#include <unistd.h> +#include <sys/socket.h> + +/* + * Quick hack: just open a socket. + * Return 0 if it works, non-zero otherwise. + * When run under instrument.sh, will tell us if netmond is ready for traffic. + */ +int +main() +{ + int rv = socket(PF_INET, SOCK_DGRAM, 0); + if (rv >= 0) { + close(rv); + exit(0); + } + exit(rv); +} diff --git a/pelab/make-tarball b/pelab/make-tarball index acde58b7612afbde0c6acd907e8347203e5ece62..c115480433ca878d1e8edfc3c3bd0befcfe0d83d 100755 --- a/pelab/make-tarball +++ b/pelab/make-tarball @@ -21,7 +21,7 @@ fi echo "##### cleaning up a little" rm -f magent/*.o stub/*.o -strip magent/magent stub/stubd +strip magent/magent stub/stubd libnetmon/netmonup echo "##### creating tarball $path from .." tar czf $path -C .. $files diff --git a/pelab/monitor/auto-monitor.sh b/pelab/monitor/auto-monitor.sh index cb1a273b8f518ccaeca391f89d124ff7009b6420..59e8ce45d31e94cb602a134c534374535ec8d7a7 100644 --- a/pelab/monitor/auto-monitor.sh +++ b/pelab/monitor/auto-monitor.sh @@ -9,6 +9,11 @@ ARGS=$* . `dirname $0`/../common-env.sh +# +# How long to wait for netmond. +# +NETMOND_TIMO=60 + # # Wait for all of the stubs to start # @@ -29,9 +34,19 @@ MONPID=$! trap "{ $AS_ROOT kill $MONPID; $AS_ROOT killall netmond; true; }" TERM # -# Give it time to come up +# Make sure it is ready to receive requests. +# We do this with a simple program that just opens a socket. +# When run under libnetmon, it will fail if netmond is not yet running. # -sleep 1 +if [ -x ${NETMON_DIR}/netmonup ]; then + LIBNETMON_CONNECTTIMO=$NETMOND_TIMO \ + ${MONITOR_DIR}/instrument.sh ${NETMON_DIR}/netmonup + if [ $? -ne 0 ]; then + echo "**** WARNING: netmond failed to start after $NETMOND_TIMO seconds" + fi +else + sleep 2 +fi # # Wait for all the monitors to come up