diff --git a/inputs/mysql/binlog.go b/inputs/mysql/binlog.go index daa9901..b569e8e 100644 --- a/inputs/mysql/binlog.go +++ b/inputs/mysql/binlog.go @@ -11,7 +11,7 @@ import ( "github.com/toolkits/pkg/container/list" ) -func (m *MySQL) gatherBinlog(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) { +func (m *MySQL) gatherBinlog(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) { var logBin uint8 err := db.QueryRow(`SELECT @@log_bin`).Scan(&logBin) if err != nil { diff --git a/inputs/mysql/mysql.go b/inputs/mysql/mysql.go index b62bfbd..7a7142b 100644 --- a/inputs/mysql/mysql.go +++ b/inputs/mysql/mysql.go @@ -238,11 +238,11 @@ func (m *MySQL) gatherOnce(slist *list.SafeList, ins *Instance) { m.gatherGlobalVariables(slist, ins, db, tags, cache) m.gatherEngineInnodbStatus(slist, ins, db, tags, cache) m.gatherEngineInnodbStatusCompute(slist, ins, db, tags, cache) - m.gatherBinlog(slist, ins, db, tags, cache) - m.gatherProcesslistByState(slist, ins, db, tags, cache) - m.gatherProcesslistByUser(slist, ins, db, tags, cache) - m.gatherSchemaSize(slist, ins, db, tags, cache) - m.gatherTableSize(slist, ins, db, tags, cache, false) - m.gatherTableSize(slist, ins, db, tags, cache, true) - m.gatherSlaveStatus(slist, ins, db, tags, cache) + m.gatherBinlog(slist, ins, db, tags) + m.gatherProcesslistByState(slist, ins, db, tags) + m.gatherProcesslistByUser(slist, ins, db, tags) + m.gatherSchemaSize(slist, ins, db, tags) + m.gatherTableSize(slist, ins, db, tags, false) + m.gatherTableSize(slist, ins, db, tags, true) + m.gatherSlaveStatus(slist, ins, db, tags) } diff --git a/inputs/mysql/processlist.go b/inputs/mysql/processlist.go index 1b8f960..2fde3aa 100644 --- a/inputs/mysql/processlist.go +++ b/inputs/mysql/processlist.go @@ -90,7 +90,7 @@ var ( } ) -func (m *MySQL) gatherProcesslistByState(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) { +func (m *MySQL) gatherProcesslistByState(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) { if !ins.GatherProcessListProcessByState { return } diff --git a/inputs/mysql/processlist_by_user.go b/inputs/mysql/processlist_by_user.go index 29e761b..bb4692c 100644 --- a/inputs/mysql/processlist_by_user.go +++ b/inputs/mysql/processlist_by_user.go @@ -9,7 +9,7 @@ import ( "github.com/toolkits/pkg/container/list" ) -func (m *MySQL) gatherProcesslistByUser(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) { +func (m *MySQL) gatherProcesslistByUser(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) { if !ins.GatherProcessListProcessByUser { return } diff --git a/inputs/mysql/schema_size.go b/inputs/mysql/schema_size.go index 1c55ba8..b37468a 100644 --- a/inputs/mysql/schema_size.go +++ b/inputs/mysql/schema_size.go @@ -9,7 +9,7 @@ import ( "github.com/toolkits/pkg/container/list" ) -func (m *MySQL) gatherSchemaSize(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) { +func (m *MySQL) gatherSchemaSize(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) { if !ins.GatherSchemaSize { return } diff --git a/inputs/mysql/slave_status.go b/inputs/mysql/slave_status.go index 3cbe986..0df3293 100644 --- a/inputs/mysql/slave_status.go +++ b/inputs/mysql/slave_status.go @@ -14,7 +14,7 @@ import ( var slaveStatusQueries = [2]string{"SHOW ALL SLAVES STATUS", "SHOW SLAVE STATUS"} var slaveStatusQuerySuffixes = [3]string{" NONBLOCKING", " NOLOCK", ""} -func (m *MySQL) gatherSlaveStatus(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) { +func (m *MySQL) gatherSlaveStatus(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) { if !ins.GatherSlaveStatus { return } @@ -89,6 +89,11 @@ func (m *MySQL) gatherSlaveStatus(slist *list.SafeList, ins *Instance, db *sql.D textItems["channel_name"] = textItems["connection_name"] } + // default channel name is empty + if textItems["channel_name"] == "" { + textItems["channel_name"] = "default" + } + for k, v := range fields { slist.PushFront(inputs.NewSample("slave_status_"+k, v, tags, map[string]string{ "master_host": textItems["master_host"], diff --git a/inputs/mysql/table_size.go b/inputs/mysql/table_size.go index ad9967e..62a8c6a 100644 --- a/inputs/mysql/table_size.go +++ b/inputs/mysql/table_size.go @@ -9,7 +9,7 @@ import ( "github.com/toolkits/pkg/container/list" ) -func (m *MySQL) gatherTableSize(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64, isSystem bool) { +func (m *MySQL) gatherTableSize(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, isSystem bool) { query := SQL_QUERY_TABLE_SIZE if isSystem { query = SQL_QUERY_SYSTEM_TABLE_SIZE