Skip to content

Commit

Permalink
fix: parse snmp agents without scheme (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 authored May 14, 2024
1 parent d6bc32c commit 5cbeccb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions inputs/snmp/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ func (ins *Instance) Init() error {
}

func (ins *Instance) up(slist *types.SampleList, i int) {
host := ins.Agents[i]
u, err := url.Parse(ins.Agents[i])
target := ins.Agents[i]
if !strings.Contains(target, "://") {
target = "udp://" + target
}
var host string
u, err := url.Parse(target)
if err == nil {
host = u.Hostname()
}
Expand Down

0 comments on commit 5cbeccb

Please sign in to comment.