mcelog: Check if location was correctly parsed
authorPrzemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
Thu, 19 Jan 2017 10:59:29 +0000 (10:59 +0000)
committerPrzemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
Thu, 19 Jan 2017 12:33:31 +0000 (12:33 +0000)
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 <przemyslawx.szczerbik@intel.com>
src/mcelog.c

index 7299d11..78888cf 100644 (file)
@@ -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.");