For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

momo_84865's avatar
momo_84865
Icon for Nimbostratus rankNimbostratus
May 15, 2014

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

  • 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
    
  • Hi Momo, What scripting language are you using? For example: Powershell, an API, PHP, ? I'm really a newbee. Thanks