summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c6350b3)
raw | patch | inline | side by side (parent: c6350b3)
author | Tahhan, Maryam <maryam.tahhan@intel.com> | |
Mon, 27 Feb 2017 13:33:31 +0000 (13:33 +0000) | ||
committer | Tahhan, Maryam <maryam.tahhan@intel.com> | |
Thu, 6 Jul 2017 13:38:08 +0000 (14:38 +0100) |
Implement notification persist option and separate out memory block from the
rest of the configuration.
Change-Id: I48d946bb381d3cfc61fee91a31f3865802389eef
Signed-off-by: Tahhan, Maryam <maryam.tahhan@intel.com>
rest of the configuration.
Change-Id: I48d946bb381d3cfc61fee91a31f3865802389eef
Signed-off-by: Tahhan, Maryam <maryam.tahhan@intel.com>
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/mcelog.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index e2d6aafab9a7d52bf4fcc109103de73e2e9ef899..a0bfc15cfb1b895935665c9a4dd40c5871fe49eb 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#</Plugin>
#<Plugin mcelog>
-# McelogClientSocket "/var/run/mcelog-client"
-# McelogLogfile "/var/log/mcelog"
+# <Memory>
+# McelogClientSocket "/var/run/mcelog-client"
+# PersistentNotification false
+# </Memory>
+# McelogLogfile "/var/log/mcelog"
#</Plugin>
#<Plugin md>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 32020154fbed3156ed95b0d7a699fb2ee49acd09..c1c9461960ad3328c6b719876a5259f2da3a6e0b 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -3475,12 +3475,24 @@ client protocol to retrieve memory related machine check exceptions. Note that
for memory exceptions, notifications are only sent when there is a change in
the number of corrected/uncorrected memory errors.
-=over 4
+=head3 The Memory block
+
+=over 3
=item B<McelogClientSocket> I<Path>
Connect to the mcelog client socket using the UNIX domain socket at I<Path>.
Defaults to B<"/var/run/mcelog-client">.
+=item B<PersistentNotification> B<true>|B<false>
+Override default configuration to only send notifications when sent when there
+is a change in the number of corrected/uncorrected memory errors. When set to
+true notifications will be sent for every read cycle. Default is false. Does
+not affect the stats being dispatched.
+
+=back
+
+=over 4
+
=item B<McelogLogfile> I<Path>
The mcelog file to parse. Defaults to B<"/var/log/mcelog">.
diff --git a/src/mcelog.c b/src/mcelog.c
index 654305d3701b14c6f66270b6ac21266626bef9f3..23040c81bea765db8a9ac1c197419b674e47c5c5 100644 (file)
--- a/src/mcelog.c
+++ b/src/mcelog.c
* collectd - src/mcelog.c
* MIT License
*
- * Copyright(c) 2016 Intel Corporation. All rights reserved.
+ * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
pthread_t tid; /* poll thread id */
llist_t *dimms_list; /* DIMMs list */
/* lock for dimms cache */
+ _Bool persist;
pthread_mutex_t dimms_lock;
} mcelog_config_t;
static int socket_receive(socket_adapter_t *self, FILE **p_file);
static mcelog_config_t g_mcelog_config = {
- .logfile = "/var/log/mcelog",
+ .logfile = "/var/log/mcelog", .persist = 0,
};
static socket_adapter_t socket_adapter = {
sfree(e->key);
sfree(e->value);
}
-
}
/* Create or get dimm by dimm name/location */
pthread_mutex_lock(&g_mcelog_config.dimms_lock);
memcpy(dimm->value, rec, sizeof(mcelog_memory_rec_t));
pthread_mutex_unlock(&g_mcelog_config.dimms_lock);
-
}
static int mcelog_config(oconfig_item_t *ci) {
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
- if (strcasecmp("McelogClientSocket", child->key) == 0) {
- if (cf_util_get_string_buffer(child, socket_adapter.unix_sock.sun_path,
- sizeof(socket_adapter.unix_sock.sun_path)) <
- 0) {
- ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
- child->key);
- return (-1);
- }
- } else if (strcasecmp("McelogLogfile", child->key) == 0) {
+ if (strcasecmp("McelogLogfile", child->key) == 0) {
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);
}
+ } else if (strcasecmp("Memory", child->key) == 0) {
+ oconfig_item_t *mem_child = child->children;
+ for (int j = 0; j < child->children_num; j++) {
+ mem_child += j;
+ if (strcasecmp("McelogClientSocket", mem_child->key) == 0) {
+ if (cf_util_get_string_buffer(
+ mem_child, socket_adapter.unix_sock.sun_path,
+ sizeof(socket_adapter.unix_sock.sun_path)) < 0) {
+ ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
+ mem_child->key);
+ return (-1);
+ }
+ } else if (strcasecmp("PersistentNotification", mem_child->key) == 0) {
+ if (cf_util_get_boolean(mem_child, &g_mcelog_config.persist) < 0) {
+ ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
+ mem_child->key);
+ return (-1);
+ }
+ } else {
+ ERROR(MCELOG_PLUGIN ": Invalid Memory configuration option: \"%s\".",
+ mem_child->key);
+ return (-1);
+ }
+ }
} else {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
child->key);
llentry_t *dimm = mcelog_dimm(mr, g_mcelog_config.dimms_list);
if (dimm == NULL) {
- ERROR(MCELOG_PLUGIN ": Error adding/getting dimm memory item to/from cache");
- return -1;
+ ERROR(MCELOG_PLUGIN
+ ": Error adding/getting dimm memory item to/from cache");
+ return (-1);
}
-
mcelog_memory_rec_t *mr_old = dimm->value;
+ if (!g_mcelog_config.persist) {
- if (mr_old->corrected_err_total != mr->corrected_err_total ||
- mr_old->corrected_err_timed != mr->corrected_err_timed)
- dispatch_corrected_notifs = 1;
+ if (mr_old->corrected_err_total != mr->corrected_err_total ||
+ mr_old->corrected_err_timed != mr->corrected_err_timed)
+ dispatch_corrected_notifs = 1;
- if (mr_old->uncorrected_err_total != mr->uncorrected_err_total ||
- mr_old->uncorrected_err_timed != mr->uncorrected_err_timed)
- dispatch_uncorrected_notifs = 1;
+ if (mr_old->uncorrected_err_total != mr->uncorrected_err_total ||
+ mr_old->uncorrected_err_timed != mr->uncorrected_err_timed)
+ dispatch_uncorrected_notifs = 1;
- if (!dispatch_corrected_notifs && !dispatch_uncorrected_notifs) {
- DEBUG("%s: No new notifications to dispatch", MCELOG_PLUGIN);
- return (0);
+ if (!dispatch_corrected_notifs && !dispatch_uncorrected_notifs) {
+ DEBUG("%s: No new notifications to dispatch", MCELOG_PLUGIN);
+ return (0);
+ }
+ } else {
+ dispatch_corrected_notifs = 1;
+ dispatch_uncorrected_notifs = 1;
}
sstrncpy(n.host, hostname_g, sizeof(n.host));
llentry_t *dimm = mcelog_dimm(mr, g_mcelog_config.dimms_list);
if (dimm == NULL) {
- ERROR(MCELOG_PLUGIN ": Error adding/getting dimm memory item to/from cache");
- return -1;
+ ERROR(MCELOG_PLUGIN
+ ": Error adding/getting dimm memory item to/from cache");
+ return (-1);
}
value_list_t vl = {