Module: check_mk
Branch: master
Commit: cbdf4cf13414c5d83eaa7674542ad4091b886c53
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cbdf4cf13414c5…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Nov 2 09:40:57 2012 +0100
logwatch: windows agent now with ok pattern support
---
agents/windows/check_mk_agent.cc | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 75cd8f8..c9d988f 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -1514,14 +1514,16 @@ void add_globline(char *value)
// Split globline into tokens
if (value != 0) {
char *copy = strdup(value);
- char *token = strtok(copy, " ");
+ char *token = strtok(copy, "|");
while (token) {
+ token = lstrip(token);
new_globline->token[new_globline->num_tokens] = new
glob_token();
new_globline->token[new_globline->num_tokens]->pattern =
strdup(token);
process_glob_expression(new_globline->token[new_globline->num_tokens],
new_globline->patterns);
- token = strtok(NULL, " ");
+ token = strtok(NULL, "|");
new_globline->num_tokens++;
}
+ free(copy);
}
}
@@ -1599,22 +1601,22 @@ bool process_textfile(FILE *file, logwatch_textfile* textfile,
SOCKET &out, bool
if (!fgets(line, sizeof(line), file))
break;
+ if (line[strlen(line)-1] == '\n')
+ line[strlen(line)-1] = 0;
+
char state = '.';
for (int j=0; j < textfile->patterns->num_patterns; j++) {
pattern = textfile->patterns->patterns[j];
if (globmatch(pattern->glob_pattern, line)){
- if (!write_output && (pattern->state == 'C' ||
pattern->state == 'W'))
+ if (!write_output && (pattern->state == 'C' ||
pattern->state == 'W' || pattern->state == 'O'))
return true;
state = pattern->state;
break;
}
}
- if (write_output)
- output(out, "%c %s", state, line);
+ if (write_output && strlen(line) > 0)
+ output(out, "%c %s\n", state == 'O' ? 'I' : state,
line);
}
- // add an extra \n if the last logline was missing a newline character
- if (write_output && line[strlen(line)] != '\n')
- output(out, "\n");
return false;
}
@@ -2604,9 +2606,14 @@ bool handle_logfiles_config_variable(char *var, char *value)
if (value != 0)
add_condition_pattern('I', value);
return true;
+ }else if (!strcmp(var, "ok")) {
+ if (value != 0)
+ add_condition_pattern('O', value);
+ return true;
}
return false;
}
+
bool handle_logwatch_config_variable(char *var, char *value)
{
if (!strncmp(var, "logfile ", 8)) {