iRules should only ever execute on an active unit, so I am not sure this is necessary. Are you seeing otherwise?
There isn’t a way to run bigpipe commands from an iRule. I remember Unruley mentioning a bit of a hack you could use to determine the unit number from an iRule. I think this involved a shell script writing to a datagroup. If you wanted to get arbitrary, real time-ish data from a shell script, you could try this method.
"I remember Unruley mentioning a bit of a hack you could use to determine the unit number from an iRule. "
Do you know what this hack is? I am keen to find out as we are seeing duplicate log entries on a syslog server due to the irule being executed on the activ & standby BIG-IP’s.
The idea is that you’d run a bash or Perl script from cron on LTM which gets the failover status, writes the output to a file which is referenced in an external datagroup and then use iControl to force a reread of the datagroup contents. You could then access the datagroup from an iRule and check to see it returns active before calling HSL commands.
The external datagroup format is:
External Class Format:
class namevalue {
"name1" := "value",
}
As you don’t need a value, you could use:
class active_status_class {
“active”,
}
For 10.2.x you can use ‘bigpipe failover’ or ‘tmsh run /util bigpipe failover’ to get the failover status. For 11.0.x you can use ‘tmsh show /sys failover’
Here’s a Perl iControl example from Joe for updating the datagroup:
It would make sense for us to have a default TCL variable that gives the HA status of the unit in an iRule. You could open an RFE case with Support to request this. If you do, could you reply back with the RFE ID so others can pile on?