Skip to content

Commit

Permalink
Add InfluxDBGlobal.ClientTimeout option for slow InfluxDB instances
Browse files Browse the repository at this point in the history
  • Loading branch information
u238 committed Sep 18, 2018
1 parent ea87753 commit 5f4746b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.gcfg.example
Expand Up @@ -53,6 +53,7 @@
NastyString = ""
NastyStringToReplace = ""
HostcheckAlias = "hostcheck"
ClientTimeout = 5

[InfluxDB "nagflux"]
Enabled = true
Expand Down
1 change: 1 addition & 0 deletions config/Config.go
Expand Up @@ -34,6 +34,7 @@ type Config struct {
NastyString string
NastyStringToReplace string
HostcheckAlias string
ClientTimeout int
}
InfluxDB map[string]*struct {
Enabled bool
Expand Down
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -94,7 +94,7 @@ For further informations / bugs reportes: https://github.com/Griesbacher/nagflux
resultQueues[target],
influxConfig.Address, influxConfig.Arguments, cfg.Main.DumpFile, influxConfig.Version,
cfg.Main.InfluxWorker, cfg.Main.MaxInfluxWorker, cfg.InfluxDBGlobal.CreateDatabaseIfNotExists,
influxConfig.StopPullingDataIfDown, target,
influxConfig.StopPullingDataIfDown, target, cfg.InfluxDBGlobal.ClientTimeout,
)
stoppables = append(stoppables, influx)
influxDumpFileCollector := nagflux.NewDumpfileCollector(resultQueues[target], cfg.Main.DumpFile, target, cfg.Main.FileBufferSize)
Expand Down
4 changes: 2 additions & 2 deletions target/influx/Connector.go
Expand Up @@ -36,13 +36,13 @@ type Connector struct {

//ConnectorFactory Constructor which will create some workers if the connection is established.
func ConnectorFactory(jobs chan collector.Printable, connectionHost, connectionArgs, dumpFile, version string,
workerAmount, maxWorkers int, createDatabaseIfNotExists, stopReadingDataIfDown bool, target data.Target) *Connector {
workerAmount, maxWorkers int, createDatabaseIfNotExists, stopReadingDataIfDown bool, target data.Target, clientTimeout int) *Connector {
parsedArgs := helper.StringToMap(connectionArgs, "&", "=")
var databaseName string
if db, found_db := parsedArgs["db"]; found_db {
databaseName = db
}
timeout := time.Duration(5 * time.Second)
timeout := time.Duration(time.Duration(clientTimeout) * time.Second)
transport := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
client := http.Client{Timeout: timeout, Transport: transport}
s := &Connector{
Expand Down
3 changes: 2 additions & 1 deletion target/influx/Worker.go
Expand Up @@ -50,7 +50,8 @@ var mutex = &sync.Mutex{}
func WorkerGenerator(jobs chan collector.Printable, connection, dumpFile, version string,
connector *Connector, target data.Target, stopReadingDataIfDown bool) func(workerId int) *Worker {
return func(workerId int) *Worker {
timeout := time.Duration(5 * time.Second)
//timeout := time.Duration(5 * time.Second)
timeout := connector.httpClient.Timeout
transport := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
Expand Down

0 comments on commit 5f4746b

Please sign in to comment.