code refactor
This commit is contained in:
parent
11ead55c91
commit
84bcff5987
|
@ -0,0 +1,11 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/toolkits/pkg/container/list"
|
||||
)
|
||||
|
||||
func (m *MySQL) gatherGlobalStatus(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/toolkits/pkg/container/list"
|
||||
)
|
||||
|
||||
func (m *MySQL) gatherGlobalVariables(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) {
|
||||
|
||||
}
|
|
@ -147,13 +147,19 @@ func (m *MySQL) gatherOnce(slist *list.SafeList, ins *Instance) {
|
|||
return
|
||||
}
|
||||
|
||||
slist.PushFront(inputs.NewSample("up", 1, tags))
|
||||
defer db.Close()
|
||||
|
||||
db.SetMaxOpenConns(1)
|
||||
db.SetMaxIdleConns(1)
|
||||
db.SetConnMaxLifetime(time.Minute)
|
||||
|
||||
if err = db.Ping(); err != nil {
|
||||
slist.PushFront(inputs.NewSample("up", 0, tags))
|
||||
log.Println("E! failed to ping mysql:", err)
|
||||
}
|
||||
|
||||
slist.PushFront(inputs.NewSample("up", 1, tags))
|
||||
|
||||
m.gatherGlobalStatus(slist, ins, db, tags)
|
||||
|
||||
}
|
||||
|
||||
func (m *MySQL) gatherGlobalStatus(slist *list.SafeList, ins *Instance, db *sql.DB, globalTags map[string]string) {
|
||||
|
||||
m.gatherGlobalVariables(slist, ins, db, tags)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue