Forum Discussion

Livius's avatar
Livius
Icon for Altostratus rankAltostratus
Nov 06, 2017

Check number of active pool members when HTTP request incoming to a VS contains a specific string

Hi,

 

I need to create an iRule which checks the number of active pool members if an incoming HTTP request contains "test" string and report either 200 or 400 error message based on pool availability. I was thinking about the following iRule code :

 

when HTTP_REQUEST {log local0.  "HTTP request"
if { [HTTP::path] ends_with "test" }  {
  log local0. "HealthCheck - test_p got [active_members test_p] active members"
if {[active_members test_p] > 1 } {
   HTTP::respond 200 content "OK" 
} else {
   HTTP::respond 404 "Not found"
   TCP::close
   event disable
}
}
}

Does that look OK ? is there any way to make it more generic, without specifying pool name, so I can apply it to multiple virtual servers?

 

Thanks in advance!

 

2 Replies

  • If you have naming standard based on virtual server, you could use pool name as [virtual]_pool.

     

  • You could potentially make it very generic ... :) but that would make the code complex. For example, you could "query" for the actual names of the pools attached to a VS, put them in a variable and then use the pool command accordingly. Or maybe an array ...

     

    I haven't tried this ... just giving some ideas. Assuming this would be even possibily, it would defenitely make the code more complex that need be. Nothing wrong with copy&paste and just changing the pool name....