git-svn: trunk@4417
Török Edvin authored on 2008/11/17 01:38:14... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sun Nov 16 17:35:23 EET 2008 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * contrib/clamdtop/Makefile, contrib/clamdtop/clamdtop.c: fix queue |
|
4 |
+ length parsing |
|
5 |
+ |
|
1 | 6 |
Fri Nov 14 22:24:44 CET 2008 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* libclamav: drop cl_settempdir(); use cl_engine_set() with CL_ENGINE_TMPDIR |
... | ... |
@@ -690,7 +690,7 @@ static void parse_queue(conn_t *conn, char* buf, size_t len, unsigned idx) |
690 | 690 |
} while (recv_line(conn, buf, len) && buf[0] == '\t' && strcmp("END\n", buf) != 0); |
691 | 691 |
} |
692 | 692 |
|
693 |
-static unsigned biggest_queue = 1, biggest_mem = 0; |
|
693 |
+static unsigned biggest_mem = 0; |
|
694 | 694 |
|
695 | 695 |
static void output_memstats(struct stats *stats) |
696 | 696 |
{ |
... | ... |
@@ -828,20 +828,18 @@ static int output_stats(struct stats *stats, unsigned idx) |
828 | 828 |
print_colored(win, buf); |
829 | 829 |
show_bar(win, i++, stats->live, stats->idle, stats->max, 0); |
830 | 830 |
|
831 |
+ blink = 0; |
|
832 |
+ if(stats->current_q > stats->biggest_queue) { |
|
833 |
+ stats->biggest_queue = stats->current_q; |
|
834 |
+ blink = 1; |
|
835 |
+ } |
|
831 | 836 |
mvwprintw(win, i++, 0, "Queue:"); |
832 | 837 |
snprintf(buf, sizeof(buf), "%6u items %6u max", stats->current_q, stats->biggest_queue); |
833 | 838 |
print_colored(win, buf); |
839 |
+ show_bar(win, i++, stats->current_q, 0, stats->biggest_queue, blink); |
|
834 | 840 |
werase(mem_window); |
835 | 841 |
output_memstats(stats); |
836 | 842 |
} |
837 |
- blink = 0; |
|
838 |
- if(stats->current_q > stats->biggest_queue) { |
|
839 |
- stats->biggest_queue = stats->current_q; |
|
840 |
- blink = 1; |
|
841 |
- } |
|
842 |
- if (sel && !stats->stats_unsupp) { |
|
843 |
- show_bar(win, i++, stats->current_q, 0, biggest_queue, blink); |
|
844 |
- } |
|
845 | 843 |
free(line); |
846 | 844 |
return i; |
847 | 845 |
} |
... | ... |
@@ -936,6 +934,7 @@ static void parse_stats(conn_t *conn, struct stats *stats, unsigned idx) |
936 | 936 |
stats->conn_hr = conn_dt/3600; |
937 | 937 |
stats->conn_min = (conn_dt/60)%60; |
938 | 938 |
stats->conn_sec = conn_dt%60; |
939 |
+ stats->current_q = 0; |
|
939 | 940 |
|
940 | 941 |
while(recv_line(conn, buf, sizeof(buf)) && strcmp("END\n",buf) != 0) { |
941 | 942 |
char *val = strchr(buf, ':'); |
... | ... |
@@ -989,7 +988,7 @@ static void parse_stats(conn_t *conn, struct stats *stats, unsigned idx) |
989 | 989 |
unsigned len; |
990 | 990 |
if(sscanf(val, "%u", &len) != 1) |
991 | 991 |
continue; |
992 |
- stats->current_q = len; |
|
992 |
+ stats->current_q += len; |
|
993 | 993 |
} |
994 | 994 |
} |
995 | 995 |
} |
... | ... |
@@ -1153,7 +1152,8 @@ int main(int argc, char *argv[]) |
1153 | 1153 |
init_windows(global.num_clamd); |
1154 | 1154 |
break; |
1155 | 1155 |
case 'R': |
1156 |
- biggest_queue = 1; |
|
1156 |
+ for (i=0;i<global.num_clamd;i++) |
|
1157 |
+ global.all_stats[i].biggest_queue = 1; |
|
1157 | 1158 |
biggest_mem = 0; |
1158 | 1159 |
break; |
1159 | 1160 |
case KEY_UP: |
... | ... |
@@ -1180,10 +1180,13 @@ int main(int argc, char *argv[]) |
1180 | 1180 |
if(tv.tv_sec - tv_last.tv_sec >= MIN_INTERVAL) { |
1181 | 1181 |
free_global_stats(); |
1182 | 1182 |
for(i=0;i<global.num_clamd;i++) { |
1183 |
+ unsigned biggest_q; |
|
1183 | 1184 |
struct stats *stats = &global.all_stats[i]; |
1184 | 1185 |
if (global.conn[i].sd != -1) |
1185 | 1186 |
send_string(&global.conn[i], "STATS\n"); |
1187 |
+ biggest_q = stats->biggest_queue; |
|
1186 | 1188 |
memset(stats, 0, sizeof(*stats)); |
1189 |
+ stats->biggest_queue = biggest_q; |
|
1187 | 1190 |
parse_stats(&global.conn[i], stats, i); |
1188 | 1191 |
} |
1189 | 1192 |
if (global.tasks) |