Forum Discussion
ebeng_278441
Aug 31, 2016Altocumulus
Log the count of the STREAM hits
I'm trying to figure out how it will be possible, how many times a STREAM::expression is being executed.
when HTTP_RESPONSE {
if { $http_host equals "avv.com" or $http_host equals "acc...
Kai_Wilke
Sep 01, 2016MVP
Hi Ebeng,
you can count the individual
[STREAM::expression]
hits using the STREAM_MATCHED
event. But its not that easy to accumulate the total hit numbers, since STREAM happens after the HTTP_RESPONSE_RELEASE
event. You have to accumulate the hit numbers either on the very next HTTP_REQUEST
(if keep-alive is used) or on CLIENT_CLOSE
.
You may take a look to the iRule below. It will count the individual STREAM hits and finally accumulate the results.
when STREAM_MATCHED {
set stream_result(path) $http_path
if { [info exists stream_result(Pattern:[STREAM::match])] } then {
incr stream_result(Pattern:[STREAM::match])
} else {
set stream_result(Pattern:[STREAM::match]) 1
}
}
when HTTP_REQUEST {
set http_path [HTTP::path]
if { [info exists stream_result(path)] } then {
set stream_result(match_total) 0
log local0.debug "Debug [array names stream_result Pattern:*]"
foreach stream_result(pattern) [array names stream_result Pattern:*] {
incr stream_result(match_total) $stream_result($stream_result(pattern))
append stream_result(match_detailed) "( $stream_result(pattern) = $stream_result($stream_result(pattern)) | "
}
log local0.debug "STREAM hits on URL $stream_result(path): $stream_result(match_total) [string trimright $stream_result(match_detailed) " |"] )"
unset -nocomplain stream_result
}
}
when CLIENT_CLOSED {
if { [info exists stream_result(path)] } then {
set stream_result(match_total) 0
log local0.debug "Debug [array names stream_result Pattern:*]"
foreach stream_result(pattern) [array names stream_result Pattern:*] {
incr stream_result(match_total) $stream_result($stream_result(pattern))
append stream_result(match_detailed) "( $stream_result(pattern) = $stream_result($stream_result(pattern)) | "
}
log local0.debug "STREAM hits on URL $stream_result(path): $stream_result(match_total) [string trimright $stream_result(match_detailed) " |"] )"
unset -nocomplain stream_result
}
}
Note: Keep in mind, that you can't specify multiple STREAM::expression during HTTP_RESPONSE. But you can combine multiple expression into a single STREAM::expression (e.g.
STREAM::expression "@aa@bb@@rr@ff@@gg@qaqa@")
Cheers, Kai
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