Forum Discussion
Tony_Hobson_189
Jun 10, 2015Nimbostratus
Variable Scope in iRules
Hello
I’ve got a quick question regarding variables in iRules. I would like to set variables to use across different functions in an iRule but struggling to find out what I need to do to make a va...
Tony_Hobson_189
Jun 10, 2015Nimbostratus
Hi nitass
Thanks for the reply. It looks like I can use static global variables instead:
From https://devcentral.f5.com/articles/-the101-irules-101-variables
Set a static variable value, which will exist until config reload, living outside of the scope of any one particular
set static::logserver "10.10.1.145"
Reference that static variable just as you would any other variable from within any iRule
log $static::logserver "This is a remote log message"
The articles says: You can effectively set static global variable data in the static namespace without breaking CMP, and thereby not decreasing performance. To do so simply set up your static::varname variables, likely in RULE_INIT
How do I invoke RULE_INIT and set variables in here?
Thanks
Tony
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