From 7ca06f501f16b2fa7b821dcbaa0f13fbf9d512f4 Mon Sep 17 00:00:00 2001 From: Kamil Wiatrowski Date: Thu, 25 Apr 2019 15:09:00 +0200 Subject: [PATCH] logparser plugin: move utils_* to src/utils move utils_* to src/utils minor doc fixes Change-Id: I287dff4639b2fa59418cac3e16093b240119f945 Signed-off-by: Kamil Wiatrowski --- Makefile.am | 26 +++++++++---------- configure.ac | 2 +- src/collectd.conf.pod | 17 +++++++----- src/logparser.c | 4 +-- src/utils/match/match.c | 1 - .../message_parser/message_parser.c} | 10 +++---- .../message_parser/message_parser.h} | 2 +- .../message_parser/message_parser_test.c} | 4 +-- src/utils/tail/tail.c | 2 +- 9 files changed, 35 insertions(+), 33 deletions(-) rename src/{utils_message_parser.c => utils/message_parser/message_parser.c} (97%) rename src/{utils_message_parser.h => utils/message_parser/message_parser.h} (99%) rename src/{utils_message_parser_test.c => utils/message_parser/message_parser_test.c} (99%) diff --git a/Makefile.am b/Makefile.am index f2f01cd0f..17faaa914 100644 --- a/Makefile.am +++ b/Makefile.am @@ -362,15 +362,15 @@ test_utils_heap_SOURCES = \ test_utils_heap_LDADD = libheap.la $(COMMON_LIBS) test_utils_message_parser_SOURCES = \ - src/utils_message_parser_test.c \ + src/utils/message_parser/message_parser_test.c \ src/testing.h \ src/daemon/configfile.c \ src/daemon/types_list.c \ src/utils_tail_match.c src/utils_tail_match.h \ - src/utils_tail.c src/utils_tail.h \ - src/utils_match.c src/utils_match.h \ - src/utils_latency.c src/utils_latency.h \ - src/utils_latency_config.c src/utils_latency_config.h + src/utils/tail/tail.c src/utils/tail/tail.h \ + src/utils/match/match.c src/utils/match/match.h \ + src/utils/latency/latency.c src/utils/latency/latency.h \ + src/utils/latency/latency_config.c src/utils/latency/latency_config.h test_utils_message_parser_CPPFLAGS = $(AM_CPPFLAGS) test_utils_message_parser_LDADD = liboconfig.la libplugin_mock.la -lm @@ -1217,20 +1217,20 @@ endif if BUILD_PLUGIN_LOGPARSER pkglib_LTLIBRARIES += logparser.la logparser_la_SOURCES = src/logparser.c \ - src/utils_message_parser.c src/utils_message_parser.h \ + src/utils/message_parser/message_parser.c src/utils/message_parser/message_parser.h \ src/utils_tail_match.c src/utils_tail_match.h \ - src/utils_tail.c src/utils_tail.h \ - src/utils_match.c src/utils_match.h \ - src/utils_latency.c src/utils_latency.h \ - src/utils_latency_config.c src/utils_latency_config.h + src/utils/tail/tail.c src/utils/tail/tail.h \ + src/utils/match/match.c src/utils/match/match.h \ + src/utils/latency/latency.c src/utils/latency/latency.h \ + src/utils/latency/latency_config.c src/utils/latency/latency_config.h logparser_la_CPPFLAGS = $(AM_CPPFLAGS) logparser_la_LDFLAGS = $(PLUGIN_LDFLAGS) -lm test_plugin_logparser_SOURCES = src/logparser_test.c \ - src/utils_message_parser.c \ + src/utils/message_parser/message_parser.c \ src/utils_tail_match.c src/utils_tail_match.h \ - src/utils_tail.c src/utils_tail.h \ - src/utils_match.c src/utils_match.h \ + src/utils/tail/tail.c src/utils/tail/tail.h \ + src/utils/match/match.c src/utils/match/match.h \ src/daemon/configfile.c \ src/daemon/types_list.c test_plugin_logparser_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/configure.ac b/configure.ac index efa440a39..6e2a41b4a 100644 --- a/configure.ac +++ b/configure.ac @@ -6788,7 +6788,7 @@ AC_PLUGIN([java], [$with_java], [Embed the Java Vi AC_PLUGIN([load], [$plugin_load], [System load]) AC_PLUGIN([log_logstash], [$plugin_log_logstash], [Logstash json_event compatible logging]) AC_PLUGIN([logfile], [yes], [File logging plugin]) -AC_PLUGIN([logparser], [yes], [Log parsing plugin]) +AC_PLUGIN([logparser], [yes], [Log parsing plugin]) AC_PLUGIN([lpar], [$with_perfstat], [AIX logical partitions statistics]) AC_PLUGIN([lua], [$with_liblua], [Lua plugin]) AC_PLUGIN([madwifi], [$have_linux_wireless_h], [Madwifi wireless statistics]) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 25e0f8e62..602b6d468 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -4061,23 +4061,26 @@ B blocks which are defined below. =item B I|I -Set to true if want to read the file from the beginning first time. +Set to true if the file has to be parsed from the beginning on the first read. +If false only subsequent writes to log file will be parsed. =item B I -B block contains matches to search the log file for. +B block contains matches to search the log file for. Each B +block builds a notification message using matched elements if its mandatory +B blocks are matched. =item B I -Sets the default plugin instance. +Sets the default value for the plugin instance of the notification. =item B I -Sets the default type. +Sets the default value for the type of the notification. =item B I -Sets the default type instance. +Sets the default value for the type instance of the notification. =item B I @@ -4120,11 +4123,11 @@ optional. Default value is set to true. If set to true, it sets plugin instance to string returned by regex. It can be overridden by user string. -=item B I|I +=item B I|I Sets notification type using rules like B. -=item B I|I +=item B I|I Sets notification type instance using rules like above. diff --git a/src/logparser.c b/src/logparser.c index 4a7b3cbe2..c326ce865 100644 --- a/src/logparser.c +++ b/src/logparser.c @@ -27,9 +27,9 @@ #include "collectd.h" -#include "common.h" +#include "utils/common/common.h" +#include "utils/message_parser/message_parser.h" #include "utils_llist.h" -#include "utils_message_parser.h" #define PLUGIN_NAME "logparser" diff --git a/src/utils/match/match.c b/src/utils/match/match.c index c9bbd7b49..ca6f1aaa7 100644 --- a/src/utils/match/match.c +++ b/src/utils/match/match.c @@ -33,7 +33,6 @@ #include -#define UTILS_MATCH_FLAGS_REGEX 0x04 #define UTILS_MATCH_FLAGS_EXCLUDE_REGEX 0x02 #define UTILS_MATCH_FLAGS_REGEX 0x04 diff --git a/src/utils_message_parser.c b/src/utils/message_parser/message_parser.c similarity index 97% rename from src/utils_message_parser.c rename to src/utils/message_parser/message_parser.c index 1f48e2af9..60ca0d89c 100644 --- a/src/utils_message_parser.c +++ b/src/utils/message_parser/message_parser.c @@ -1,5 +1,5 @@ /* - * collectd - src/utils_message_parser.c + * collectd - src/utils/message_parser/message_parser.c * MIT License * * Copyright(c) 2017-2018 Intel Corporation. All rights reserved. @@ -29,10 +29,10 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" -#include "utils_message_parser.h" +#include "utils/message_parser/message_parser.h" #define UTIL_NAME "utils_message_parser" @@ -91,8 +91,8 @@ static int start_message_assembly(parser_job_data_t *self) { if (self->message_idx >= self->messages_max_len) { INFO(UTIL_NAME ": Exceeded message buffer size: %zu", self->messages_max_len); - if (self->resize_message_buffer( - self, self->messages_max_len + MSG_STOR_INC_STEP) != 0) { + if (self->resize_message_buffer(self, self->messages_max_len + + MSG_STOR_INC_STEP) != 0) { ERROR(UTIL_NAME ": Insufficient message buffer size: %zu. Remaining " "messages for this read will be skipped", self->messages_max_len); diff --git a/src/utils_message_parser.h b/src/utils/message_parser/message_parser.h similarity index 99% rename from src/utils_message_parser.h rename to src/utils/message_parser/message_parser.h index cd7e192cf..5ae91b53a 100644 --- a/src/utils_message_parser.h +++ b/src/utils/message_parser/message_parser.h @@ -1,5 +1,5 @@ /* - * collectd - src/utils_message_parser.h + * collectd - src/utils/message_parser/message_parser.h * MIT License * * Copyright(c) 2017-2018 Intel Corporation. All rights reserved. diff --git a/src/utils_message_parser_test.c b/src/utils/message_parser/message_parser_test.c similarity index 99% rename from src/utils_message_parser_test.c rename to src/utils/message_parser/message_parser_test.c index e63e69471..8cb5dc121 100644 --- a/src/utils_message_parser_test.c +++ b/src/utils/message_parser/message_parser_test.c @@ -1,5 +1,5 @@ /** - * collectd - src/utils_message_parser_test.c + * collectd - src/utils/message_parser/message_parser_test.c * * Copyright(c) 2018 Intel Corporation. All rights reserved. * @@ -26,7 +26,7 @@ **/ #include "testing.h" -#include "utils_message_parser.c" +#include "utils/message_parser/message_parser.c" #define TEST_PATTERN_NAME "test_pattern_name" #define TEST_REGEX "test_regex" diff --git a/src/utils/tail/tail.c b/src/utils/tail/tail.c index 088248587..0fdf174ea 100644 --- a/src/utils/tail/tail.c +++ b/src/utils/tail/tail.c @@ -72,7 +72,7 @@ static int cu_tail_reopen(cu_tail_t *obj, bool force_rewind) { * if we re-open the same file again or the file opened is the first at all * or the first after an error */ if ((obj->stat.st_ino == 0) || (obj->stat.st_ino == stat_buf.st_ino)) - seek_end = force_rewind ? false : true; + seek_end = !force_rewind; FILE *fh = fopen(obj->file, "r"); if (fh == NULL) { -- 2.47.2