Forum Discussion

lostnytechie_55's avatar
lostnytechie_55
Icon for Nimbostratus rankNimbostratus
Apr 15, 2011

Node Status change to trigger Script

Hi All,

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.

 

Thanks

 

Sam

 

6 Replies

  • 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:

     

     

    http://devcentral.f5.com/wiki/default.aspx/tmsh/WatchPools.html

     

     

    Hope this gets you started!
  • Joel,

     

    Thanks for the quick reply! I was kind of afraid you were going to say that. So with the TMSH script, what time interval are you using for the cron?

     

    Thanks

     

    Sam
  • 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:

     

     

    Generic command in user_alert.conf

     

    http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=55956&ptarget=56007

     

     

    Aaron

     

  • I used user_alert.conf to trigger an external script. It was the simplest and easiest solution once i figured out how it works.
  • See http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/44/aft/1178752/showtab/groupforums/Default.aspx