Forum Discussion

f5_learner_2857's avatar
f5_learner_2857
Icon for Nimbostratus rankNimbostratus
Jan 29, 2010

Persistence Cookie Logger - undefined procedure

Hello,

 

 

I am using the following iRule given at http://devcentral.f5.com/Wiki/default.aspx/iRules/Persistence_Cookie_Logger.html

 

and am getting the following error. Please advise what could be the problem.

 

 

Thanks.

 

 

Error:

 

 

01070151:3: Rule [PersistenceCookieLogger] error:

 

line 1: [undefined procedure: rule] [rule persistence_cookie_logger {

 

 

iRule:

 

 

rule persistence_cookie_logger {

 

 

when RULE_INIT {

 

see AskF5 SOL6917 for cookie encoding details:

 

https://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html

 

set ::myCookieName BIGipServerXXXX

 

set ::debug 0

 

}

 

 

when HTTP_REQUEST {

 

grab encoded cookie value & parse into relevant pieces

 

if {[HTTP::cookie exists $::myCookieName]}{

 

scan [HTTP::cookie $::myCookieName] "%d.%d.%d" myIpE myPortE unused

 

if {$::debug != 0}{log local0. "myIpD=$myIpE myPortE=$myPortE unused=$unused"}

 

 

calculate IP

 

%08x format strings forces padding w/leading 0's to 8 char string

 

set myIpH [format %08x $myIpE]

 

if {$::debug != 0}{log local0. "myIpH=$myIpH"}

 

set myIpD1 [expr 0x[substr $myIpH 6 2]]

 

set myIpD2 [expr 0x[substr $myIpH 4 2]]

 

set myIpD3 [expr 0x[substr $myIpH 2 2]]

 

set myIpD4 [expr 0x[substr $myIpH 0 2]]

 

set myIpD "$myIpD1.$myIpD2.$myIpD3.$myIpD4"

 

if {$::debug != 0}{log local0. "myIpD=$myIpD"}

 

 

calculate port

 

set myPortH [format %x $myPortE]

 

if {$::debug != 0}{log local0. "myPortH=$myPortH"}

 

set myPortD [string trimleft [expr 0x[substr $myPortH 2 2]][expr 0x[substr $myPortH 0 2]] 0]

 

if {$::debug != 0}{log local0. "myPortD=$myPortD"}

 

 

log results

 

log local0. "Request from client: \

 

[IP::remote_addr]:[TCP::remote_port] contains persistence cookie \

 

referencing pool member $myIpD:$myPortD"

 

} else {

 

log local0. "Request from client: [IP::remote_addr]:[TCP::remote_port] \

 

contains NO persistence cookie"

 

}

 

}

 

 

}

6 Replies

  • If you're adding the rule via the GUI or the iRuler, you need to leave off the object definition line:

     

     

    rule persistence_cookie_logger {

     

     

    and the matching close curly brace at the end.

     

     

    Aaron
  • I am using the persistence_cookie_logger irule . How come I don't see the cookie value. The only thing i see is :

     

     

     

    Dec 18 07:49:00 tmm tmm[2317]: Rule persistence_cookie_logger : Request from client: 63.116.166.102:57254 contains persistence cookie referencing pool member 172.28.24.106:80

     

     

     

  • Posted By Kirit Patel on 12/18/2010 04:51 AM

     

    I am using the persistence_cookie_logger irule . How come I don't see the cookie value. The only thing i see is :

     

     

     

    Dec 18 07:49:00 tmm tmm[2317]: Rule persistence_cookie_logger : Request from client: 63.116.166.102:57254 contains persistence cookie referencing pool member 172.28.24.106:80

     

     

     

     

    Because that's what you're logging. The logging statement logs the source ip:port and the pool member being used.
  • log local0. "Request from client: \

     

    [IP::remote_addr]:[TCP::remote_port] contains persistence cookie \

     

    referencing pool member $myIpD:$myPortD and value $myCookieName"
  • Did you change BIGipServerXXXX to the name of your actual persistence cookie?

     

     

    Aaron