Forum Discussion
Ulf_Zimmermann_
Nimbostratus
Sep 11, 2009Checking for file from iRule?
I am looking at implementing a downtime pool for something like 50-60 virtual servers at a time. My current idea would involve an iRule always applied to these virtual servers which as the first action checks for a file locally on the BigIP. If it exists the rule would send requests to the downtime pool, otherwise it would just exit.
This would allow us to give the application people an account, they would do a touch via a script on the file system and when the downtime is done, they would remove it.
Is this possible with iRules?
- The_Bhattman
Nimbostratus
Are you talking about moving your connections to a single pool for maintenance? - Ulf_Zimmermann_
Nimbostratus
The downtime rule would allow our internal IPs still to go to the normal pool, while external IPs should get redirected to another virtual server or to the downtime pool. - Ulf_Zimmermann_
Nimbostratus
Reading up on TCL, it seems what I would be looking for is "file exists" which is a disabled command. - The_Bhattman
Nimbostratus
That would be correct that you can't access the file system directly with iRules. One way would be to write up something using iControl or possibly using an indirect method with iRuleswhen CLIENT_ACCEPTED { if { (![IP::address [IP::client_address]/24 eq "192.168.1.0") and ($::downtimepool eq "DOWN" } { pool pool_downtime } }
when CLIENT_ACCEPTED { set downtimepool "UP" if { (![IP::address [IP::client_address]/24 eq "192.168.1.0") and ($:downtimepool eq "DOWN" } { pool pool_downtime } }
when CLIENT_ACCEPTED { if { (![IP::address [IP::client_address]/24 eq "192.168.1.0") and (![active_members dummy_pool] < 1) } { pool pool_downtime } }
- Another options would be to use a Statistics Profile and have the iRule reference the contents of a variable in it. You could then write a perl script on the BIG-IP that either talks iControl to configure the stats profile entry or uses bigpipe. When I get back into the office on Monday I'll whip up a prototype for you.
- hoolio
Cirrostratus
Another option would be to use priority groups and a health check which looks for a file on the server which is available over HTTP(S). The monitor would check that file for an UP message and mark the pool member up. If the server admin modifies the file or the web server is down, the file wouldn't be served and the monitor would mark the pool member down. You could use priority groups on the pool so that your normal production servers would handle all requests unless some or all of them were down. In that case, the lower priority pool members would be used. - Ulf_Zimmermann_
Nimbostratus
Using the suggestions posted in reply to my posts, here is what I have come up with so far:when HTTP_REQUEST { if { [PROFILE::exists serverssl] == 1 } { set downtimepool "Downtime-SSL" set downtimemember "10.21.67.103" set downtimeport "16443" log local0. "Virtual server has SSL server profile" } else { set downtimepool "Downtime-NonSSL" set downtimemember "10.21.67.103" set downtimeport "16080" log local0. "Virtual server has no SSL server profile" } if { ([LB::status pool $downtimepool member $downtimemember $downtimeport] eq "up") and (![IP::addr [IP::client_addr]/16 equals 10.21.0.0]) } { pool $::downtimepool log local0. "Sending request to pool $downtimepool" } }
- The_Bhattman
Nimbostratus
Put in a log statement to see what is contained in the profile.when HTTP_REQUEST { log local0. "server SSL profile enabled: [PROFILE::serverssl name]" if { [PROFILE::exists serverssl] == 1 } { set downtimepool "Downtime-SSL" set downtimemember "10.21.67.103" set downtimeport "16443" log local0. "Virtual server has SSL server profile" } else { set downtimepool "Downtime-NonSSL" set downtimemember "10.21.67.103" set downtimeport "16080" log local0. "Virtual server has no SSL server profile" k } if { ([LB::status pool $downtimepool member $downtimemember $downtimeport] eq "up") and (![IP::addr [IP::client_addr]/16 equals 10.21.0.0]) } { pool $::downtimepool log local0. "Sending request to pool $downtimepool" } }
- Ulf_Zimmermann_
Nimbostratus
I think my problem might be this part: - Ulf_Zimmermann_
Nimbostratus
Ok, I think this is working as I intend it to work:when HTTP_REQUEST { set downtimepool "Downtime-NonSSL" set downtimemember "10.21.67.103" set downtimeport "16080" set downtime 0 if { ([LB::status pool $downtimepool member $downtimemember $downtimeport] eq "up") and (![IP::addr [IP::client_addr]/16 equals 10.21.0.0]) } { pool $downtimepool log local0. "Sending request to pool $downtimepool" set downtime 1 } } when SERVER_CONNECTED { if { $downtime == 1 and [PROFILE::exists serverssl] == 1 } { set disable "SSL::disable serverside" catch {eval $disable} log local0. "Disabled server side SSL" } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects