Forum Discussion
hooleylist
Oct 03, 2012Cirrostratus
Can you try this updated version of the script? If it works for you too I'll update the Codeshare example.
!/bin/bash
Handle a first-run situation
if [ ! -e /var/class/pool_member_status_list.class ]; then
touch /var/class/pool_member_status_list.class
fi
Grab the node list from bigpipe
nodelist=`b pool all |grep "POOL MEMBER" | awk '{sub(":any",":0",$4);print "\""$4"\","}' | sort`
for i in $nodelist; do
Get the service from the bigpipe output for the pool member
service=`echo $i | cut -f2 -d : - | sed s/\",// -`
Determine whether the service is a numeric value or not; if not, we'll look it up in /etc/services.
if [[ $service =~ ^[0-9]+$ ]] && (( 0 <= $service && $service < 65536 )); then
servicenumber=$service
else
servicenumber=`cat /etc/services | tr '\011' ',' | sed s/,,/,/ | grep "^$service,.*\/tcp" | cut -f2 -d, | cut -f1 -d/`
fi
Write it to a temp file in the class directory.
echo $i | sed s/$service\"\,/$servicenumber\"\,/ >> /var/class/pool_member_status_list.class.tmp.$$
done
Move the temp file to the active position.
mv /var/class/pool_member_status_list.class.tmp.$$ /var/class/pool_member_status_list.class
Only load the config to update with the new class file if I am in HA Active mode (avoids getting out of sync if
this happens on the Standby unit).
if [ "`cat /var/prompt/ps1`" == "Active" ]; then
b load
fi
exit 0
Thanks, Aaron