"easy" pool status from external monitor source

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" DOWN DOWN UP

Code :

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 "


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 "


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" }
Published Mar 17, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment