Forum Discussion

JRahm's avatar
JRahm
Icon for Admin rankAdmin
Oct 18, 2005

more fun with iRules

I had some time to play today, and I was interested in the new stats profile offered in 9.2. Here is a rule I put together to get more granular view into the http status codes returned by the server, along with an attached picture of the GUI output. The server in this case is a cisco 2801 with the http server enabled (my lab is weak on the server side!)


class codes_class  {
   "200 c200_OK"
   "201 c201_Created"
   "202 c202_Accepted"
   "203 c203_Partial_Info"
   "204 c204_No_Response"
   "301 c301_Moved"
   "302 c302_Found"
   "303 c303_Method"
   "304 c304_Not_Modified"
   "400 c400_Bad_Request"
   "401 c401_Unauthorized"
   "402 c402_Payment_Required"
   "403 c403_Forbidden"
   "404 c404_Not_Found"
   "411 c411_No_Such_Group"
   "500 c500_Internal_Error"
   "501 c501_Not_Implemented"
   "502 c502_Timed_Out"
}
profile stats codes_profile {
   defaults from stats
   field1 c200_OK
   field2 c201_Created
   field3 c202_Accepted
   field4 c203_Partial_Info
   field5 c204_No_Response
   field6 c301_Moved
   field7 c302_Found
   field8 c303_Method
   field9 c304_Not_Modified
   field10 c400_Bad_Request
   field11 c401_Unauthorized
   field12 c402_Payment_Required
   field13 c403_Forbidden
   field14 c404_Not_Found
   field15 c411_No_Such_Group
   field16 c500_Internal_Error
   field17 c501_Not_Implemented
   field18 c502_Timed_Out
}
pool C2801_HTTP {
   monitor all http
   member 10.5.5.15:http
}
rule stats_HTTP_STATUS {
   when HTTP_RESPONSE {
   if { not ([HTTP::status] eq "") } {
      set status_code_current [ findclass [HTTP::status] $::codes_class " " ]
      STATS::incr codes_profile $status_code_current
   }
}
}
virtual C2801_HTTP_VIP {
   destination 10.29.10.100:http
   ip protocol tcp
   profile codes_profile tcp
   pool C2801_HTTP
   rule stats_HTTP_STATUS
}

2 Replies

  • Great post Citizen!

     

     

    The question now is: What are you going to do with all that data?

     

     

    -Joe
  • :D

     

     

    Actually, I was just testing the functionality of custom stats collection in a profile and that was the first scenario that popped in my head (and a relatively easy one to set up and test). I can see greater uses, such as counting the number of times beer is referenced in http_data.......