From b16bc3d2e35f9ef032b8b3f1aa8a31b6fd3fff0f Mon Sep 17 00:00:00 2001 From: Maksadbek Date: Fri, 26 Feb 2016 01:35:27 +0500 Subject: [PATCH] remove duplicate function; Mysql plugin GatherTableSchema is configurable --- plugins/inputs/mysql/mysql.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/inputs/mysql/mysql.go b/plugins/inputs/mysql/mysql.go index a4de7e602..0220394b2 100644 --- a/plugins/inputs/mysql/mysql.go +++ b/plugins/inputs/mysql/mysql.go @@ -24,6 +24,7 @@ type Mysql struct { GatherBinaryLogs bool GatherTableIOWaits bool GatherIndexIOWaits bool + GatherTableSchema bool } var sampleConfig = ` @@ -44,6 +45,7 @@ var sampleConfig = ` GatherBinaryLogs = false GatherTableIOWaits = false GatherIndexIOWaits = false + GatherTableSchema = false ` var defaultTimeout = time.Second * time.Duration(5) @@ -448,14 +450,11 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error { return err } - err = m.gatherTableSchema(db, serv, acc) - if err != nil { - return err - } - - err = m.gatherTableSchema(db, serv, acc) - if err != nil { - return err + if m.GatherTableSchema { + err = m.gatherTableSchema(db, serv, acc) + if err != nil { + return err + } } return nil } @@ -484,7 +483,7 @@ func (m *Mysql) gatherGlobalVariables(db *sql.DB, serv string, acc telegraf.Accu fields[key] = floatVal } } - acc.Add("mysql_variables", fields, tags) + acc.AddFields("mysql_variables", fields, tags) return nil }