diff --git a/ChangeLog b/ChangeLog index 29b9d7842..baf6f7cde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 16 17:35:23 EET 2008 (edwin) +------------------------------------ + * contrib/clamdtop/Makefile, contrib/clamdtop/clamdtop.c: fix queue + length parsing + Fri Nov 14 22:24:44 CET 2008 (tk) --------------------------------- * libclamav: drop cl_settempdir(); use cl_engine_set() with CL_ENGINE_TMPDIR diff --git a/contrib/clamdtop/Makefile b/contrib/clamdtop/Makefile index 3f873c725..70dbd8592 100644 --- a/contrib/clamdtop/Makefile +++ b/contrib/clamdtop/Makefile @@ -1,4 +1,4 @@ -CFLAGS=-g -Wall -W -Wshadow -Wformat=2 -O2 +CFLAGS=-g -Wall -W -Wshadow -Wformat=2 -O2 CC=gcc OBJS=clamdtop.o CPPFLAGS=-D_FORTIFY_SOURCE=2 diff --git a/contrib/clamdtop/clamdtop.c b/contrib/clamdtop/clamdtop.c index 7854ace06..c77b33876 100644 --- a/contrib/clamdtop/clamdtop.c +++ b/contrib/clamdtop/clamdtop.c @@ -690,7 +690,7 @@ static void parse_queue(conn_t *conn, char* buf, size_t len, unsigned idx) } while (recv_line(conn, buf, len) && buf[0] == '\t' && strcmp("END\n", buf) != 0); } -static unsigned biggest_queue = 1, biggest_mem = 0; +static unsigned biggest_mem = 0; static void output_memstats(struct stats *stats) { @@ -828,20 +828,18 @@ static int output_stats(struct stats *stats, unsigned idx) print_colored(win, buf); show_bar(win, i++, stats->live, stats->idle, stats->max, 0); + blink = 0; + if(stats->current_q > stats->biggest_queue) { + stats->biggest_queue = stats->current_q; + blink = 1; + } mvwprintw(win, i++, 0, "Queue:"); snprintf(buf, sizeof(buf), "%6u items %6u max", stats->current_q, stats->biggest_queue); print_colored(win, buf); + show_bar(win, i++, stats->current_q, 0, stats->biggest_queue, blink); werase(mem_window); output_memstats(stats); } - blink = 0; - if(stats->current_q > stats->biggest_queue) { - stats->biggest_queue = stats->current_q; - blink = 1; - } - if (sel && !stats->stats_unsupp) { - show_bar(win, i++, stats->current_q, 0, biggest_queue, blink); - } free(line); return i; } @@ -936,6 +934,7 @@ static void parse_stats(conn_t *conn, struct stats *stats, unsigned idx) stats->conn_hr = conn_dt/3600; stats->conn_min = (conn_dt/60)%60; stats->conn_sec = conn_dt%60; + stats->current_q = 0; while(recv_line(conn, buf, sizeof(buf)) && strcmp("END\n",buf) != 0) { char *val = strchr(buf, ':'); @@ -989,7 +988,7 @@ static void parse_stats(conn_t *conn, struct stats *stats, unsigned idx) unsigned len; if(sscanf(val, "%u", &len) != 1) continue; - stats->current_q = len; + stats->current_q += len; } } } @@ -1153,7 +1152,8 @@ int main(int argc, char *argv[]) init_windows(global.num_clamd); break; case 'R': - biggest_queue = 1; + for (i=0;i= MIN_INTERVAL) { free_global_stats(); for(i=0;ibiggest_queue; memset(stats, 0, sizeof(*stats)); + stats->biggest_queue = biggest_q; parse_stats(&global.conn[i], stats, i); } if (global.tasks)