iRule: Logging lb failures
The question here was how to log a lb failure (no nodes available) but not on every connection. It would preferably log an error every 50 lb failures.
unRuleY responded with the following rule that will go a step further and create an array that will store counters for each pool. And then, for each pool, it will log only on the 50th lb failure.
when RULE_INIT {
# Initialize the counter to 0.
array set ::log_ctr { }
}
when LB_FAILED {
if { [LB::server addr] eq "" } {
set pool [LB::server]
if { not [info exists ::log_ctr($pool)] or $::log_ctr($pool) >= 50 } {
log "No nodes available - pool $pool"
set ::log_ctr($pool) 0
} else {
incr ::log_ctr($pool)
}
}
}
Click here for the original thread.
[Listening to: The Hanging Garden - The Cure - Staring at the Sea: The Singles (04:22)]
Published Jul 27, 2005
Version 1.0No CommentsBe the first to comment
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)