git-svn: trunk@4392
Török Edvin authored on 2008/11/13 06:23:35... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Wed Nov 12 21:33:50 EET 2008 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * contrib/clamdtop/TODO, contrib/clamdtop/clamdtop.c: some docs |
|
4 |
+ |
|
1 | 5 |
Wed Nov 12 20:12:09 EET 2008 (edwin) |
2 | 6 |
------------------------------------ |
3 | 7 |
* contrib/clamdtop/clamdtop.c: fix some leaks and crashes |
... | ... |
@@ -3,10 +3,7 @@ parse pool states, and show those that are != VALID |
3 | 3 |
highlight problems in version/dbversion/dbtime (old db version, old dbtime, |
4 | 4 |
different db versions). |
5 | 5 |
write a manpage |
6 |
-check that it works for clamd w/o STATS support (version should still work). |
|
7 | 6 |
consider writing a GUI using Tk 8.5 (version 8.5 has much nicer widgets than 8.4) |
8 | 7 |
integrate into toplevel clamav, and build if ncurses is available (optional) |
9 | 8 |
figure out minimum version of ncurses required, I used 5.5 during development. |
10 |
-describe what the various fields mean, like what live/idle threads mean and why |
|
11 |
-describe why the multiscan view is split |
|
12 |
-explain what queue means, and why it is high with multiscan |
|
9 |
+explain why queued items are high during multiscan. |
... | ... |
@@ -140,8 +140,8 @@ static unsigned maxy=0, maxx=0; |
140 | 140 |
static char *queue_header = NULL; |
141 | 141 |
static char *clamd_header = NULL; |
142 | 142 |
|
143 |
-#define CMDHEAD " COMMAND TIME QUEUED FILE" |
|
144 |
-#define CMDHEAD2 " # COMMAND TIME QUEUED FILE" |
|
143 |
+#define CMDHEAD " COMMAND QUEUEDSINCE FILE" |
|
144 |
+#define CMDHEAD2 " # COMMAND QUEUEDSINCE FILE" |
|
145 | 145 |
|
146 | 146 |
/* |
147 | 147 |
* CLAMD - which local/remote clamd this is |
... | ... |
@@ -222,8 +222,9 @@ static void init_windows(int num_clamd) |
222 | 222 |
werase(stdscr); |
223 | 223 |
refresh(); |
224 | 224 |
memset(status_bar_keys, 0, sizeof(status_bar_keys)); |
225 |
- status_bar_keys[0] = "Q - quit"; |
|
226 |
- status_bar_keys[1] = "R - reset bar maximums"; |
|
225 |
+ status_bar_keys[0] = "F1 - help"; |
|
226 |
+ status_bar_keys[1] = "Q - quit"; |
|
227 |
+ status_bar_keys[2] = "R - reset bar maximums"; |
|
227 | 228 |
} |
228 | 229 |
|
229 | 230 |
static void init_ncurses(int num_clamd) |
... | ... |
@@ -282,11 +283,6 @@ static void header(void) |
282 | 282 |
|
283 | 283 |
win_start(header_window, header_color); |
284 | 284 |
mvwprintw(header_window, 0, 0, " ClamdTOP version 0.1 "); |
285 |
-/* mvwprintw(header_window, 0, 0, " __ ____ "); |
|
286 |
- mvwprintw(header_window, 1, 0, " ____/ /__ ___ _ ___/ / /____ ___ "); |
|
287 |
- mvwprintw(header_window, 2, 0, "/ __/ / _ `/ ' \\/ _ / __/ _ \\/ _ \\"); |
|
288 |
- mvwprintw(header_window, 3, 0, "\\__/_/\\_,_/_/_/_/\\_,_/\\__/\\___/ .__/"); |
|
289 |
- mvwprintw(header_window, 4, 0," /_/ ");*/ |
|
290 | 285 |
time(&t); |
291 | 286 |
wprintw(header_window, "%s", ctime(&t)); |
292 | 287 |
wrefresh(header_window); |
... | ... |
@@ -963,6 +959,13 @@ static void setup_connections(int argc, char *argv[]) |
963 | 963 |
} |
964 | 964 |
#endif |
965 | 965 |
|
966 |
+ /* clamdtop v0.1 */ |
|
967 |
+ puts( " __ ____"); |
|
968 |
+ puts(" _____/ /___ _____ ___ ____/ / /_____ ____ ___ ___"); |
|
969 |
+ puts(" / ___/ / __ `/ __ `__ \\/ __ / __/ __ \\/ __ \\ _ __/ _ \\ < /"); |
|
970 |
+ puts("/ /__/ / /_/ / / / / / / /_/ / /_/ /_/ / /_/ / | |/ / // / / /"); |
|
971 |
+ puts("\\___/_/\\__,_/_/ /_/ /_/\\__,_/\\__/\\____/ .___/ |___/\\___(_)_/"); |
|
972 |
+ puts(" /_/ "); |
|
966 | 973 |
memset(&global, 0, sizeof(global)); |
967 | 974 |
if (argc == 1) { |
968 | 975 |
global.num_clamd = 1; |
... | ... |
@@ -1005,6 +1008,60 @@ static void free_global_stats(void) |
1005 | 1005 |
global.n=0; |
1006 | 1006 |
} |
1007 | 1007 |
|
1008 |
+static int help_line; |
|
1009 |
+static void explain(const char *abbrev, const char *msg) |
|
1010 |
+{ |
|
1011 |
+ wattron(stdscr, A_BOLD); |
|
1012 |
+ mvwprintw(stdscr, help_line++, 0, "%-15s", abbrev); |
|
1013 |
+ wattroff(stdscr, A_BOLD); |
|
1014 |
+ wprintw(stdscr," %s", msg); |
|
1015 |
+} |
|
1016 |
+ |
|
1017 |
+static int show_help(void) |
|
1018 |
+{ |
|
1019 |
+ int ch; |
|
1020 |
+ werase(stdscr); |
|
1021 |
+ help_line = 0; |
|
1022 |
+ |
|
1023 |
+ explain("NO","Unique clamd number"); |
|
1024 |
+ explain("CONNTIME", "How long it is connected"); |
|
1025 |
+ explain("LIV", "Total number of live threads"); |
|
1026 |
+ explain("IDL", "Total number of idle threads"); |
|
1027 |
+ explain("QUEUE", "Number of items in queue"); |
|
1028 |
+ explain("MAXQ","Maximum number of items observed in queue"); |
|
1029 |
+ explain("MEM", "Total memory usage (if available)"); |
|
1030 |
+ explain("HOST", "Which clamd, local means unix socket"); |
|
1031 |
+ explain("ENGINE", "Engine version"); |
|
1032 |
+ explain("DBVER", "Database version"); |
|
1033 |
+ explain("DBTIME", "Database publish time"); |
|
1034 |
+ explain("Primary threads", "Threadpool used to receive commands"); |
|
1035 |
+ explain("All threads","All threadpools, including multiscan"); |
|
1036 |
+ explain("live","Executing commands, or scanning"); |
|
1037 |
+ explain("idle","Waiting for commands, will exit after idle_timeout"); |
|
1038 |
+ explain("max", "Maximum number of threads configured for this pool"); |
|
1039 |
+ explain("Queue","Tasks queued for processing, but not yet picked up by a thread"); |
|
1040 |
+ explain("COMMAND","Command this thread is executing"); |
|
1041 |
+ explain("QUEUEDSINCE","How long this task is executing"); |
|
1042 |
+ explain("FILE","Which file it is processing (if applicable)"); |
|
1043 |
+ explain("Mem","Memory usage reported by libc"); |
|
1044 |
+ explain("Libc","Used/free memory reported by libc"); |
|
1045 |
+ explain("Pool","Memory usage reported by libclamav's pool"); |
|
1046 |
+ |
|
1047 |
+ wrefresh(stdscr); |
|
1048 |
+ werase(status_bar_window); |
|
1049 |
+ wattron(status_bar_window, A_REVERSE); |
|
1050 |
+ mvwprintw(status_bar_window, 0, 0, "Press any key to exit help"); |
|
1051 |
+ wattroff(status_bar_window, A_REVERSE); |
|
1052 |
+ wrefresh(status_bar_window); |
|
1053 |
+ /* getch() times out after a few seconds */ |
|
1054 |
+ do { |
|
1055 |
+ ch = getch(); |
|
1056 |
+ /* we do need to exit on resize, because the text scroll out of |
|
1057 |
+ * view */ |
|
1058 |
+ } while (ch == -1 /*|| ch == KEY_RESIZE*/); |
|
1059 |
+ return ch == KEY_RESIZE ? KEY_RESIZE : -1; |
|
1060 |
+} |
|
1061 |
+ |
|
1008 | 1062 |
int main(int argc, char *argv[]) |
1009 | 1063 |
{ |
1010 | 1064 |
int ch = 0; |
... | ... |
@@ -1018,6 +1075,9 @@ int main(int argc, char *argv[]) |
1018 | 1018 |
|
1019 | 1019 |
memset(&tv_last, 0, sizeof(tv_last)); |
1020 | 1020 |
do { |
1021 |
+ if (ch == KEY_F(1)) { |
|
1022 |
+ ch = show_help(); |
|
1023 |
+ } |
|
1021 | 1024 |
if(ch == KEY_RESIZE) { |
1022 | 1025 |
resize(); |
1023 | 1026 |
endwin(); |