Forum Discussion

Bhanu_9561's avatar
Jun 14, 2013

Mark the status of a virtual server down

Hi all,

 

 

Is there a way to mark a Virtual Server offline using an iRule?

 

 

My requirement is that the Virtual Server should be marked offline by the iRule when a certain condition is met, whcih will be reflected at the GT level.

 

Once the VS is marked offline it will become offline in the GTM as well.

 

 

Thanks for your help!

 

1 Reply

  • I do not believe there is a way to mark a virtual server down within an iRule.

     

     

    You can, however, use an iCall in 11.4. Here is a very crude example:

     

     

    1. Create a script (ex. vi /var/temp/virtual_down.conf)

     

    sys icall script virtualdown {

     

    app-service none

     

    definition {

     

    exec tmsh modify / ltm virtual my_test_vs disabled

     

    }

     

    description none

     

    events none

     

    }

     

    sys icall handler triggered virtualdown {

     

    script virtualdown

     

    subscriptions {

     

    virtualdown {

     

    event-name virtualdown

     

    }

     

    }

     

    }

     

     

    2. Merge this script into the config:

     

    tmsh load sys config merge file /var/tmp/virtual_down.conf

     

     

    3. Modify /config/user_alert.conf:

     

    alert local-http-virtualdown "trigger:virtualdown:my_test_vs" {

     

    exec command="tmsh generate sys icall event virtualdown"

     

    }

     

     

    4. Modify your iRule to generate a syslog statement at the appropriate time:

     

    log local0. "trigger:virtualdown:my_test_vs"

     

     

    Whenever the iRule generates this alert the iCall will be triggered and consequently disable the virtual server. Here are some parting thoughts:

     

    1. Needless to say, you must make ABSOLUTE sure that you're calling this iCall for the right reason. A mistake in logic can easily turn it into a denial of service.

     

    2. I haven't quite figured out the parameter syntax yet, though the various wiki pages say otherwise. So in this case I'd have to create a separate iCall handler for each virtual server.