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

yuni's avatar
yuni
Icon for Altostratus rankAltostratus
Jul 16, 2019
Solved

iRule syntax error

Hello

Could you please help me correcting my following iRule?

I am newbie to iRules, so I couldn't figure out the error.

when HTTP_REQUEST {
  switch -exact -- [HTTP::uri] contains "/info/capacity" {
    if {[active_members pool_test1 ] >0 } {
      pool pool_test1 
    } else {
      pool pool_sorry
    }
 } "/execution/v1" {
    if {[active_members pool_test2 ] >0 } {
      pool pool_test2
    }   
  }  else {
    pool pool_sorry2
  }
}

ERROR

01070151:3: Rule [/Common/test_iRules] error: /Common/test_iRules:2: error: [undefined procedure: /info/capacity][/info/capacity]
/Common/test_iRules:8: error: [undefined procedure: /execution/v1][/execution/v1]
/Common/test_iRules:12: error: [undefined procedure: else][else]

I try to do this 

contain "/info/capacity" & active_members pool_test1 >0 → pool_test1 

contain "/info/capacity" & active_members pool_test1 <0 → pool_sorry

contain "/execution/v1" & active_members pool_test2 >0 → pool_test2

contain "/execution/v1" & active_members pool_test2 <0 → pool_sorry2

Thanks 

  • You're syntax is slightly off, try this

    when HTTP_REQUEST {
        switch [HTTP::uri] {
            "/info/capacity" {
                if {[active_members pool_test1 ] >0 } {
                    pool pool_test1 
                } else {
                    pool pool_sorry
                }
            }
            "/execution/v1" {
                if {[active_members pool_test2 ] >0 } {
                    pool pool_test2
                } else {
                    pool pool_sorry2
                } 
            }
        }
    }

2 Replies

  • You're syntax is slightly off, try this

    when HTTP_REQUEST {
        switch [HTTP::uri] {
            "/info/capacity" {
                if {[active_members pool_test1 ] >0 } {
                    pool pool_test1 
                } else {
                    pool pool_sorry
                }
            }
            "/execution/v1" {
                if {[active_members pool_test2 ] >0 } {
                    pool pool_test2
                } else {
                    pool pool_sorry2
                } 
            }
        }
    }
    • yuni's avatar
      yuni
      Icon for Altostratus rankAltostratus

      Thank you so much, Lee Sutcliffe

      ​It works well!!