From: Przemyslaw Szczerbik Date: Thu, 19 Jan 2017 10:59:29 +0000 (+0000) Subject: mcelog: Check if location was correctly parsed X-Git-Tag: collectd-5.8.0~239^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8860aa692de10bbd6b9e56ef42d1b103564e1432;p=collectd.git mcelog: Check if location was correctly parsed Avoid dispatching metrics if location (used as plugin instance) wasn't parsed correctly. Such thing can occur when there are no machine check exceptions reported by mcelog server. With csv plugin enabled, it was causing a creation of unexpected mcelog directory with all files (metrics) filled out with 0's. Change-Id: Ib01f355a986ee5c6191cd126e1b32ef956ffce1f Signed-off-by: Przemyslaw Szczerbik --- diff --git a/src/mcelog.c b/src/mcelog.c index 7299d117..78888cfa 100644 --- a/src/mcelog.c +++ b/src/mcelog.c @@ -435,6 +435,11 @@ static void *poll_worker(__attribute__((unused)) void *arg) { mcelog_memory_rec_t memory_record = {0}; while (parse_memory_info(*pp_file, &memory_record)) { + /* Check if location was successfully parsed */ + if (memory_record.location[0] == '\0') { + memset(&memory_record, 0, sizeof(memory_record)); + continue; + } notification_t n = {NOTIF_OKAY, cdtime(), "", "", MCELOG_PLUGIN, "", "", "", NULL}; ssnprintf(n.message, sizeof(n.message), "Got memory errors info.");