Forum Discussion
Chris_Miller
Altostratus
Jul 06, 2010Heatmap iRule Errors
I've implemented this - http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1084382/Heatmaps-iRules-Style-Part-1.aspxComments and am getting a few errors.
Here's t...
hoolio
Cirrostratus
Jul 07, 2010Hi Chris,
You're trying to increment the states subtable on every request regardless of whether you've done a lookup of the client IP and saved the output to $loc. You can avoid the issue by moving the table incr command into the same else clause as the whereis command.
To build two separate heatmaps, you could use a token to differentiate between them. Here's an untested suggestion to start with:
when HTTP_REQUEST {
if { [HTTP::header exists "True-Client-IP"] }{
set user_ip [HTTP::header True-Client-IP]
set token "header"
} else {
set user_ip [IP::client_addr]
set token "clientip"
}
if {[HTTP::uri] starts_with "/heatmap_$token" and [matchclass $user_ip equals whitelist]} {
set chld ""
set chd ""
foreach state [table keys -subtable states_$token] {
append chld $state
append chd "[table lookup -subtable states_$token $state],"
}
set chd [string trimright $chd ","]
HTML REMOVED SO DC DOESN'T PUT UP PIC
log local0. "heatmap accessed by $user_ip"
} elseif {[HTTP::uri] starts_with "/resetmap_$token" and [matchclass $user_ip equals whitelist]} {
foreach state [table keys -subtable states_$token] {
table delete -subtable states $state_$token
}
log local0. "heatmap reset by $user_ip"
} else {
set loc [whereis $user_ip abbrev]
log local0. "location is $loc"
}
if {[table incr -subtable states_$token -mustexist $loc] eq ""} {
table set -subtable states_$token $loc 1 indefinite indefinite
}
}
Note that if you leave the $:: prefix on class names, the iRule will be demoted from CMP use.
Aaron
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
