Forum Discussion
James_Thomson
Employee
Jul 25, 2005Question about No Nodes Available Rule
I recently posted this rule to emulate the 4.X feature that logged No Nodes available.
when LB_FAILED {
if { [LB::server addr] eq "" } {
log "No nodes available - pool [LB::server]"
}
}
Can anyone think of a way to make it so it does not log every single time a connection hits? Maybe only every 50 times or something. I guess I just need to figure out how to set a variable, increment by 1 every connection and then only log when it equals 50.
Any easier way to do this that you can think of?
- You could use a global variable and increment it's value for each request. When it reaches your threashold then log your message and reset it to zero.
when RULE_INIT { Initialize the counter to 0. set ::log_ctr 0 } when HTTP_REQUEST { Increment the counter incr ::log_ctr If counter has reached 50, log the message and reset counter if { $::log_ctr == 50 } { log "Rule has been called $::log_ctr times" set ::log_ctr 0 } }
set my_ns::log_ctr 0
- unRuleY_95363Historic F5 AccountImproved version -
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) } } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects