Technical Article

v.10 - New GTM iRules commands

GTM version 10 is here! With its arrival, GTM gets more than a fist-full of new iRules commands for you to add to the toolbox. In this article, we'll take a look at the command syntax and work through some examples.

whoami

Returns the server name for the local GTM. This example checks for client source and which GTM is handling the request so it can override the wideIP to serve up a specific host entry.

Returns the number of seconds the local GTM has been up. This can be useful for not answering queries until the GTM has been up for a set number of seconds, allowing it to get synchronized with the other GTM's in the group.

Returns the number or list of members in the referenced pool. This command is really flexible. Returns all pool members as a number or a list, or if you want only a certain state (blue, green, yellow, red, gray) you can specify that too.

Returns the number or list of pools in the wideIP. This command has the same options as members, just one step up the hierarchy. You can combine them to iterate through all the virtual servers under the wideIP:

Returns the persistence state value. You can enable/disable as arguments, so if you have a wideIP with persist enabled, you can now selectively disable (or selectively enable if persist is disabled globally):

This eliminates the need for this workaround described in the wiki, but keep in mind that there is no access to the persist data from the iRules, so other unique LDNS requests cannot be pinned to the same virtual server without another approach.

nodes_up [<virtual server name> | <ip address port>]

Returns the number of up nodes behind a virtual server. This is to the vip that members command is to the GTM pool, and the pools command is to the GTM wideIP. If the virtual server is blue, GTM interprets as green and the nodes_up value is 1, even if you have more functional servers in place and serving traffic. This command gives you the opportunity to make some changes to your selection if the virtual chosen is constrained on resources that other virtuals might not be. There is an issue passing variables or using memory lookups right now, but it is functional if you use the virtual name or specify literally the IP and port.

That concludes this look into the new GTM iRules commands. Users in the community are always discovering new and unique ways to use iRules in ways that were not originally intended, so I fully intend to see some real innovation in the coming months. Enjoy!