Operating System - Linux
1829119 Members
1975 Online
109986 Solutions
New Discussion

selecting a node to run checks from a row

 
SOLVED
Go to solution
Klaas D. Eenkhoorn
Regular Advisor

selecting a node to run checks from a row

All,

KSH scripting question:
I whant to run a checkscript on a mc/sg node to check the status of the packages of the cluster. I have a list of nodes in my script in an environment variable like 'NODES="hp1 hp2 hp3' and i like to check these nodes for availability to execute my checkscript with remsh.

What would be the code to do this selection process, first availible in line is fine with me.

Thanks in advance,

Klaas Eenkhoorn
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: selecting a node to run checks from a row

I'm not quite sure I understand what you want. If you have: NODES="hp1 hp2 hp3"
You can do:
for node in $NODES; do
checkscript ...
done

Or do you want something to check if the node is ok enough to do remsh?
Klaas D. Eenkhoorn
Regular Advisor

Re: selecting a node to run checks from a row

Yes, one of the nodes that responds is OK enough to do remsh.
It is not my intension to run the script on all the nodes. The first one availible is fine.

Kl@@s
Dennis Handly
Acclaimed Contributor
Solution

Re: selecting a node to run checks from a row

>The first one availible is fine.

for node in $NODES; do
checkscript ...
if [ $? -eq 0 ]; then
remsh $node ...
break
fi
done

Basically you will have add some code to detect if the machine is up. (One possible check is to do remsh $node -n uname -a.)

If it is, you can do the real remsh and the break.
Peter Godron
Honored Contributor

Re: selecting a node to run checks from a row

Klaas,
you can do:
#!/usr/bin/ksh
NODES="hp1 hp2 hp3"
for node in $NODES; do
remsh $node -l userid -n "ls" 2> /dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo "$node ok"
exit
else
echo "$node failed"
fi
done
Klaas D. Eenkhoorn
Regular Advisor

Re: selecting a node to run checks from a row

Well we have a winner . .
Dennis, thanks for the smart thinking.
Indeed after the first succesfull response from a host in the list, the status of the packages of that cluster are retreived and the main checkscript continues with other checks as i want it to be.

Now this results in the fact that the first available clusternode gives me the status of the packages even if one node is down.
That was what i wanted.

Klaas