Skip to content

Commit

Permalink
fix: parse snmp agents without scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed May 14, 2024
1 parent 4e89374 commit d5dc457
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 @@ -89,8 +89,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 d5dc457

Please sign in to comment.