static

Description

A namespace for creating global variables to hold constant values in a CMP-compatible fashion. This namespace is intended only for use with values that will not change. While it is possible to alter the value of a global variable in the static namespace, this value will not be propagated to other CMP nodes in the system. Therefore, doing so may lead to unexpected results. If you need to share information across CMP nodes, you should use the session or table commands instead.
Note: When you use the static namespace the variable is available to all iRules on the box. See Examples below.

Syntax

static::varname

In GTM, you must fully qualify the variable name, i.e.:
::static::varname

static::varname

  • References the global variable named varname, which should hold a constant value

Examples

when RULE_INIT {
  # Change to "1" to enable debugging log statements
  set static::debug 0
}
when HTTP_REQUEST {
  if { $static::debug != 0 } {
    log local0. "Got HTTP request: [HTTP::host][HTTP::uri]"
  }
  switch -glob [string tolower [HTTP::host]] {
    "*.foo.com" { pool foo_com_pool }
    "*.bar.com" { pool bar_com_pool }
    default     { pool big_pool }
  }
  if { $static::debug != 0 } {
    log local0. "Using pool [LB::server pool]"
  }
}

Note that when you use the static namespace the variable is available to all iRules on the box. In the above example, if you use “$static::debug” for every iRule, it will enable debugging for all iRules. As such define a static variable that will be unique to each iRule to avoid this problem.