Forum Discussion
James_Flood_401
Nimbostratus
Jun 26, 2007Maintenance iRule Issue
I'm trying to use the iRule below to allow some of our web server developers be able to up and down a single node in a pool via simple input to a uri. I used the Maintenance iRule that was recently mailed in an F5 Tech Tip as my basis but seem to have something buggy in my coding someplace. My web_maintenance statistics profile has a single field of "hostname" (minus quotes). The only parts that actually appear to return any data are the "/disable*" without any additional input after, and the "/usage". Any input is appreciated..thanks in advance.
when HTTP_REQUEST {
set TITLE "Web Maintenance"
set PROFILE_NAME "web_maintenance"
switch -glob [string tolower [HTTP::uri]] {
"/disable*" {
set params [split [HTTP::uri] "/"]
if { [llength $params] < 3} {
HTTP::respond 200 content "
$TITLE
Usage: http://[HTTP::host]/disable/host
"
} else {
STATS::set $PROFILE_NAME "hostname" [lindex $params 2]
HTTP::respond 200 content "
$TITLE
Maintenance host is downed
"
}
}
"/enable" {
STATS::set $PROFILE_NAME "hostname" 0
HTTP::respond 200 content "
$TITLE
All Hosts enabled
"
}
"/check" {
set downhost [STATS::get $PROFILE_NAME "hostname"]
HTTP::respond 200 content "
$TITLE
Currently $downhost is down for maintenance
"
}
"/usage" {
HTTP::respond 200 content "
$TITLE
Usage: http://[HTTP::host]/\[command\]
/disable/host - down host /enable - enable all hosts /check - check downed hosts /usage - display this message
"
}
default {
set hostdown [STATS::get $PROFILE_NAME "hostname"]
if {$hostdown eq "web1"} {
use node 192.168.0.1 80
} elseif { $hostdown eq "web2" } {
use node 192.168.0.2 80
} else {
use pool http_192_168_0.p }
}
}
}
- Colin_Walker_12Historic F5 AccountIt looks like the only two cases in the switch that are returning results are those that don't use the STATS:: commands. Are you getting any info in your /var/log/ltm file that shows an issue when trying to execute those commands?
- James_Flood_401
Nimbostratus
Just wanted to give everyone a follow up. First I explicitly used the profile name in each instance where it was referenced to get away from setting the variable. Second I removed the double quotes when setting or getting the value from my statistics profile.
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