vADC Forum

Reply
Occasional Contributor
Posts: 11
Registered: ‎02-10-2014
Accepted Solution

Enable a Rule from TrafficScript or External Program

Hi, Is it possible to enable or disable a rule by a TrafficScript (some other rule) or external program.

Infact my requirement is this. - I need to health check the DB periodically and if DB fails, I need to redirect requests to a maintenance page.

In order to monitor the DB, I thought of writing an external program monitor which emits a custom-event if DB fails. Then I thought of writing a custom Alert/Action which is triggered by that custom-event and this action enables the maintenance page rule. Is this approach correct? Is there a better way for achieving the same?

Thanks in Advance.

Contributor
Posts: 29
Registered: ‎10-19-2013

Re: Enable a Rule from TrafficScript or External Program

you are able to disable a rule from external e.g. through zcli program.

but nevertheless, imho the best way to achieve what you want would be a health-check within a pool.

Health Checks are done via nodes (which is normally not your DB Server), so what we've done is creating a small page within our app-server (=node), this page just checks if DB is running, and returns OK/NOK. And we implemented a custom-healthcheck, calling this page via http request, and checking if return body is OK.

If there is a DB-Problem, all nodes will be disabled automatically, and you can do something different through trafficscript "pool.activenodes" function (e.g. showing maintenance via .http.sendresponse)

Occasional Contributor
Posts: 11
Registered: ‎02-10-2014

Re: Enable a Rule from TrafficScript or External Program

Appreciate if you could explain the following further.

"And we implemented a custom-healthcheck, calling this page via http request, and checking if return body is OK. If there is a DB-Problem, all nodes will be disabled automatically,.."


"custom-healthcheck" here means a custom health monitor which will run periodically? or a rule applied to the virtual server?

Also cold you please provide some links/ resources on how to enable/ disable rules from external programs/ other scripts?

Contributor
Posts: 29
Registered: ‎10-19-2013

Re: Enable a Rule from TrafficScript or External Program

we are using a http-healthcheck (Pools - Health Monitoring),

e.g. check your  nodes via   "/checkdb.php" (depending on your environment php maybe not suitable).

this php-script checks DB Connectivity, and returns OK/NOK

(we are not using php, so i can't provide a example, our healthcheck is part of our own application)

within the health-monitor, just define the "body_regex:" as "OK".

If you have setup this, STM will check your nodes every few seconds if this URL still returns OK, if not, the node will be marked as failed.

then, within a rule (assigned to your vserver), you can check, if nodes for your pool are available

if (pool.activenodes("yourpoolname") < 1 {

http.sendresponse(....your maintenance message);

}

if you want to use zcli, there is full documentation with functions...

Highlighted
Occasional Contributor
Posts: 33
Registered: ‎12-10-2012

Re: Enable a Rule from TrafficScript or External Program

If you really need to have external control of rules in Stingray, you should be able to set up a script fairly easily with Python and FlyScript - check out the FlyScript pages on: https://splash.riverbed.com/community/product-lines/flyscript

There are a few predefined scripts already in the Stingray module, including:

change_rule(self, vserver, rule, enable=True, request=True, response=True);

If you want to create something more specific, you can see how this constructs a JSON request to access the REST API for Stingray. There is detailed documentation on the REST API on the Stingray download pages:

https://support.riverbed.com/content/support/software/stingray/traffic-manager.html

Occasional Contributor
Posts: 11
Registered: ‎02-10-2014

Re: Enable a Rule from TrafficScript or External Program

Hi Jochen Maurer,

Appreciate if you could calrify the following.

As you said:

"If you have setup this, STM will check your nodes every few seconds if this URL still returns OK, if not, the node will be marked as failed.

then, within a rule (assigned to your vserver), you can check, if nodes for your pool are available

if (pool.activenodes("yourpoolname") < 1 {

http.sendresponse(....your maintenance message);

}

"


However I saw a configuration under Virtual Server > Connection Management > Connection Error Settings:

that we can configure an error page. I'm not quite sure whether configuring an error page (i.e. maintanace-page.html) here has the same effect as doing like the following

if (pool.activenodes("yourpoolname") < 1 {

http.sendRedirect("maintanace-page.html");

}


Could you please shed some light on this

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.

Click to Register
Download FREE NVMe eBook