iRule Maintenance Windows
A fun, but not well known, feature on BIG-IP is the Statistics Profile. This tech tip is the second in a series on how the Statistics Profile and iRules, when working together, can save time, product...
Published Apr 10, 2007
Version 1.0DeVon_Jarvis
Nov 10, 2008Nimbostratus
I tried to use part of this code to create an static outage window iRule this weekend. The problem is, there is a bug in this code.
When this line executes:
set cur_time [expr [expr [lindex $l 1]*100] + [lindex $l 2]]
It fails if the hour or minute is 08 or 09. The problem is, TCL assumes any string that starts with a '0' is octal, and 08 and 09 are invalid octal strings!
There are 2 options. Either use string manipulation or regexp to trim the zeros. I chose the string manipulation, thinking it would be faster. I didn't time it out though...
Here is the "fixed" code:
set cur_day [lindex $t_array 0]
set cur_hour [string trimleft [lindex $t_array 1] 0]
if { ![string length $cur_hour] } { set cur_hour 0 }
set cur_min [string trimleft [lindex $t_array 2] 0]
if { ![string length $cur_min] } { set cur_min 0 }
set cur_time [expr ( $cur_hour * 100 ) + $cur_min]
Hope this helps someone out there!