From d72d0314e0a563a447f560d44a7d7e7c46fb88a0 Mon Sep 17 00:00:00 2001 From: Andreas Ericsson Date: Sun, 24 Jan 2010 23:39:36 +0100 Subject: [PATCH] showlog: Ignore nothing Since we're supposed to display the raw eventlog (albeit nicely formatted), we should never ignore anything that we can parse. This patch takes care of that, and adds the missing handlers for external commands, eventhandlers and log rotation events. Signed-off-by: Andreas Ericsson --- showlog.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/showlog.c b/showlog.c index 9ab3299..8757c39 100644 --- a/showlog.c +++ b/showlog.c @@ -24,12 +24,14 @@ static int reverse_parse_files; #define EVT_STATE (1 << 4) #define EVT_FLAPPING (1 << 5) #define EVT_DOWNTIME (1 << 6) +#define EVT_LROTATE (1 << 7) +#define EVT_EHANDLER (1 << 8) + #define EVT_HOST (1 << 20) #define EVT_SERVICE (1 << 21) -#define EVENT_MASK (EVT_PROCESS | EVT_NOTIFY | EVT_ALERT | EVT_COMMAND | \ - EVT_STATE | EVT_FLAPPING | EVT_DOWNTIME) +#define EVENT_MASK (0xffffffff & (~(EVT_HOST | EVT_SERVICE))) -static int event_filter = EVT_ALERT | EVT_STATE | EVT_FLAPPING | EVT_DOWNTIME | EVT_PROCESS; +static int event_filter = EVENT_MASK; static int host_state_filter = -1; static int service_state_filter = -1; static int statetype_filter = (1 << HARD_STATE) | (1 << SOFT_STATE); @@ -42,11 +44,11 @@ static struct string_code event_codes[] = { add_event("HOST FLAPPING ALERT", EVT_FLAPPING | EVT_HOST), add_event("SERVICE NOTIFICATION", EVT_NOTIFY | EVT_SERVICE), add_event("SERVICE FLAPPING ALERT", EVT_FLAPPING | EVT_SERVICE), - add_ignored("LOG ROTATION"), - add_ignored("SERVICE EVENT HANDLER"), - add_ignored("HOST EVENT HANDLER"), - add_ignored("LOG VERSION"), - add_ignored("EXTERNAL COMMAND"), + add_event("LOG ROTATION", EVT_LROTATE), + add_event("HOST EVENT HANDLER", EVT_EHANDLER | EVT_HOST), + add_event("SERVICE EVENT HANDLER", EVT_EHANDLER | EVT_SERVICE), + add_event("LOG VERSION", EVT_PROCESS), + add_event("EXTERNAL COMMAND", EVT_COMMAND), add_code(5, "HOST ALERT", EVT_ALERT | EVT_HOST), add_code(5, "INITIAL HOST STATE", EVT_STATE | EVT_HOST), @@ -174,10 +176,27 @@ static void print_line_html(int type, struct tm *t, char *line, uint len) case EVT_DOWNTIME | EVT_SERVICE: image = "downtime.gif"; break; + case EVT_FLAPPING | EVT_HOST: case EVT_FLAPPING | EVT_SERVICE: image = "flapping.gif"; break; + + case EVT_COMMAND: + image = "command.png"; + break; + + case EVT_LROTATE: + image = "logrotate.png"; + break; + + case EVT_EHANDLER | EVT_HOST: + image = "hostevent.gif"; + break; + + case EVT_EHANDLER | EVT_SERVICE: + image = "serviceevent.gif"; + break; } if (!image) @@ -258,13 +277,11 @@ static int parse_line(char *orig_line, uint len) print_line(EVT_PROCESS, line, len); } - handle_unknown_event(line); - return -1; + return 0; } if (!(sc = get_event_type(ptr, colon - ptr))) { - handle_unknown_event(line); - return -1; + return 0; } if (sc->code == IGNORE_LINE) @@ -340,8 +357,8 @@ static int parse_line(char *orig_line, uint len) print_line(sc->code, line, len); break; - case IGNORE_LINE: - return 0; + default: + print_line(sc->code, line, len); } return 0; -- 2.11.4.GIT