Commit f3ad18f6 authored by Mike Hibler's avatar Mike Hibler

Doofy program to allow us to check whether netmond is ready for connections.

We use this in the monitor/auto-start script to ensure the monitor is ready
before declaring ourselves done.
parent f5bdc358
......@@ -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
#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);
}
......@@ -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
......@@ -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
......
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