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-18 09:32:39 +00:00
|
|
|
// DefaultBatchDuration is the default batch timeout duration.
|
2015-06-09 03:38:38 +00:00
|
|
|
DefaultBatchDuration = toml.Duration(10 * time.Second)
|
2015-06-09 02:44:42 +00:00
|
|
|
|
2015-11-18 09:32:39 +00:00
|
|
|
// DefaultTypesDB is the default location of the collectd types db file.
|
2015-06-09 02:44:42 +00:00
|
|
|
DefaultTypesDB = "/usr/share/collectd/types.db"
|
2015-11-05 20:51:42 +00:00
|
|
|
|
2015-11-05 22:43:36 +00:00
|
|
|
// DefaultReadBuffer is the default buffer size for the UDP listener.
|
2015-11-05 21:35:07 +00:00
|
|
|
// Sets the size of the operating system's receive buffer associated with
|
2015-11-05 22:43:36 +00:00
|
|
|
// the UDP traffic. Keep in mind that the OS must be able
|
|
|
|
// to handle the number set here or the UDP listener will error and exit.
|
|
|
|
//
|
|
|
|
// DefaultReadBuffer = 0 means to use the OS default, which is usually too
|
|
|
|
// small for high UDP performance.
|
|
|
|
//
|
|
|
|
// Increasing OS buffer limits:
|
|
|
|
// Linux: sudo sysctl -w net.core.rmem_max=<read-buffer>
|
|
|
|
// BSD/Darwin: sudo sysctl -w kern.ipc.maxsockbuf=<read-buffer>
|
|
|
|
DefaultReadBuffer = 0
|
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
|
|
|
}
|