From c8b77392370a48264ff88de050eec2e526de2058 Mon Sep 17 00:00:00 2001 From: Matteo Cerutti Date: Fri, 26 May 2017 20:09:43 +0100 Subject: [PATCH] MySQL input: log and continue on field parse error (#2855) --- plugins/inputs/mysql/mysql.go | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index e3861c82f..77ca7e47e 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -858,42 +858,45 @@ func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accum case "Queries": i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) if err != nil { - return err + acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err)) + } else { + fields["queries"] = i } - - fields["queries"] = i case "Questions": i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) if err != nil { - return err + acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err)) + } else { + fields["questions"] = i } - - fields["questions"] = i case "Slow_queries": i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) if err != nil { - return err + acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err)) + } else { + fields["slow_queries"] = i } - - fields["slow_queries"] = i case "Connections": i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) if err != nil { - return err + acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err)) + } else { + fields["connections"] = i } - fields["connections"] = i case "Syncs": i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) if err != nil { - return err + acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err)) + } else { + fields["syncs"] = i } - fields["syncs"] = i case "Uptime": i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) if err != nil { - return err + acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err)) + } else { + fields["uptime"] = i } - fields["uptime"] = i } } // Send any remaining fields