]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
logparser plugin: move utils_* to src/utils 3045/head
authorKamil Wiatrowski <kamilx.wiatrowski@intel.com>
Thu, 25 Apr 2019 13:09:00 +0000 (15:09 +0200)
committerKamil Wiatrowski <kamilx.wiatrowski@intel.com>
Tue, 3 Dec 2019 10:34:16 +0000 (11:34 +0100)
move utils_* to src/utils
minor doc fixes

Change-Id: I287dff4639b2fa59418cac3e16093b240119f945
Signed-off-by: Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
Makefile.am
configure.ac
src/collectd.conf.pod
src/logparser.c
src/utils/match/match.c
src/utils/message_parser/message_parser.c [moved from src/utils_message_parser.c with 97% similarity]
src/utils/message_parser/message_parser.h [moved from src/utils_message_parser.h with 99% similarity]
src/utils/message_parser/message_parser_test.c [moved from src/utils_message_parser_test.c with 99% similarity]
src/utils/tail/tail.c

index f2f01cd0f7315f03e42e9b5c1d6109f4602ca70a..17faaa914333ea868fe621b935f01c2491120d69 100644 (file)
@@ -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)
index efa440a39c3528ad077bc7c219beaf06849c7d03..6e2a41b4a5fe4afef220a0139181ea5abad4168b 100644 (file)
@@ -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])
index 25e0f8e62977bc2e50ceb58de606aff933965e2c..602b6d468aaeb45317707721282e5c56238a9700 100644 (file)
@@ -4061,23 +4061,26 @@ B<Message> blocks which are defined below.
 
 =item B<FirstFullRead> I<true>|I<false>
 
-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<Message> I<Name>
 
-B<Message> block contains matches to search the log file for.
+B<Message> block contains matches to search the log file for. Each B<Message>
+block builds a notification message using matched elements if its mandatory
+B<Match> blocks are matched.
 
 =item B<DefaultPluginInstance> I<String>
 
-Sets the default plugin instance.
+Sets the default value for the plugin instance of the notification.
 
 =item B<DefaultType> I<String>
 
-Sets the default type.
+Sets the default value for the type of the notification.
 
 =item B<DefaultTypeInstance> I<String>
 
-Sets the default type instance.
+Sets the default value for the type instance of the notification.
 
 =item B<DefaultSeverity> I<String>
 
@@ -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<Tyoe> I<true>|I<String>
+=item B<Type> I<true>|I<String>
 
 Sets notification type using rules like B<PluginInstance>.
 
-=item B<TyoeInstance> I<true>|I<String>
+=item B<TypeInstance> I<true>|I<String>
 
 Sets notification type instance using rules like above.
 
index 4a7b3cbe2b60fd591149add891542d37b8cd751d..c326ce865c83f112c61e34f118a2269e3013a729 100644 (file)
@@ -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"
 
index c9bbd7b495e723337609349eefaabb879d3346a7..ca6f1aaa7779a86b2a54da95636b3ab52e56f6aa 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <regex.h>
 
-#define UTILS_MATCH_FLAGS_REGEX 0x04
 #define UTILS_MATCH_FLAGS_EXCLUDE_REGEX 0x02
 #define UTILS_MATCH_FLAGS_REGEX 0x04
 
similarity index 97%
rename from src/utils_message_parser.c
rename to src/utils/message_parser/message_parser.c
index 1f48e2af905782fdb41090facb68de851a3908d2..60ca0d89c0763c731f445c93cffa9443bb6e0bb1 100644 (file)
@@ -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.
 
 #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);
similarity index 99%
rename from src/utils_message_parser.h
rename to src/utils/message_parser/message_parser.h
index cd7e192cf2837c875a0414792abe8ac119b88dcc..5ae91b53ae2812c8411d6cab56b68fb8766468ae 100644 (file)
@@ -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.
similarity index 99%
rename from src/utils_message_parser_test.c
rename to src/utils/message_parser/message_parser_test.c
index e63e694711b2db3dc7f8f35bbc9aa18158331b07..8cb5dc12130d3a907bc376d94a36b38b83b54d7c 100644 (file)
@@ -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"
index 088248587d961ad10370f38c20e8e6ca15bf8cfe..0fdf174eab6a35b6dda2056f16e219eee66938af 100644 (file)
@@ -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) {