Forum Discussion
Simon_Wright_85
Nimbostratus
Jul 13, 2007iRule failing on earlier version of Big IP
Hi all
I am using the following iRule on an LTM running 9.4.0 without any problems but as soon as i use it on one thats running 9.2.3 i end up getting problems.
It compiles fine and i have made sure the correct Data Groups and Statistics Profiles are present. I have added .asp and .asmx to be included in the active stats but i get a page cannot be displayed message when i access and asp page. Strangely enough an aspx page will work with out any problems.
Am i trying to use functionality in the rule that is not compatible with 9.2.3?
many thanks in advance
Simon
when HTTP_REQUEST {
Set the variable names in one place.
set ::StatProfileName Test_Stats
Set the the start time of the request.
set t0 [clock clicks -milliseconds]
Load the list of IP addresses to identify monitoring servers.
set excludeIPStat [matchclass [IP::client_addr] equals $::Test_StatsIPExclude]
Check if the request comes from an monitoring server.
if { 0 != $excludeIPStat}
{
The request is from a monitoring server so it is for monitoring content.
set ::page_type 2
}
else
{
Load the list of URIs to include as active content.
set includeStat [matchclass [string tolower [HTTP::uri]] contains $::Test_StatsInclude]
Check to see if the request is on the included list.
if { 0 != $includeStat}
{
Load the list of URIs to exclude from active content.
set excludeStat [matchclass [string tolower [HTTP::uri]] contains $::Test_StatsExclude ]
Check to see if the request is on the excluded list.
if { 0 != $excludeStat}
{
The request is for monitoring content.
set ::page_type 2
}
else
{
The request is for active user content.
set ::page_type 1
}
}
else
{
The request is for static content.
set ::page_type 3
}
}
}
when HTTP_RESPONSE {
Set the the finish time of the request and work out the total time the request took.
set t1 [clock clicks -milliseconds]
set total_time [expr $t1 - $t0]
if { $::page_type == 1 } {
if { [expr $total_time <= 500] } {
STATS::incr $::StatProfileName "active_requests_500ms" 1
STATS::incr $::StatProfileName "active_requests_500ms_time" $total_time
}
elseif { [expr $total_time >= 501 and <=1000] } {
STATS::incr $::StatProfileName "active_requests_1000ms" 1
STATS::incr $::StatProfileName "active_requests_1000ms_time" $total_time
}
elseif { [expr $total_time >= 1001 and <=1500] } {
STATS::incr $::StatProfileName "active_requests_1500ms" 1
STATS::incr $::StatProfileName "active_requests_1500ms_time" $total_time
}
elseif { [expr $total_time >= 1501 and <=2000] } {
STATS::incr $::StatProfileName "active_requests_2000ms" 1
STATS::incr $::StatProfileName "active_requests_2000ms_time" $total_time
}
elseif { [expr $total_time >= 2001 and <=2500] } {
STATS::incr $::StatProfileName "active_requests_2500ms" 1
STATS::incr $::StatProfileName "active_requests_2500ms_time" $total_time
}
elseif { [expr $total_time >= 2501 and <=3000] } {
STATS::incr $::StatProfileName "active_requests_3000ms" 1
STATS::incr $::StatProfileName "active_requests_3000ms_time" $total_time
}
elseif { [expr $total_time >= 3001] } {
STATS::incr $::StatProfileName "active_requests_over_3000ms" 1
STATS::incr $::StatProfileName "active_requests_over_3000ms_time" $total_time
}
}
elseif { $::page_type == 2 } {
Update the statistics for monitoring requests.
STATS::incr $::StatProfileName "tot_monitoring_requests" 1
STATS::incr $::StatProfileName "tot_monitoring_page_time" $total_time
}
elseif { $::page_type == 3 } {
Update the statistics for static requests.
STATS::incr $::StatProfileName "tot_static_requests" 1
STATS::incr $::StatProfileName "tot_static_page_time" $total_time
}
}4 Replies
- Deb_Allen_18Historic F5 AccountI don't see anything specific to 9.4 in your iRule.
If you are monitoring the logs and don't see any runtime errors, I'd start troubleshooting by adding logging at each condition to see where the iRule processing is stopping, and take it from there.
I do see that you are using a global variable for what looks like a connection-specific value (:page_type). Shouldn't affect your ability to get a response, but most certainly could skew your stats.
HTH
/deb - Simon_Wright_85
Nimbostratus
Hi Deb thanks for the reply.
I found the error which was caused by the expression i was using to group by time. It should have been in the formatelseif { [expr $total_time >= 501 ] and [expr $total_time <= 1000 ] }
rather thanelseif { [expr $total_time >= 501 and <= 1000 ] }
I dont know why it only affected asp pages and not aspx but its working now and i am happy.
You point about using a global variable was interesting. I was setting the page type on the request as i was having trouble setting it on the response originaly. I will do some further investigation though and see what i can come up with.
Cheers
Simon - Deb_Allen_18Historic F5 AccountI dont know why it only affected asp pages and not aspx but its working now and i am happy.Most likely they hit one of the conditions not containing that bad comparison. Glad I could help.
The way you are using the page_type variable is a recommended approach for saving request values for use in later events when they are no longer visible. Just make it a local variable by leaving off the leading "::" and it should work as expected.
Local variables are scoped to the connection, so they not only traverse events, but also multiple iRules processing the same connection. Global variables are shared across all rules, all connections. If the same global variable name is set multiple times (i.e. if you use the same varname in 2 iRules), the last value set will be the value the var holds.
So to avoid unintentional data sharing, never use a global variable for connection-specific data, and never use exactly the same global variable name in 2 iRules unless you intend it to be shared.
/deb - Simon_Wright_85
Nimbostratus
Hi Deb
Thanks for clarifying that for me. I didnt know about the '::' meaning it was a global variable. the numbers coming out of the irule now make much more sense.
cheers
Simon
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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