Forum Discussion

Gbps_31870's avatar
Gbps_31870
Icon for Nimbostratus rankNimbostratus
Nov 28, 2011

iRule to log requester_uri, redirected_uri, client_IP and selcted_server

Hi All,

 

 

I would like to know the syntax for an iRule to log the following:

 

 

Requested_uri

 

Redirected_uri

 

Client_IP

 

Selected_server/pool_member

 

 

I will link this iRule to a Datagroup which contains specific IPs, so I don't want to log all the hits coming to the VS (which is very huge).

 

 

Please let me know your thoughts, and thanks in advance.

 

2 Replies

  • e.g.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b pool foo list
    pool foo {
       members 200.200.200.101:80 {}
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            set requested_uri [HTTP::uri]
    }
    
    when HTTP_RESPONSE {
            if {[class match -- [IP::client_addr] equals clientclass]} {
                    if {[HTTP::is_redirect]} {
                            set redirected_uri [HTTP::header Location]
                    } else {
                            set redirected_uri "none"
                    }
                    log local0. "[IP::client_addr]:[TCP::client_port]|$requested_uri|$redirected_uri|[IP::remote_addr]:[TCP::remote_port]"
            }
    }
    }
    [root@ve1023:Active] config  b class clientclass list
    class clientclass {
       host 192.168.206.102
    }
    
    [root@ve1023:Active] config  tail /var/log/ltm
    Nov 28 01:05:17 local/tmm info tmm[23027]: Rule myrule : 192.168.206.102:50063|/|none|200.200.200.101:80
    Nov 28 01:05:17 local/tmm info tmm[23027]: Rule myrule : 192.168.206.102:50064|/favicon.ico|none|200.200.200.101:80
    Nov 28 01:05:17 local/tmm info tmm[23027]: Rule myrule : 192.168.206.102:50065|/favicon.ico|none|200.200.200.101:80