Forum Discussion
Bret_McGinnis_1
Nimbostratus
Sep 09, 2005Clock time
I want to track the length of time that a pool is down and send a syslog message with the downtime in hours:minutes:seconds format. I'm still not that familiar with TCL and having some difficulty usin...
unRuleY_95363
Sep 10, 2005Historic F5 Account
Well, first, I would not recommend to heavily using the clock command until 9.2 as it does have a potential performance impact (however, it may not effect you enough to be concerned about it).
The main command to use is [clock seconds] which will return you the number of seconds since epoch. You can use this to easily compute the number of seconds that a pool member has been down. To then format this into something more human readable you would use the [clock format] command. Eg:
when RULE_INIT {
array set ::down_nodes { }
}
when LB_FAILED {
set cur_time [clock seconds]
set server [LB::server addr]
Has this member been down for more than one request
if { [info exists ::down_nodes($server)] } {
set delta [expr $cur_time - $::down_nodes($server)]
Start logging after the member has been down for more than 60 secs
if { $delta > 60 } {
log local0. "Pool member [LB::server] down [clock format $delta -format {%H:%M:%S}]"
}
}
set ::down_nodes($server) $cur_time
}
when LB_SELECTED {
Clear out a down node that is now up
if { [info exists ::down_nodes([LB::server addr])] } {
unset ::down_nodes([LB::server addr])
}
}Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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