Forum Discussion
TayF5un
Nimbostratus
Jan 04, 2017irule static::debug
Hi everyone,
I am bit confused, when i interpret irule shown below.
Why should i use static::debug. Could you please explain the function of this.
when RULE_INIT {
set static::debug 0
...
VernonWells
Employee
Jan 04, 2017A few things to note:
-
It is global [1], so while it is common to see
, it's not best-practice to do so. The reason is, if you usestatic::debug
in more than one iRule, and set it to different values in each of the rules, the final value will apply to all iRules and will be essentially non-deterministic [2]. There are several ways to remedy this, but a common approach -- and the one I think is easiest -- is to simply choose a unique prefix for each iRule. So, if you have three rules that want to usestatic::debug
, you might usestatic::debug
,static::abc_debug
andstatic::def_debug
(okay, use something more meaningful thatstatic::ghi_debug
, etc.);abc_ -
These
commands will be evaluated on each connection. So, while the use of the "debug" value is useful when building or changing an iRule, I strongly recommend commenting these out (or removing them) for production. For complex rules, some people create an iApp which essentially inserts debugging into a rule (or uncomments existing statements) so that debugging can be "turned on" and "turned off".if { $static::abc_debug } { ... }
[1] To be completely pedantic, it is tied to a tmm, so if you were to change this or any
static:: scoped variable, the change would be visible only to other connections being processed on the tmm instance where the change was made. There is a valid and quite useful case for this, but 99% of the time -- and unless you really know what you're doing and why -- treat a static:: variable as a constant and don't change it.
[2] It will be the value in the last iRule loaded which attempts to set this value, but that ordering could change over time.
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