2020-07-08 05:37:53 +08:00
|
|
|
package snmp
|
|
|
|
|
|
|
|
|
|
import (
|
2024-02-28 00:13:17 +08:00
|
|
|
"time"
|
|
|
|
|
|
2021-04-10 01:15:04 +08:00
|
|
|
"github.com/influxdata/telegraf/config"
|
2020-07-08 05:37:53 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ClientConfig struct {
|
|
|
|
|
// Timeout to wait for a response.
|
2021-04-10 01:15:04 +08:00
|
|
|
Timeout config.Duration `toml:"timeout"`
|
|
|
|
|
Retries int `toml:"retries"`
|
2020-07-08 05:37:53 +08:00
|
|
|
// Values: 1, 2, 3
|
2022-07-09 03:40:32 +08:00
|
|
|
Version uint8 `toml:"version"`
|
|
|
|
|
UnconnectedUDPSocket bool `toml:"unconnected_udp_socket"`
|
2021-12-01 06:47:50 +08:00
|
|
|
// Path to mib files
|
|
|
|
|
Path []string `toml:"path"`
|
2022-03-18 11:43:46 +08:00
|
|
|
// Translator implementation
|
|
|
|
|
Translator string `toml:"-"`
|
2020-07-08 05:37:53 +08:00
|
|
|
|
|
|
|
|
// Parameters for Version 1 & 2
|
|
|
|
|
Community string `toml:"community"`
|
|
|
|
|
|
|
|
|
|
// Parameters for Version 2 & 3
|
2021-03-02 04:46:49 +08:00
|
|
|
MaxRepetitions uint32 `toml:"max_repetitions"`
|
2020-07-08 05:37:53 +08:00
|
|
|
|
|
|
|
|
// Parameters for Version 3
|
|
|
|
|
ContextName string `toml:"context_name"`
|
|
|
|
|
// Values: "noAuthNoPriv", "authNoPriv", "authPriv"
|
|
|
|
|
SecLevel string `toml:"sec_level"`
|
|
|
|
|
SecName string `toml:"sec_name"`
|
|
|
|
|
// Values: "MD5", "SHA", "". Default: ""
|
|
|
|
|
AuthProtocol string `toml:"auth_protocol"`
|
|
|
|
|
AuthPassword string `toml:"auth_password"`
|
|
|
|
|
// Values: "DES", "AES", "". Default: ""
|
|
|
|
|
PrivProtocol string `toml:"priv_protocol"`
|
|
|
|
|
PrivPassword string `toml:"priv_password"`
|
|
|
|
|
EngineID string `toml:"-"`
|
|
|
|
|
EngineBoots uint32 `toml:"-"`
|
|
|
|
|
EngineTime uint32 `toml:"-"`
|
|
|
|
|
}
|
2024-02-28 00:13:17 +08:00
|
|
|
|
|
|
|
|
func DefaultClientConfig() *ClientConfig {
|
|
|
|
|
return &ClientConfig{
|
|
|
|
|
Timeout: config.Duration(5 * time.Second),
|
|
|
|
|
Retries: 3,
|
|
|
|
|
Version: 2,
|
|
|
|
|
Path: []string{"/usr/share/snmp/mibs"},
|
|
|
|
|
Translator: "gosmi",
|
|
|
|
|
Community: "public",
|
|
|
|
|
MaxRepetitions: 10,
|
|
|
|
|
SecLevel: "authNoPriv",
|
|
|
|
|
SecName: "myuser",
|
|
|
|
|
AuthProtocol: "MD5",
|
|
|
|
|
AuthPassword: "pass",
|
|
|
|
|
}
|
|
|
|
|
}
|