From a4a57fe40b3eaea0d43328e4f707860f8d061dec Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Fri, 22 Mar 2019 12:24:47 +0100 Subject: [PATCH] Allow setting the session timeout Now that we have a good config framework in place, this is low-hanging fruit. Will apply to all collectors used, so total scrape time for Prometheus could be (timeout * #-of-collectors) milliseconds for a given module. Related to #20. --- collector.go | 4 ++++ config.go | 1 + ipmi_remote.yml | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/collector.go b/collector.go index f7ee2b9..edaa665 100644 --- a/collector.go +++ b/collector.go @@ -187,6 +187,10 @@ func freeipmiConfig(config IPMIConfig) string { if config.Password != "" { fmt.Fprintf(&b, "password %s\n", config.Password) } + if config.Timeout != 0 { + fmt.Fprintf(&b, "session-timeout %d\n", config.Timeout) + } + fmt.Println(b.String()) return b.String() } diff --git a/config.go b/config.go index a856a33..13644da 100644 --- a/config.go +++ b/config.go @@ -31,6 +31,7 @@ type IPMIConfig struct { Password string `yaml:"pass"` Privilege string `yaml:"privilege"` Driver string `yaml:"driver"` + Timeout uint32 `yaml:"timeout"` Collectors []string `yaml:"collectors"` ExcludeSensorIDs []int64 `yaml:"exclude_sensor_ids"` diff --git a/ipmi_remote.yml b/ipmi_remote.yml index c79c97c..5e267a1 100644 --- a/ipmi_remote.yml +++ b/ipmi_remote.yml @@ -12,8 +12,14 @@ modules: # module=default is specified. user: "default_user" pass: "example_pw" + # The below settings correspond to driver-type, privilege-level, and + # session-timeout respectively, see `man 5 freeipmi.conf`. driver: "LAN_2_0" privilege: "user" + # The session timeout is in milliseconds. Note that a scrape can take up + # to (session-timeout * #-of-collectors) milliseconds, so set the scrape + # timeout in Prometheus accordingly. + timeout: 10000 # Available collectors are bmc, ipmi, and dcmi # If not specified, all three are used collectors: