Permalink
Browse files

cmd/scollector: Update SNMP timeout from 5s to 30s and allow override (

  • Loading branch information...
1 parent 63eba65 commit b8c80c141d7b46be327a29f41f613e1877ca5616 @gbrayut gbrayut committed on GitHub Sep 13, 2016
Showing with 11 additions and 1 deletion.
  1. +3 −0 cmd/scollector/conf/conf.go
  2. +4 −0 cmd/scollector/main.go
  3. +4 −1 snmp/snmp.go
@@ -52,6 +52,9 @@ type Conf struct {
// UserAgentMessage is an optional message that is appended to the User Agent
UserAgentMessage string
+ // SNMPTimeout is the number of seconds to wait for SNMP responses (default 30)
+ SNMPTimeout int
+
HAProxy []HAProxy
SNMP []SNMP
MIBS map[string]MIB
@@ -25,6 +25,7 @@ import (
"bosun.org/metadata"
"bosun.org/opentsdb"
"bosun.org/slog"
+ "bosun.org/snmp"
"bosun.org/util"
"github.com/BurntSushi/toml"
"github.com/facebookgo/httpcontrol"
@@ -123,6 +124,9 @@ func main() {
if conf.ColDir != "" {
collectors.InitPrograms(conf.ColDir)
}
+ if conf.SNMPTimeout > 0 {
+ snmp.Timeout = conf.SNMPTimeout
+ }
var err error
check := func(e error) {
if e != nil {
View
@@ -10,6 +10,9 @@ import (
"bosun.org/snmp/asn1"
)
+//Timeout is the number of seconds to use for conn.SetReadDeadline
+var Timeout = 30
+
// reserved binding values.
var (
null = asn1.RawValue{Class: 0, Tag: 5}
@@ -236,7 +239,7 @@ func (s *SNMP) do(req *request) (*response, error) {
return nil, err
}
buf = make([]byte, 10000, 10000)
- if err := conn.SetReadDeadline(time.Now().Add(5 * time.Second)); err != nil {
+ if err := conn.SetReadDeadline(time.Now().Add(time.Duration(Timeout) * time.Second)); err != nil {
return nil, err
}
n, err := conn.Read(buf)

0 comments on commit b8c80c1

Please sign in to comment.