Forum Discussion
Chris_Day_10331
Nimbostratus
Oct 04, 2005iRule for Server Testing
Good morning,
Please see attached doc.
Essentially, what we are trying to achieve is to be able to validate that a single server behind a VS is responding correctly. Ideally, we co...
Oct 04, 2005
Chris, I moved your post over to the iRules forum. Next time, if you could post iRules questions over there that would help you get a better response.
Also, the forums weren't configured to allow uploads of .doc files. I've modified that so you should be able to post your attachment (and I've bumped the size limit up to 100k).
Now, on to your question:
As for monitoring, iRules does not have the ability to test an application directly in the code. You will have to rely on either external monitors (if your errors are detected via HTTP content or network connectivity).
As for having iRules do some manipulation of the request uri then that has been covered many times here on the forum. Here's a sample on how you can build 2 classes, one for the host mapping and another for the node mapping.
*** String data groups ***
class host_mapping {
companyA.test.pnimedia.com companyA.pnimedia.com
companyB.test.pnimedia.com companyB.pnimedia.com
companyC.test.pnimedia.com companyC.pnimedia.com
}
class node_mapping {
web001 10.10.10.1
web002 10.10.10.2
web003 10.10.10.3
}
*** Begin iRule ***
when HTTP_REQUEST {
Search for host mapping in the lookup list
set new_host [findclass [HTTP::host] $::host_mapping " "]
if { "" ne $new_host } {
if mapping is found, replace the Host header
log local0. "Replacing host from [HTTP::host] to $new_host"
HTTP::header replace "Host" $new_host"
Pull out the node name as the first element of the uri
ie. /web001/foo/bar -> web001
set node_name [lindex [split [HTTP::uri] "/"] 1]
if { "" ne $node_name } {
Now look for the node address in the lookup list
log local0. "Searching for node: $node_name"
set node_addr [findclass $node_name $::node_mapping " "]
if { "" ne $node_addr } {
log local0. "Routing to node: $node_addr "
node $node_addr
} else {
log local0. "Didn't find node '$node_name' in lookup class"
}
} else {
log local0. "No node name passed in URI"
}
} else {
log local0. "Didn't find [HTTP::host] in lookup class"
}
}
There may be more elegant ways to extract the node out of the uri without making a list. I'll leave it to you to figure that optimization out.
Good luck!
-Joe
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