|
@@ -1,6 +1,6 @@
|
|
|
print_usage(){
|
|
|
echo
|
|
|
- echo "script usage: $(basename $0) [-n node] [-a] [-1] [-2] [-h] " >&2
|
|
|
+ echo "script usage: $(basename $0) [-s node] [-k node] [-m] [-h] " >&2
|
|
|
echo "type: '$(basename $0) -h' for help"
|
|
|
return 0
|
|
|
}
|
|
@@ -10,10 +10,9 @@ print_help(){
|
|
|
echo "$(basename $0): a useless script"
|
|
|
echo
|
|
|
echo "options:"
|
|
|
- echo " -n Print the hostname of the specified node"
|
|
|
- echo " -a Print the hostname of all nodes"
|
|
|
- echo " -1 Print the hostname of all nodes in LCM1"
|
|
|
- echo " -2 Print the hostname of all nodes in LCM2"
|
|
|
+ echo " -s <node> Start the service on the specified node"
|
|
|
+ echo " -k <node> Kill the service on the specified node"
|
|
|
+ echo " -m Monitor function: display all the nodes on which the service is runnig"
|
|
|
echo " -h Print this help message"
|
|
|
command_parsed=1
|
|
|
|
|
@@ -21,27 +20,74 @@ print_help(){
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
-call_node(){
|
|
|
- printf "$1 says: "
|
|
|
- ssh $1 'hostname' #come si fa a non mostrare il messaggio?
|
|
|
+start_node(){
|
|
|
|
|
|
+ ssh $1 'sleep 300 &> /dev/null &' #come si fa a non mostrare il messaggio?
|
|
|
+ echo "Service started on $1"
|
|
|
|
|
|
command_parsed=1
|
|
|
|
|
|
}
|
|
|
|
|
|
-call_1(){
|
|
|
+start_1(){
|
|
|
for i in {0..12}
|
|
|
do
|
|
|
- call_node ${LCM1[i]}
|
|
|
+ start_node ${LCM1[i]}
|
|
|
done
|
|
|
command_parsed=1
|
|
|
}
|
|
|
|
|
|
-call_2(){
|
|
|
+start_2(){
|
|
|
for i in {0..14}
|
|
|
do
|
|
|
- call_node ${LCM2[i]}
|
|
|
+ start_node ${LCM2[i]}
|
|
|
done
|
|
|
command_parsed=1
|
|
|
}
|
|
|
+
|
|
|
+monitor(){
|
|
|
+
|
|
|
+ echo "Service running on:"
|
|
|
+ for i in {0..12}
|
|
|
+ do
|
|
|
+ #printf "${LCM1[i]}: "
|
|
|
+ ssh ${LCM1[i]} 'ps aux | grep "sleep 300" | grep -v grep' > /dev/null
|
|
|
+ if [ $? -eq 0 ]; then
|
|
|
+ echo ${LCM1[i]}
|
|
|
+ fi
|
|
|
+ done
|
|
|
+ for i in {0..14}
|
|
|
+ do
|
|
|
+ ssh ${LCM2[i]} 'ps aux | grep "sleep 300" | grep -v grep' > /dev/null
|
|
|
+ if [ $? -eq 0 ]; then
|
|
|
+ echo ${LCM1[i]}
|
|
|
+ fi
|
|
|
+ done
|
|
|
+
|
|
|
+ command_parsed=1
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+kill_process(){
|
|
|
+
|
|
|
+ ssh $1 'pkill sleep' #pericoloso (testato e funzionante con pkill xfreerdp)
|
|
|
+
|
|
|
+ command_parsed=1
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+kill_1(){
|
|
|
+ for i in {0..12}
|
|
|
+ do
|
|
|
+ kill_process ${LCM1[i]}
|
|
|
+ done
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+kill_2(){
|
|
|
+ for i in {0..14}
|
|
|
+ do
|
|
|
+ kill_process ${LCM2[i]}
|
|
|
+ done
|
|
|
+
|
|
|
+}
|