Files
secondo/Algebras/Hadoop/clusterManagement/ps-start-AllMonitors

97 lines
2.1 KiB
Plaintext
Raw Normal View History

2026-01-23 17:03:45 +08:00
#!/bin/bash
bin=`dirname "$0"`
bin=`cd "$bin"; pwd`
source $bin/ps-functions
ADDPAR="" # Additional startup parameters for each slave
SLONLY=false
# Process the parameters
declare -i numOfArgs=$#
let numOfArgs++
while [ $numOfArgs -ne $OPTIND ]; do
getopts "hsop" optKey
if [ "$optKey" == "?" ]; then
optKey="h"
fi
case $optKey in
h)
echo -en "\nUsage of ${0##*/}:\n\n"
echo -en "Start up the Secondo Monitors on machines inside the cluster.\n"
echo -en "Machine's IP addresses are listed in the file\n$PARALLEL_SECONDO_SLAVES \n$PARALLEL_SECONDO_MASTER\n\n"
echo -en " -h Print this message and exit. \n\n"
echo -en " -s Start up the monitors only on Slave nodes. \n\n"
echo -en " -o Start the Secondo Monitors base on Own configuration \n"
echo -en " $HOME/.parasecrc \n\n"
echo -en " -p Profile the Secondo Monitors\n\n"
exit 0
;;
s)
SLONLY=true
;;
o)
ADDPAR="$ADDPAR -o"
;;
p)
ADDPAR="$ADDPAR -p"
esac
done
aJobs=()
Status="/tmp/.${USER}_ps-start-AllMonitors.data"
cat /dev/null > $Status
function startNodeMonitors
{
IPAddr=$1
DSPath=$2
ssh $IPAddr "${DSPath}/bin/ps-startMonitors ${ADDPAR}" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "Switch ON Monitor on $IPAddr ... ... FAIL." >>$Status
else
echo -e "Switch ON Monitor on $IPAddr ... ... Done!" >>$Status
fi
}
if $SLONLY ; then
DSLIST=($(get_mainDServs))
else
DSLIST=($(get_mainDServs -m))
fi
NDNUM=${#DSLIST[*]}
echo "In total, has $NDNUM nodes"
for ((NDIDX=0;NDIDX<$NDNUM;));do
node=${DSLIST[$NDIDX]}
IPAddr=${node%:*}
DSPath=${node#*:}
for((token=1;token<=$PS_PIPE_Width;token++)); do
if [ $NDIDX -gt $NDNUM ]; then
break
fi
if [ ! "${aJobs[$token]}" ] || ! kill -0 ${aJobs[$token]} 2>/dev/null; then
startNodeMonitors $IPAddr $DSPath &
aJobs[$token]=$!
let NDIDX++
break
fi
done
done
for ((token=1;token<=$PS_PIPE_Width;));do
if ! kill -0 ${aJobs[$token]} 2>/dev/null; then
let token++
fi
done
cat $Status | sort | cat -n
exit 0