summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 21234c8)
raw | patch | inline | side by side (parent: 21234c8)
author | Tahhan, Maryam <maryam.tahhan@intel.com> | |
Mon, 29 May 2017 13:04:39 +0000 (14:04 +0100) | ||
committer | Tahhan, Maryam <maryam.tahhan@intel.com> | |
Thu, 6 Jul 2017 13:38:17 +0000 (14:38 +0100) |
Make the logfile and socket options mutually exclusive as the collection
requirements for the 2 are different and the memory errors from the
socket overlap with the logfile. Set the default to memory errors until
the logfile changes are merged.
Change-Id: If1eef9d37f1ffe404cf679df4dca9ae3c92ab9ea
Signed-off-by: Tahhan, Maryam <maryam.tahhan@intel.com>
requirements for the 2 are different and the memory errors from the
socket overlap with the logfile. Set the default to memory errors until
the logfile changes are merged.
Change-Id: If1eef9d37f1ffe404cf679df4dca9ae3c92ab9ea
Signed-off-by: Tahhan, Maryam <maryam.tahhan@intel.com>
src/collectd.conf.pod | patch | blob | history | |
src/mcelog.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index c1c9461960ad3328c6b719876a5259f2da3a6e0b..c19ae734b933b1c6f9f6e425b49ce6a442a86a97 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=head3 The Memory block
+Note: these options cannot be used in conjunction with the logfile options, they are mutually
+exclusive.
+
=over 3
=item B<McelogClientSocket> I<Path>
=item B<McelogLogfile> I<Path>
-The mcelog file to parse. Defaults to B<"/var/log/mcelog">.
+The mcelog file to parse. Defaults to B<"/var/log/mcelog">. Note: this option
+cannot be used in conjunction with the memory block options, they are mutually
+exclusive.
=back
diff --git a/src/mcelog.c b/src/mcelog.c
index 23040c81bea765db8a9ac1c197419b674e47c5c5..865b0d128752a81ddd8d3a3bb878ee61305a60f2 100644 (file)
--- a/src/mcelog.c
+++ b/src/mcelog.c
}
static int mcelog_config(oconfig_item_t *ci) {
+ int use_logfile = 0, use_memory = 0;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (strcasecmp("McelogLogfile", child->key) == 0) {
+ use_logfile = 1;
+ if (use_memory) {
+ ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\", Memory "
+ "option is already configured.",
+ child->key);
+ return (-1);
+ }
if (cf_util_get_string_buffer(child, g_mcelog_config.logfile,
sizeof(g_mcelog_config.logfile)) < 0) {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
child->key);
return (-1);
}
+ memset(socket_adapter.unix_sock.sun_path, 0,
+ sizeof(socket_adapter.unix_sock.sun_path));
} else if (strcasecmp("Memory", child->key) == 0) {
+ if (use_logfile) {
+ ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\", Logfile "
+ "option is already configured.",
+ child->key);
+ return (-1);
+ }
+ use_memory = 1;
oconfig_item_t *mem_child = child->children;
for (int j = 0; j < child->children_num; j++) {
mem_child += j;
return (-1);
}
}
+ memset(g_mcelog_config.logfile, 0, sizeof(g_mcelog_config.logfile));
} else {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
child->key);
}
static int mcelog_init(void) {
+ if (g_mcelog_config.logfile != NULL &&
+ socket_adapter.unix_sock.sun_path != NULL) {
+ INFO(MCELOG_PLUGIN
+ ": No configuration selected defaulting to memory errors.");
+ memset(g_mcelog_config.logfile, 0, sizeof(g_mcelog_config.logfile));
+ }
g_mcelog_config.dimms_list = llist_create();
int err = pthread_mutex_init(&g_mcelog_config.dimms_lock, NULL);
if (err < 0) {
return (-1);
}
- if (plugin_thread_create(&g_mcelog_config.tid, NULL, poll_worker, NULL,
- NULL) != 0) {
- ERROR(MCELOG_PLUGIN ": Error creating poll thread.");
- return (-1);
+ if (socket_adapter.unix_sock.sun_path != NULL) {
+ if (plugin_thread_create(&g_mcelog_config.tid, NULL, poll_worker, NULL,
+ NULL) != 0) {
+ ERROR(MCELOG_PLUGIN ": Error creating poll thread.");
+ return (-1);
+ }
}
return (0);
}