2015-05-29 19:50:05 +00:00
|
|
|
package collectd
|
|
|
|
|
2015-06-09 02:44:42 +00:00
|
|
|
import (
|
|
|
|
"time"
|
2015-06-09 03:38:38 +00:00
|
|
|
|
|
|
|
"github.com/influxdb/influxdb/toml"
|
2015-06-09 02:44:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2015-11-05 20:51:42 +00:00
|
|
|
// DefaultBindAddress is the default port to bind to
|
2015-06-09 02:44:42 +00:00
|
|
|
DefaultBindAddress = ":25826"
|
|
|
|
|
2015-11-05 20:51:42 +00:00
|
|
|
// DefaultDatabase is the default DB to write to
|
2015-06-09 02:44:42 +00:00
|
|
|
DefaultDatabase = "collectd"
|
|
|
|
|
2015-11-05 20:51:42 +00:00
|
|
|
// DefaultRetentionPolicy is the default retention policy of the writes
|
2015-06-09 02:44:42 +00:00
|
|
|
DefaultRetentionPolicy = ""
|
|
|
|
|
2015-11-05 20:51:42 +00:00
|
|
|
// DefaultBatchSize is the default write batch size.
|
|
|
|
DefaultBatchSize = 5000
|
2015-09-08 22:18:14 +00:00
|
|
|
|
2015-11-05 20:51:42 +00:00
|
|
|
// DefaultBatchPending is the default number of pending write batches.
|
|
|
|
DefaultBatchPending = 10
|
2015-06-09 02:44:42 +00:00
|
|
|
|
2015-11-05 20:51:42 +00:00
|
|
|
// DefaultBatchTimeout is the default batch timeout.
|
2015-06-09 03:38:38 +00:00
|
|
|
DefaultBatchDuration = toml.Duration(10 * time.Second)
|
2015-06-09 02:44:42 +00:00
|
|
|
|
|
|
|
DefaultTypesDB = "/usr/share/collectd/types.db"
|
2015-11-05 20:51:42 +00:00
|
|
|
|
|
|
|
// DefaultUDPReadBuffer is the default UDP read buffer
|
2015-11-05 21:35:07 +00:00
|
|
|
// Sets the size of the operating system's receive buffer associated with
|
|
|
|
// the UDP traffic
|
2015-11-05 20:51:42 +00:00
|
|
|
DefaultReadBuffer = 8 * 1024 * 1024
|
2015-06-09 02:44:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config represents a configuration for the collectd service.
|
2015-05-29 19:50:05 +00:00
|
|
|
type Config struct {
|
2015-06-09 02:44:42 +00:00
|
|
|
Enabled bool `toml:"enabled"`
|
|
|
|
BindAddress string `toml:"bind-address"`
|
|
|
|
Database string `toml:"database"`
|
|
|
|
RetentionPolicy string `toml:"retention-policy"`
|
|
|
|
BatchSize int `toml:"batch-size"`
|
2015-09-08 22:18:14 +00:00
|
|
|
BatchPending int `toml:"batch-pending"`
|
2015-06-09 03:38:38 +00:00
|
|
|
BatchDuration toml.Duration `toml:"batch-timeout"`
|
2015-11-05 20:51:42 +00:00
|
|
|
ReadBuffer int `toml:"read-buffer"`
|
2015-06-09 02:44:42 +00:00
|
|
|
TypesDB string `toml:"typesdb"`
|
2015-05-29 19:50:05 +00:00
|
|
|
}
|
2015-06-05 20:40:18 +00:00
|
|
|
|
2015-06-09 02:44:42 +00:00
|
|
|
// NewConfig returns a new instance of Config with defaults.
|
2015-06-05 20:40:18 +00:00
|
|
|
func NewConfig() Config {
|
2015-06-09 02:44:42 +00:00
|
|
|
return Config{
|
|
|
|
BindAddress: DefaultBindAddress,
|
|
|
|
Database: DefaultDatabase,
|
|
|
|
RetentionPolicy: DefaultRetentionPolicy,
|
2015-11-05 20:51:42 +00:00
|
|
|
ReadBuffer: DefaultReadBuffer,
|
2015-06-09 02:44:42 +00:00
|
|
|
BatchSize: DefaultBatchSize,
|
2015-09-08 22:18:14 +00:00
|
|
|
BatchPending: DefaultBatchPending,
|
2015-06-09 02:44:42 +00:00
|
|
|
BatchDuration: DefaultBatchDuration,
|
|
|
|
TypesDB: DefaultTypesDB,
|
|
|
|
}
|
2015-06-05 20:40:18 +00:00
|
|
|
}
|