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 fd8f93c commit f0bfd10
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 f0bfd10

Please sign in to comment.