Forum Discussion
Sriram_129909
Nimbostratus
May 01, 2014iRule errors out on Insert operation
The following snippet of iRule broke my Virtual in 10.4 but works fine in 11.2
HTTP::header insert F5-Unique-Id $md5var
The following is the error I got:
TCL error: tcop_hslog - Oper...
Sriram_129909
Nimbostratus
May 01, 2014Here you go. The iRule that has problems:
when CLIENT_ACCEPTED {
set applayer_hsl [HSL::open -proto UDP -pool hslog_pool]
set ClientPort [TCP::local_port]
}
when HTTP_REQUEST {
set http_request_time [clock clicks -milliseconds]
set req_time [clock format [clock seconds] -format "%D %H:%M:%S %z"]
generation of UUID.
set id "[IP::client_addr][TCP::client_port][IP::local_addr][TCP::local_port][expr { int(100000000 * rand()) }]"
binary scan [md5 $id] H* md5var
log local0. "$md5var"
insert the generated unique id as header
HTTP::header insert F5-Unique-Id $md5var
set http_request "[HTTP::request]HttpKalive:[HTTP::is_keepalive]\r\nHttpVer:[HTTP::version]\r\nF5Addr:[IP::local_addr]\r\nClientIP:[IP::client_addr]\r\nTime:$req_time\r\nPort:$ClientPort\r\nTimeinMills:$http_request_time"
append http_request "\r\nf5UniqueId:$md5var"
}
when LB_SELECTED {
set lb_selected "Server:[LB::server addr]\r\nPool:[LB::server pool] "
append the the worker selected to http_request
append http_request "\r\n$lb_selected"
log local0. "Selected [LB::server addr]"
}
when HTTP_RESPONSE {
calculate the response time and append it
append http_request "\r\nresponseTime: [expr {[clock clicks -milliseconds] - $http_request_time}]"
set response "Set-Cookie:[HTTP::header values Set-Cookie]\r\nContent-Type:[HTTP::header Content-Type]\r\nContent-Encoding:[HTTP::header Content-Encoding]\r\nContent-Length:[HTTP::header Content-Length] "
log local0.info "<190>\r\n$http_request\r\n$lb_selected\r\n--||--\r\n$response"
HSL::send $applayer_hsl "<190>\r\n$http_request\r\n--||--\r\n$response\r\n"
}
The iRule that has the respond:
when HTTP_REQUEST {
HTTP::respond 301 Location "http://www.company-name.com[HTTP::uri]"
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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