Minor usability fixes to config
This commit is contained in:
parent
82cbc4daa2
commit
13e6018eb0
|
@ -9,12 +9,8 @@ import (
|
||||||
"github.com/influxdb/tivan/plugins"
|
"github.com/influxdb/tivan/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
|
||||||
Address string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Mysql struct {
|
type Mysql struct {
|
||||||
Servers []*Server
|
Servers []string
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
|
@ -32,7 +28,7 @@ func (m *Mysql) Description() string {
|
||||||
return "Read metrics from one or many mysql servers"
|
return "Read metrics from one or many mysql servers"
|
||||||
}
|
}
|
||||||
|
|
||||||
var localhost = &Server{}
|
var localhost = ""
|
||||||
|
|
||||||
func (m *Mysql) Gather(acc plugins.Accumulator) error {
|
func (m *Mysql) Gather(acc plugins.Accumulator) error {
|
||||||
if len(m.Servers) == 0 {
|
if len(m.Servers) == 0 {
|
||||||
|
@ -80,8 +76,8 @@ var mappings = []*mapping{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mysql) gatherServer(serv *Server, acc plugins.Accumulator) error {
|
func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
|
||||||
db, err := sql.Open("mysql", serv.Address)
|
db, err := sql.Open("mysql", serv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ var sampleConfig = `
|
||||||
# to sslmode=disable as well.
|
# to sslmode=disable as well.
|
||||||
#
|
#
|
||||||
|
|
||||||
address = "localhost"
|
address = "sslmode=disable"
|
||||||
|
|
||||||
# A list of databases to pull metrics about. If not specified, metrics for all
|
# A list of databases to pull metrics about. If not specified, metrics for all
|
||||||
# databases are gathered.
|
# databases are gathered.
|
||||||
|
@ -69,6 +69,10 @@ func (p *Postgresql) Gather(acc plugins.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Postgresql) gatherServer(serv *Server, acc plugins.Accumulator) error {
|
func (p *Postgresql) gatherServer(serv *Server, acc plugins.Accumulator) error {
|
||||||
|
if serv.Address == "" {
|
||||||
|
serv = localhost
|
||||||
|
}
|
||||||
|
|
||||||
db, err := sql.Open("postgres", serv.Address)
|
db, err := sql.Open("postgres", serv.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -94,11 +94,19 @@ func (g *Redis) Gather(acc plugins.Accumulator) error {
|
||||||
return outerr
|
return outerr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultPort = "6379"
|
||||||
|
|
||||||
func (g *Redis) gatherServer(addr string, acc plugins.Accumulator) error {
|
func (g *Redis) gatherServer(addr string, acc plugins.Accumulator) error {
|
||||||
if g.c == nil {
|
if g.c == nil {
|
||||||
|
|
||||||
|
_, _, err := net.SplitHostPort(addr)
|
||||||
|
if err != nil {
|
||||||
|
addr = addr + ":" + defaultPort
|
||||||
|
}
|
||||||
|
|
||||||
c, err := net.Dial("tcp", addr)
|
c, err := net.Dial("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("Unable to connect to redis server '%s': %s", addr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.c = c
|
g.c = c
|
||||||
|
|
115
tivan.toml
115
tivan.toml
|
@ -1,44 +1,101 @@
|
||||||
# This config file tells tivan how and what to collect stats from this
|
# Tivan configuration
|
||||||
# system.
|
|
||||||
|
|
||||||
# These are the setting that govern the agents overall operation.
|
# Tivan is entirely plugin driven. All metrics are gathered from the
|
||||||
[agent]
|
# declared plugins.
|
||||||
|
|
||||||
# How often to gather stats. 5s = 5 seconds, 10m = 10 minutes, etc.
|
# Even if a plugin has no configuration, it must be declared in here
|
||||||
interval = "5s"
|
# to be active. Declaring a plugin means just specifying the name
|
||||||
|
# as a section with no variables.
|
||||||
|
|
||||||
# If the agent should run in debug mode, printing out the stats it
|
# Configuration for influxdb server to send metrics to
|
||||||
# gathers as well as sending them to InfluxDB.
|
# [influxdb]
|
||||||
debug = true
|
# url = "http://10.20.2.4"
|
||||||
|
# username = "tivan"
|
||||||
|
# password = "metricsmetricsmetricsmetrics"
|
||||||
|
# database = "tivan"
|
||||||
|
# user_agent = "tivan"
|
||||||
|
# tags = { "dc": "us-east-1" }
|
||||||
|
|
||||||
|
# Tags can also be specified via a normal map, but only one form at a time:
|
||||||
|
|
||||||
# This section governs how tivan talks to influxdb
|
# [influxdb.tags]
|
||||||
[influxdb]
|
# dc = "us-east-1"
|
||||||
|
|
||||||
# The location, in http url form, of your influxdb server
|
# PLUGINS
|
||||||
url = "http://localhost:8086"
|
|
||||||
|
|
||||||
# Username to connect to influx as
|
# Read metrics about cpu usage
|
||||||
username = "root"
|
[cpu]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
# Password for said user
|
# Read metrics about disk usage by mount point
|
||||||
password = "root"
|
[disk]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
# The database to store the metrics into
|
# Read metrics about docker containers
|
||||||
database = "tivan"
|
[docker]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
# A map of addition tags to apply to all metrics, for instance:
|
# Read metrics about disk IO by device
|
||||||
|
[io]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
|
# Read metrics about memory usage
|
||||||
|
[mem]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
|
# Read metrics from one or many mysql servers
|
||||||
|
[mysql]
|
||||||
|
|
||||||
|
# specify servers via a url matching:
|
||||||
|
# [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]]
|
||||||
#
|
#
|
||||||
# tags = { dc = "us-east-1" }
|
# If no servers are specified, then localhost is used as the host.
|
||||||
#
|
servers = ["localhost"]
|
||||||
# could be used to add a indicate which datacenter the metrics are
|
|
||||||
# coming from
|
|
||||||
|
|
||||||
# This section governs how and if tivan gathers stats from redis
|
# Read metrics about network interface usage
|
||||||
|
[net]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
|
# Read metrics from one or many postgresql servers
|
||||||
|
[postgresql]
|
||||||
|
|
||||||
|
# specify servers via an array of tables
|
||||||
|
[[postgresql.servers]]
|
||||||
|
|
||||||
|
# specify address via a url matching:
|
||||||
|
# postgres://[pqgotest[:password]]@localhost?sslmode=[disable|verify-ca|verify-full]
|
||||||
|
# or a simple string:
|
||||||
|
# host=localhost user=pqotest password=... sslmode=...
|
||||||
|
#
|
||||||
|
# All connection parameters are optional. By default, the host is localhost
|
||||||
|
# and the user is the currently running user. For localhost, we default
|
||||||
|
# to sslmode=disable as well.
|
||||||
|
#
|
||||||
|
|
||||||
|
address = "sslmode=disable"
|
||||||
|
|
||||||
|
# A list of databases to pull metrics about. If not specified, metrics for all
|
||||||
|
# databases are gathered.
|
||||||
|
|
||||||
|
# databases = ["app_production", "blah_testing"]
|
||||||
|
|
||||||
|
# [[postgresql.servers]]
|
||||||
|
# address = "influx@remoteserver"
|
||||||
|
|
||||||
|
# Read metrics from one or many redis servers
|
||||||
[redis]
|
[redis]
|
||||||
|
|
||||||
# Do not gather stats on redis, even if the address is configured
|
# An array of address to gather stats about. Specify an ip on hostname
|
||||||
# disabled = true
|
# with optional port. ie localhost, 10.10.3.33:18832, etc.
|
||||||
|
#
|
||||||
|
# If no servers are specified, then localhost is used as the host.
|
||||||
|
servers = ["localhost"]
|
||||||
|
|
||||||
|
# Read metrics about swap memory usage
|
||||||
|
[swap]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
|
# Read metrics about system load
|
||||||
|
[system]
|
||||||
|
# no configuration
|
||||||
|
|
||||||
# The address of your redis server to gather stats on
|
|
||||||
# address = ":6379"
|
|
||||||
|
|
Loading…
Reference in New Issue