Add rule about 'localhost'
This commit is contained in:
@@ -135,6 +135,11 @@ var header = `# Tivan configuration
|
||||
# Use 'tivan -config tivan.toml -test' to see what metrics a config
|
||||
# file would generate.
|
||||
|
||||
# One rule that plugins conform is wherever a connection string
|
||||
# can be passed, the values '' and 'localhost' are treated specially.
|
||||
# They indicate to the plugin to use their own builtin configuration to
|
||||
# connect to the local system.
|
||||
|
||||
# Configuration for influxdb server to send metrics to
|
||||
# [influxdb]
|
||||
# url = "http://10.20.2.4"
|
||||
|
||||
@@ -77,6 +77,10 @@ var mappings = []*mapping{
|
||||
}
|
||||
|
||||
func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
|
||||
if serv == "localhost" {
|
||||
serv = ""
|
||||
}
|
||||
|
||||
db, err := sql.Open("mysql", serv)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -69,7 +69,7 @@ func (p *Postgresql) Gather(acc plugins.Accumulator) error {
|
||||
}
|
||||
|
||||
func (p *Postgresql) gatherServer(serv *Server, acc plugins.Accumulator) error {
|
||||
if serv.Address == "" {
|
||||
if serv.Address == "" || serv.Address == "localhost" {
|
||||
serv = localhost
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
# to be active. Declaring a plugin means just specifying the name
|
||||
# as a section with no variables.
|
||||
|
||||
# Use 'tivan -config tivan.toml -test' to see what metrics a config
|
||||
# file would generate.
|
||||
|
||||
# One rule that plugins conform is wherever a connection string
|
||||
# can be passed, the values '' and 'localhost' are treated specially.
|
||||
# They indicate to the plugin to use their own builtin configuration to
|
||||
# connect to the local system.
|
||||
|
||||
# Configuration for influxdb server to send metrics to
|
||||
# [influxdb]
|
||||
# url = "http://10.20.2.4"
|
||||
|
||||
Reference in New Issue
Block a user