web Log_ Display_log_messages_to_ Web_ Browser
Problem this snippet solves:
As an alternative of logging to syslog-ng, this simple rule is to display log messages directly to web browser.
It's useful when you are developing or troubleshooting iRules for web traffic.
Basically, it will display global variable "webLogMsg" right after tag.
Psst .. It can also be modified for other purposes like posting notification of a scheduled maintenance in near future on all web page.
.:: Hum.the.Benedict ::.
Code :
when RULE_INIT { set ::webShowLog 1 # enable logging for this IP set ::webLogFrom "x.x.x.x" } when CLIENT_ACCEPTED { set ::webLogMsg "Client Port: [TCP::client_port]" } when HTTP_REQUEST { append ::webLogMsg "HTTP URI: [HTTP::uri]" } when HTTP_RESPONSE { # Make sure that there are no trailing spaces after '\' if {($::webShowLog) && \ ([IP::client_addr] equals $::webLogFrom) && \ ([info exists ::webLogMsg]) } { # Collect 2000 Bytes if {[HTTP::header "Content-Length"] > 2000} { HTTP::collect 2000 } else { HTTP::collect [HTTP::header "Content-Length"] } } } when HTTP_RESPONSE_DATA { regexp -indices {(?i)]*>} [HTTP::payload] BodyLocation # Make sure that there are no trailing spaces after '\' HTTP::payload replace [lindex $BodyLocation 1] 1 \ [concat {>} $::webLogMsg {}] unset ::webLogMsg HTTP::release }
Published Mar 18, 2015
Version 1.0hwidjaja_37598
Altostratus
Joined June 02, 2008
hwidjaja_37598
Altostratus
Joined June 02, 2008
No CommentsBe the first to comment