Forum Discussion
custom script to turn on / off of nodes for bigip v11
Dear all,
I created a custom script to handle the batch process to turn on / off for a desire nodes, it work with the config file that store pool name and node ip:port with the below format. when i execute the script, it return the below error. Can anybody kindly help hand of it? many thanks.
cat testing
my-testing-pool 10.0.0.1%3:80
./nodemgmt.sh status testing1
testing: line 1: testing-80-pool: command not found
!/bin/sh
prog="nodemgmt"
enable() { change_status "user-enabled" "user-up" }
disable() { change_status "user-disabled" "user-down" }
status() { show_status }
show_status() { for pool in $(seq 0 $((${POOL_ARRAY[@]} - 1))) do p=${POOL_ARRAY[$pool]} m=${MEMBER_ARRAY[$pool]} tmsh show ltm pool $p members {$m} done }
change_status() { for pool in $(seq 0 $((${POOL_ARRAY[@]} - 1))) do p=${POOL_ARRAY[$pool]} m=${MEMBER_ARRAY[$pool]} tmsh modify ltm pool $p members modify { $m { session $1 state $2 } } echo "$1 pool $p, member $m $2, status: $?" done }
case "$1" in user-enabled) . $2 enable ;; user-disabled) . $2 disable ;; status) . $2 status ;; *) echo $"Usage: $prog {user-enabled|user-disabled|status} config file " RETVAL=1 esac
exit $RETVAL
6 Replies
- Kevin_Stewart
Employee
A little different, but I think this should work:
!/bin/sh prog="nodemgmt" enable() { change_status "user-enabled" "user-up" } disable() { change_status "user-disabled" "user-down" } status() { show_status } show_status () { while read line do a=( $line ) p=${a[0]} m=${a[1]} tmsh show ltm pool $p members {$m} done < $data } change_status() { while read line do a=( $line ) p=${a[0]} m=${a[1]} tmsh modify ltm pool $p members modify { $m { session $1 state $2 } } echo "$1 pool $p, member $m $2, status: $?" done < $data } case "$1" in user-enabled) data=$2 enable ;; user-disabled) data=$2 disable ;; status) data=$2 status ;; *) echo $"Usage: $prog {user-enabled|user-disabled|status} config file " RETVAL=1 esac exit $RETVAL - the_real_deal_1
Nimbostratus
Thanks a bunch!
- the_real_deal_1
Nimbostratus
Kevin Stewart, what is your script written in? I'm really a newbee at this. :)
- Kevin_Stewart
Employee
It's Bash shell.
- the_real_deal_1
Nimbostratus
What are you using to script this? - the_real_deal_1
Nimbostratus
Hi Momo, What scripting language are you using? For example: Powershell, an API, PHP, ? I'm really a newbee. Thanks
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com