code refactor
This commit is contained in:
parent
8fc15dc671
commit
a3b7470349
|
@ -11,7 +11,8 @@ password = "1234"
|
|||
|
||||
extra_status_metrics = true
|
||||
extra_innodb_metrics = false
|
||||
gather_process_list = true
|
||||
gather_processlist_processes_by_state = false
|
||||
gather_processlist_processes_by_user = true
|
||||
|
||||
# # timeout
|
||||
# timeout_seconds = 3
|
||||
|
|
|
@ -31,7 +31,8 @@ type Instance struct {
|
|||
|
||||
ExtraStatusMetrics bool `toml:"extra_status_metrics"`
|
||||
ExtraInnodbMetrics bool `toml:"extra_innodb_metrics"`
|
||||
GatherProcessList bool `toml:"gather_process_list"`
|
||||
GatherProcessListProcessByState bool `toml:"gather_processlist_processes_by_state"`
|
||||
GatherProcessListProcessByUser bool `toml:"gather_processlist_processes_by_user"`
|
||||
|
||||
validMetrics map[string]struct{}
|
||||
dsn string
|
||||
|
@ -234,6 +235,6 @@ func (m *MySQL) gatherOnce(slist *list.SafeList, ins *Instance) {
|
|||
m.gatherEngineInnodbStatus(slist, ins, db, tags, cache)
|
||||
m.gatherEngineInnodbStatusCompute(slist, ins, db, tags, cache)
|
||||
m.gatherBinlog(slist, ins, db, tags, cache)
|
||||
m.gatherProcesslist(slist, ins, db, tags, cache)
|
||||
m.gatherProcesslistByState(slist, ins, db, tags, cache)
|
||||
m.gatherProcesslistByUser(slist, ins, db, tags, cache)
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
func (m *MySQL) gatherProcesslist(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) {
|
||||
if !ins.GatherProcessList {
|
||||
func (m *MySQL) gatherProcesslistByState(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) {
|
||||
if !ins.GatherProcessListProcessByState {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ func (m *MySQL) gatherProcesslist(slist *list.SafeList, ins *Instance, db *sql.D
|
|||
}
|
||||
|
||||
for s, c := range stateCounts {
|
||||
slist.PushFront(inputs.NewSample("process_list_threads", c, labels, map[string]string{"state": s}))
|
||||
slist.PushFront(inputs.NewSample("processlist_processes_by_state", c, labels, map[string]string{"state": s}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func (m *MySQL) gatherProcesslistByUser(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string, cache map[string]float64) {
|
||||
if !ins.GatherProcessList {
|
||||
if !ins.GatherProcessListProcessByUser {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue