From d220106092244e05268403e3f3589c012ac204d0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 27 May 2010 18:17:30 +0200 Subject: [PATCH] [CONTRIB] halog: report per-server status codes, errors and response times It's sometimes very useful to be able to monitor a production status in real time by comparing servers behaviours. Now halog is able to do this when called with "-srv". It reports various fields for each server found in a log, including statuses, total reqs, valid reqs, percent of valid reqs, average connection time, average response time. --- contrib/halog/Makefile | 4 +- contrib/halog/halog.c | 143 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 143 insertions(+), 4 deletions(-) diff --git a/contrib/halog/Makefile b/contrib/halog/Makefile index 4cf6cb5f8..9a1b79ac2 100644 --- a/contrib/halog/Makefile +++ b/contrib/halog/Makefile @@ -5,10 +5,10 @@ OPTIMIZE = -O3 OBJS = halog halog64 halog: halog.c fgets2.c - $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) $(EBTREE_DIR)/ebtree.c $(EBTREE_DIR)/eb32tree.c $^ + $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) $(EBTREE_DIR)/ebtree.c $(EBTREE_DIR)/eb32tree.c $(EBTREE_DIR)/ebmbtree.c $(EBTREE_DIR)/ebsttree.c $^ halog64: halog.c fgets2-64.c - $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) $(EBTREE_DIR)/ebtree.c $(EBTREE_DIR)/eb32tree.c $^ + $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) $(EBTREE_DIR)/ebtree.c $(EBTREE_DIR)/eb32tree.c $(EBTREE_DIR)/ebmbtree.c $(EBTREE_DIR)/ebsttree.c $^ clean: rm -vf $(OBJS) diff --git a/contrib/halog/halog.c b/contrib/halog/halog.c index 81ffa827e..b9da76155 100644 --- a/contrib/halog/halog.c +++ b/contrib/halog/halog.c @@ -1,7 +1,7 @@ /* * haproxy log time reporter * - * Copyright 2000-2009 Willy Tarreau + * Copyright 2000-2010 Willy Tarreau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,8 +28,11 @@ #include #include +#include +#define SOURCE_FIELD 5 #define ACCEPT_FIELD 6 +#define SERVER_FIELD 8 #define TIME_FIELD 9 #define STATUS_FIELD 10 #define CONN_FIELD 15 @@ -49,6 +52,13 @@ struct timer { unsigned int count; }; +struct srv_st { + unsigned int st_cnt[6]; /* 0xx to 5xx */ + unsigned int nb_ct, nb_rt, nb_ok; + unsigned long long cum_ct, cum_rt; + struct ebmb_node node; + /* don't put anything else here, the server name will be there */ +}; #define FILT_COUNT_ONLY 0x01 #define FILT_INVERT 0x02 @@ -64,6 +74,7 @@ struct timer { #define FILT_INVERT_TIME_RESP 0x400 #define FILT_COUNT_STATUS 0x800 +#define FILT_COUNT_SRV_STATUS 0x1000 unsigned int filter = 0; unsigned int filter_invert = 0; @@ -75,7 +86,7 @@ void die(const char *msg) { fprintf(stderr, "%s" - "Usage: halog [-c] [-v] [-gt] [-pct] [-st] [-s ] [-e|-E] [-rt|-RT