Forum Discussion

Re: wanna record user_agent from specific client ip

Hi Jucao,

That's close. You can set a variable in CLIENT_ACCEPTED to track whether to log the User-Agent header value in HTTP_REQUEST:

when CLIENT_ACCEPTED {
   if { [IP::addr [IP::client_addr] equals 174.76.19.40] } {
      set log_ua 1
   } else {
      set log_ua 0
   }
}
when HTTP_REQUEST {
   if { $log_ua == 1 } {
      log local0. " 174.76.19.40 uses [HTTP::header value user_agent]"
   }
}

Aaron
No RepliesBe the first to reply