cancel
Showing results for 
Search instead for 
Did you mean: 
greeblesnort
Nimbostratus
Nimbostratus

Problem this snippet solves:

After looking at several of the other excellent monitoring code snippets and talking to my developers, there wasn't anything that I could just pull out and modify a little for our needs. So, I wrote my own to provide a fairly low cost alternative to return either the number of active/total pool members in a pool, or as a per server status monitor. Some of the inner workings are plagarized from other monitoring ideas around DevCentral...

We're looking at automating not only the server and pool generation, but also the monitoring that gets applied to the services presented. To do so, we need to be able to set an arbitrary threshold of, for example, 66%, and then, based on that threshold and the current pool status, decide whether or not to wake people up or not.

How to use this snippet:

user@ws ~/working/irule $ curl http://f5.alpha.a.svc.cfx?pl=dvlp_oops_pl 1:3

user@ws ~/working/irule $ curl "http://f5.alpha.a.svc.cfx?pl=dvlp_oops_pl&detail=1" 192.168.126.102 DOWN
192.168.126.101 DOWN
172.18.47.101 UP

Code :

when HTTP_REQUEST { 
if { ([URI::query [HTTP::uri] pl ] ne "")  } { 
set pool [URI::query [HTTP::uri] pl]
        set response "Pool Status for $pool [clock format [clock seconds]]"
if { [catch { nodes $pool }] } {
append response "

INVALID REQUEST

Submitted name for an invalid or empty pool" HTTP::respond 418 content $response "Content-Type" "text/html" return } set allnodes [nodes -list $pool] set activenodes [active_members -list $pool] if { ([URI::query [HTTP::uri] detail ] eq "1") } { foreach node $allnodes { if {[string match "*$node*" $activenodes] > 0 } { append response "$node UP" } else { append response "$node DOWN" } } } else { append response "[active_members $pool]:[nodes $pool]" HTTP::respond 200 content $response "Content-Type" "text/html" return } } else { set response "Pool Status [clock format [clock seconds]]" append response "

INVALID REQUEST

usage: pl=/partition/pool_name\[&detail=1\]e.g., http://f5.alpha.a.svc.cfx?pl=/Common/dvlp_oops_pl&detail=1" HTTP::respond 418 content $response "Content-Type" "text/html" return } append response "" HTTP::respond 200 content $response "Content-Type" "text/html" }
Version history
Last update:
‎17-Mar-2015 13:08
Updated by:
Contributors