Clustering

C shell based Cluster admin script

The following script is an example Admin Script that does the following.

  1. Shutdown the cluster
  2. Restart the cluster
  3. Check the status of the cluster
  4. Kills all lam Daemons
  5. Updates the cluster nodes
  6. Synchronizes and sets the cluster node time.

#!/bin/tcsh

if (${1} == "") then
echo 'This is the primary admin script for the cluster, you must be root and have '
echo 'admin privelegs and a ~/pss file to run it. the following comands are available '
echo
echo 'cladmin shutdown <start> <end> -- shuts down the indicated cluster nodes'
echo 'most likely you really want restart '
echo
echo 'cladmin restart <start> <end> -- this shuts down and restarts a range of nodes '
echo
echo '----- do not use shutdown and restart on node 1 under any circumstatnces ------'
echo
echo 'cladmin stat <start> <end> <procname> -- this performas a stat on the cluster nodes '
echo ' it gives all the procceses ofr just the <procname>'
echo
echo 'cladmin st <start> <end> -- this is joes short version of stat '
echo
echo 'cladmin killam <start> <end> -- this is an attempt to fix the lam system it may or may not work '
echo
echo
echo 'cladmin update <start> <end> "<Package name and location>" -- this wil install apple packages. '
echo

endif

 

if (${1} == "shutdown") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo shutdown -h now &
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

if (${1} == "restart") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo shutdown -r now &
@ num++
sleep 10
if ($num >$end) then
exit (0)
endif
end

endif

 

if (${1} == "stat") then
set num=$2
set end=$3
while ( $num )
echo "Jobs running on the following computer clnode${num}: "
if ($4 == "") ssh clnode${num} ps -arcux | grep -v "root \|nobody \|administ "
if ($4 != "") ssh clnode${num} ps -arcux | grep -v "root \|nobody \|administ " | grep $4

@ num++
if ($num >$end) then
exit (0)
endif
end

endif
if (${1} == "statp") then
set num=$2
set end=$3
while ( $num )
echo "Jobs running on the following computer clnode${num}: "
ssh clnode${num} ps -aucx | grep LWSN
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

if (${1} == "st") then
set num=$2
set end=$3
echo "Jobs running on the master node clnode${num}: "
ssh clnode${num} ps -arcux | grep -v "root \|nobody \|administ "
echo "Load level on each node:"
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} uptime
@ num++
if ($num >$end) then
exit (0)
endif
end
endif

if (${1} == "killlam") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo killall lamd
ssh clnode${num} sudo killall -HUP xinetd
ssh clnode${num} sudo killall -HUP sshd
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

if (${1} == "update") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo installer -verbose -pkg $4 -target /
@ num++
if ($num >$end) then
exit (0)
endif
end
endif

if (${1} == "time") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo timed
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

if (${1} == "timecheck") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} date&
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

if (${1} == "timekill") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo killall timed&
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

if (${1} == "timeset") then
set num=$2
set end=$3
while ( $num )
echo -n "clnode${num}:"
ssh clnode${num} sudo timed -F clnode1&
@ num++
if ($num >$end) then
exit (0)
endif
end

endif

About Me | Site Map | | ©2006 Eric Adint