From e30c9c92868af1d50b7d273056b6fbfeb82aaf73 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 16 Feb 2013 23:49:04 +0100 Subject: MEDIUM: halog: add support for counting per source address (-ic) This is the same as -uc except that instead of counting URLs, it counts source addresses. The reported times are request times and not response times. The code becomes heavily ugly, the url struct is being abused to store an address, and there are no more bit fields available. The code needs a major revamp. (cherry picked from commit 7cf479cc09d4e4d142e8862e2a2792385f695439) --- contrib/halog/halog.c | 124 +++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 116 insertions(+), 8 deletions(-) diff --git a/contrib/halog/halog.c b/contrib/halog/halog.c index 61034ec..9552998 100644 --- a/contrib/halog/halog.c +++ b/contrib/halog/halog.c @@ -114,6 +114,7 @@ struct url_stat { FILT_COUNT_URL_BAVG|FILT_COUNT_URL_BTOT) #define FILT_COUNT_COOK_CODES 0x40000000 +#define FILT_COUNT_IP_COUNT 0x80000000 unsigned int filter = 0; unsigned int filter_invert = 0; @@ -126,6 +127,7 @@ int lines_max = -1; const char *fgets2(FILE *stream); void filter_count_url(const char *accept_field, const char *time_field, struct timer **tptr); +void filter_count_ip(const char *source_field, const char *accept_field, const char *time_field, struct timer **tptr); void filter_count_srv_status(const char *accept_field, const char *time_field, struct timer **tptr); void filter_count_cook_codes(const char *accept_field, const char *time_field, struct timer **tptr); void filter_count_term_codes(const char *accept_field, const char *time_field, struct timer **tptr); @@ -140,7 +142,7 @@ void usage(FILE *output, const char *msg) "%s" "Usage: halog [-h|--help] for long help\n" " halog [-q] [-c] [-m ]\n" - " {-cc|-gt|-pct|-st|-tc|-srv|-u|-uc|-ue|-ua|-ut|-uao|-uto|-uba|-ubt}\n" + " {-cc|-gt|-pct|-st|-tc|-srv|-u|-uc|-ue|-ua|-ut|-uao|-uto|-uba|-ubt|-ic}\n" " [-s ] [-e|-E] [-H] [-rt|-RT