1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
#! /bin/sh
# A script to verify/validate the proper operation of NWS and NWS-SLAPD
# Use FQDNs for the input hostnames...
# For convenient use, make sure that there are ssh keys authorized on the hosts
# on which the NWS components are to be staged
# Change shell to /usr/bin/bash on Solaris
USAGE="Usage: $0 -s (flag to start NWS and exit) -N [nameserver host] -M [memoryserver host] -S [sensor host] -P [proxy host] -b [binary path]"
if [ $# != 8 -a $# != 9 ]; then
echo ${USAGE};
exit 1;
fi
args=`getopt sN:M:S:iP:b: $*`
set -- $args
for i do
case "$i" in
-s) JUST_START='just_start'
shift;;
-N)
N_HOST=$2; shift;
shift;;
-M)
M_HOST=$2; shift;
shift;;
-S)
S_HOST=$2; shift;
shift;;
-P)
P_HOST=$2; shift;
shift;;
-b)
BIN_PATH=$2; shift;
shift;;
--)
shift; break;;
esac
done
OS=`uname`
echo "Runnin' on a ${OS} system"
if [ "${OS}" = "Solaris" -o "${OS}" = "SunOS" ]; then
PS='ps -elf';
else PS='ps auxww';
fi;
BIN_PREFIX=${BIN_PATH}
N_BIN_PREFIX=${BIN_PATH}
M_BIN_PREFIX=${BIN_PATH}
S_BIN_PREFIX=${BIN_PATH}
NWS_ETC="${HOME}/NWSdir/etc"
mkdir -p ${NWS_ETC}
# maybe will help nws-hostadmin
if [ -f "${HOME}/.nwsdb" ]; then
mv ${HOME}/.nwsdb ${HOME}/.nwsdb.orig
fi
N_PORT=44000
M_PORT=44010
S_PORT=44020
SLAPD_PORT=44030
N_HOME=$(ssh ${N_HOST} 'echo $HOME')
M_HOME=$(ssh ${M_HOST} 'echo $HOME')
S_HOME=$(ssh ${S_HOST} 'echo $HOME')
SLEEP_TIME=5
# more for nws-hostadmin
(echo "${N_HOST}:${N_PORT}" > ${HOME}/.nwsdb);
(echo "${M_HOST}:${M_PORT}" >> ${HOME}/.nwsdb);
(echo "${S_HOST}:${S_PORT}" >> ${HOME}/.nwsdb);
# set up scratch file locations on all hosts
TMPDIR="${HOME}/NWSdir"
N_TMPDIR="${N_HOME}/NWSdir"
M_TMPDIR="${M_HOME}/NWSdir"
S_TMPDIR="${S_HOME}/NWSdir"
rm -fr ${TMPDIR}; mkdir ${TMPDIR}
N_DIR_CMD="rm -fr ${N_TMPDIR}; mkdir ${N_TMPDIR}"
M_DIR_CMD="rm -fr ${M_TMPDIR}; mkdir ${M_TMPDIR}"
S_DIR_CMD="rm -fr ${S_TMPDIR}; mkdir ${S_TMPDIR}"
ssh ${N_HOST} ${N_DIR_CMD}
ssh ${M_HOST} ${M_DIR_CMD}
ssh ${S_HOST} ${S_DIR_CMD}
# name server
ssh ${N_HOST} ${N_BIN_PREFIX}/nws_nameserver -e ${N_TMPDIR}/name.err \
-l ${N_TMPDIR}/name.log -f ${N_TMPDIR}/name.regs -p ${N_PORT} \
-i ${N_TMPDIR}/nam.pid \
2>&1 > ${TMPDIR}/n_noise &
echo "* Name Server on ${N_HOST}:${N_PORT}"
# memory server
ssh ${M_HOST} ${M_BIN_PREFIX}/nws_memory -d ${M_TMPDIR} \
-e ${M_TMPDIR}/memory.err -l ${M_TMPDIR}/memory.log \
-N ${N_HOST}:${N_PORT} -p ${M_PORT} -i ${M_TMPDIR}/mem.pid \
2>&1 > ${TMPDIR}/m_noise &
echo "* Memory Server on ${M_HOST}:${M_PORT}"
# sensor
ssh ${S_HOST} ${S_BIN_PREFIX}/nws_sensor -e ${S_TMPDIR}/sensor.err \
-l ${S_TMPDIR}/sensor.log -N ${N_HOST}:${N_PORT} \
-M ${M_HOST}:${M_PORT} -p ${S_PORT} -i${S_TMPDIR}/sens.pid \
2>&1 > ${TMPDIR}/s_noise &
echo "* Sensor on ${S_HOST}:${S_PORT}"
if [ "${OS}" = "Solaris" -o "${OS}" = "SunOS" ]; then
AWKNUM='$4';
else AWKNUM='$2';
fi
N_ME=$(ssh ${N_HOST} 'echo $USER')
M_ME=$(ssh ${M_HOST} 'echo $USER')
S_ME=$(ssh ${S_HOST} 'echo $USER')
AWK="awk '{print ${AWKNUM};}'"
# find remote pids for nws components
N_REMOTE_PID=$(ssh ${N_HOST} "${PS} | grep ${N_ME} | grep nws_nameserver | \
${AWK} | head -n 1")
M_REMOTE_PID=$(ssh ${M_HOST} "${PS} | grep ${M_ME} | grep nws_memory | \
${AWK} | head -n 1")
S_REMOTE_PID=$(ssh ${S_HOST} "${PS} | grep ${S_ME} | grep nws_sensor | \
${AWK} | head -n 1")
#echo "${N_REMOTE_PID} ${M_REMOTE_PID} ${S_REMOTE_PID}"
if [ "${N_REMOTE_PID}" -a "${M_REMOTE_PID}" -a "${S_REMOTE_PID}" ]; then
echo "* Remote jobs have started.";
else
echo "=( Remote jobs NOT started.";
fi
if [ "${JUST_START}" ]; then
exit 3;
fi
# look for registrations and verify activity
echo "* Starting activity..."
${BIN_PREFIX}/start_activity ${S_HOST}:${S_PORT} \
name:${S_HOST}Memory controlName:periodic skillName:memoryMonitor period:1 \
2>&1 > ${TMPDIR}/start.log
# let the sensors gather some measurements...
sleep $SLEEP_TIME;
echo "* Testing sensors..."
# memory
MEMFILTER="(&(name=${S_HOST}Memory)(resource=freeMemory))"
TSTMEM=$(${BIN_PREFIX}/nws_search -N ${N_HOST}:${N_PORT} ${MEMFILTER} | grep "${S_HOST}Memory" 2>&1)
XTRACTMEM_M=$(${BIN_PREFIX}/nws_extract -M ${M_HOST}:${M_PORT} -f time,measurement freeMemory ${S_HOST}:${S_PORT} | head -n 2 2>&1)
XTRACTMEM_N=$(${BIN_PREFIX}/nws_extract -N ${N_HOST}:${N_PORT} -f time,measurement freeMemory ${S_HOST}:${S_PORT} | head -n 2 2>&1)
if [ "${TSTMEM}" ]; then
echo ";D MEM MONITOR/SEARCH TEST PASSED! ${TSTMEM}";
else
echo "=( MEM MONITOR/SEARCH TEST BOMBED!";
fi
if [ "${XTRACTMEM_M}" -a "${XTRACTMEM_N}" ]; then
echo ";D EXTRACT TEST PASSED! ${XTRACTMEM_M} ${XTRACTMEM_N}";
else
echo "=( EXTRACT TEST BOMBED!";
fi
#cpu
CPUFILTER="(&(name=${S_HOST}:${S_PORT}.cpuMonitor))"
TSTCPU=$(${BIN_PREFIX}/nws_search -N ${N_HOST}:${N_PORT} ${CPUFILTER} | grep "${S_HOST}:${S_PORT}.cpu" 2>&1)
#XTRACTCPU_M=$(${BIN_PREFIX}/nws_extract -M ${M_HOST}:${M_PORT} -f time,measurement avail ${S_HOST}:${S_PORT} 2>&1)
#XTRACTCPU_N=$(${BIN_PREFIX}/nws_extract -N ${N_HOST}:${N_PORT} -f time,measurement avail ${S_HOST}:${S_PORT} 2>&1)
if [ "${TSTCPU}" ]; then
echo ";D CPU MONITOR/SEARCH TEST PASSED! ${TSTCPU}";
else
echo "=( CPU MONITOR TEST BOMBED!";
fi
# slapd verification
if [ "$(which ldapsearch)" -o -f "${GLOBUS_LOCATION}/bin/ldapsearch" ]; then
echo "* Testing slapd...";
if [ -f "${GLOBUS_LOCATION}/bin/ldapsearch" ]; then
SLAPD_CMD="${GLOBUS_LOCATION}/libexec/slapd";
SLAP_SRCH_CMD="${GLOBUS_LOCATION}/bin/ldapsearch";
# else
# SLAPD_CMD="$(which slapd)";
# SLAP_SRCH_CMD="$(which ldapsearch)";
# fi
fi
# local slapd with a remote nameserver should do it
if [ -f "${GLOBUS_LOCATION}"/etc/grid-info-nws.conf ]; then
sed -e "s/nws.nsf-middleware.org:8090/${N_HOST}:${N_PORT}/g" ${GLOBUS_LOCATION}/etc/grid-info-nws.conf | sed -e "s!@ETCDIR@!${GLOBUS_LOCATION}/etc!g" > ${TMPDIR}/nwslapd.conf;
fi
SLAPPY=$(${SLAPD_CMD} -f ${TMPDIR}/nwslapd.conf -h ldap://0.0.0.0:${SLAPD_PORT}/);
#echo "${SLAPPY}";
sleep $SLEEP_TIME;
TSTSLAP=$(${SLAP_SRCH_CMD} -x -H ldap://localhost:${SLAPD_PORT}/ -b "service=nws, o=grid" | grep ${S_HOST});
#echo "${TSTSLAP}";
TSTSLAPPY=$(echo ${TSTSLAP} | awk '{print $2;}');
if [ "${TSTSLAP}" ]; then
echo ";D SLAPD TEST PASSED! ${TSTSLAPPY}";
else
echo "=( SLAPD TEST BOMBED! ${SLAPPY}";
fi
else
echo "\* No LDAPSEARCH found; skipping slapd verification.";
fi
# verify halt_activity
echo "\* Halting activity..."
${BIN_PREFIX}/halt_activity -N ${N_HOST}:${N_PORT} -S ${S_HOST}:${S_PORT} ${S_HOST}Memory
TSTMEM_HALT=$(${BIN_PREFIX}/nws_search -N ${N_HOST}:${N_PORT} ${MEMFILTER} | grep \"${S_HOST}Memory\")
TSTCPU_HALT=$(${BIN_PREFIX}/nws_search -N ${N_HOST}:${N_PORT} ${CPUFILTER} | grep \"${S_HOST}:${S_PORT}.cpu\")
if [ ! "${TSTMEM_HALT}" -a "${TSTCPU_HALT}" ]; then
echo ";D HALT TEST PASSED!";
else
echo "=( HALT TEST BOMBED!";
fi
echo "\* Cleaning up...";
SLAPD_PID=$(${PS} | grep slapd | grep ${SLAPD_PORT} | awk '{print $2;}');
if [ "${SLAPD_PID}" ]; then
kill ${SLAPD_PID};
fi
ssh ${N_HOST} kill ${N_REMOTE_PID} 2>&1 > ${TMPDIR}/ded.log
ssh ${M_HOST} kill ${M_REMOTE_PID} 2>&1 >> ${TMPDIR}/ded.log
ssh ${S_HOST} kill ${S_REMOTE_PID} 2>&1 >> ${TMPDIR}/ded.log
echo "\* Done.";
exit 0;
|