cancel
Showing results for 
Search instead for 
Did you mean: 
Kai_Wilke
MVP
MVP

Problem this snippet solves:

Hi Folks,

the provided iRule below can be used to count and analyse individual STREAM::expression hits.

Imagine you have some more of less interesting HTML content that needs several content rewrites...

"On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look." -MSOffice

... and you apply a STREAM::expression with lots of individual translations to it...

STREAM::expression @a@A@@b@B@@c@C@@d@D@@e@E@@f@F@@g@G@@h@H@@i@I@@j@J@@k@K@@l@L@@m@M@@n@N@@o@O@@p@P@@q@Q@@r@R@@s@S@@t@T@@u@U@@v@V@@w@W@@x@X@@y@Y@@z@Z@

... then you could use the iRule below to [log] which individual expression has been triggered how many times on which ressource.

Thu Sep 8 16:07:43 CEST 2016  debug  f5-02  tmm[16579]     STREAM hits on URL /stream: 271 ( Pattern:p = 2 | ( Pattern:a = 18 | ( Pattern:r = 21 | ( Pattern:b = 4 | ( Pattern:c = 13 | ( Pattern:s = 19 | ( Pattern:d = 12 | ( Pattern:t = 28 | ( Pattern:u = 12 | ( Pattern:e = 36 | ( Pattern:f = 2 | ( Pattern:v = 2 | ( Pattern:w = 2 | ( Pattern:g = 6 | ( Pattern:h = 12 | ( Pattern:y = 4 | ( Pattern:i = 15 | ( Pattern:k = 3 | ( Pattern:l = 14 | ( Pattern:m = 5 | ( Pattern:n = 15 | ( Pattern:o = 26 )  

Cheers, Kai

How to use this snippet:

  1. Attach the provided iRule to your Virtual Server which performs [STREAM] operations
  2. Request the streamed content as usual.
  3. Take a look to your LTM logfile.

Code :

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
        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 -noname 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
        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 -noname local0.debug "STREAM hits on URL $stream_result(path):  $stream_result(match_total) [string trimright $stream_result(match_detailed) " |"] )"
        unset -nocomplain stream_result
    }
}

Tested this on version:

12.0
Version history
Last update:
‎08-Sep-2016 07:15
Updated by:
Contributors