Hope someone can help me with this. I’m currently using GTM Version 10.2.1 and I have a wideIP setup with a pool that has two members. Member 1 is set to Priority 3 and Member 2 is set to Priority 1. Whenever the status of one of these members changes, I would like a script to run. Normally with Tcl I would use either open or exec but they’re both on the Disabled list. So how do I run a script that’s located at /var/scripts/
So far this is what I have for my iRULE
when LB_SELECTED {
if { [LB::status] eq “up” or “down”}{
}
}
Any and all help on this would be extremely gratefully appreciated.
I don’t think you want to do this with iRules. First, they are transactional and event-based, so using them as a warning trigger is difficult at best. Second, unless you want to do it via event logging or HTTP::retry, there is no real way to jump outside the iRule sandbox to execute something.
There are three ways you can get this done: iControl, on-box shell scripting, or TMSH scripting. With iControl, you would need to run a script from an external box, monitoring your selected pool on a regular basis, and taking action on any changes. The same is true of the other two methods, only they would both execute on-box.
The one I would use is probably TMSH. Here is an example of a monitor script:
Well, in the TMSH script I’m referencing, there’s no Cron job -- and it does not do exactly what you’re wanting, it’s just an example of how to do a “watch loop” in TMSH. There’s a delay in the script using a preset interval and “after” which will release the while loop every two seconds.
set interval 2
set delay [expr $interval * 1000]
...
after $delay
I have to admit, I’m just getting my sea legs on TMSH, so as far as starting the script on boot and creating notifications, I’m not sure where to head from here; maybe someone else with more TMSH experience can weigh in. But I do know that it this type of approach has one big advantage: it becomes part of the config file -- which a regular shell script copied up to the unit will not.
You could potentially implement this type of logic by calling a custom script from the user_alert.conf file when a member is marked down. See this post for details: