CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Joe_Pruitt
Cirrostratus
Cirrostratus

Problem this snippet solves:

This iRule application will track URI's that come in through your virtual server and store them in a table with the number of times they have been referenced. The data stored can then be viewed by passing in the "/linkadmin" url which will generate a table of the URI's and their view counts.

Code :

when HTTP_REQUEST {
  set TABLE_LINKDATA "LINK_TRACKING_[virtual name]"
  switch [string tolower [HTTP::uri]] {
    "/linkadmin" {
      set content {
} foreach key [table keys -subtable $TABLE_LINKDATA] { append content ""; } append content "
Clear Data
URI Views
$key [table lookup -subtable $TABLE_LINKDATA $key]
";
      HTTP::respond 200 Content $content;
    }
    "/linkcleardata" {
      table delete -subtable $TABLE_LINKDATA -all;
      HTTP::redirect "http://[HTTP::host]/linkadmin"
    }
    default {
      if { [table incr -subtable $TABLE_LINKDATA -mustexist [HTTP::uri]] eq ""} {
        table set -subtable $TABLE_LINKDATA [HTTP::uri] 1 indefinite indefinite;
      }
    }
  }
}

 

Version history
Last update:
‎31-Jan-2023 16:21
Updated by:
Contributors