Skip to content

Commit

Permalink
chore: snmp up and icmp up could be disabled (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 authored May 7, 2024
1 parent 5be02f0 commit cd87ed5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions inputs/snmp/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ type Instance struct {
Name string `toml:"name"`
Fields []Field `toml:"field"`

DisableUp bool `toml:"disable_up"`
DisableUp bool `toml:"disable_up"`
DisableSnmpUp bool `toml:"disable_snmp_up"`
DisableICMPUp bool `toml:"disable_icmp_up"`

connectionCache []snmpConnection

Expand Down Expand Up @@ -107,12 +109,17 @@ func (ins *Instance) up(slist *types.SampleList, i int) {
etags[ins.AgentHostTag] = host

// icmp probe
up, rtt, loss := Ping(host, 250)
slist.PushSample(inputName, "icmp_up", up, etags)
slist.PushSample(inputName, "icmp_rtt", rtt, etags)
slist.PushSample(inputName, "icmp_packet_loss", loss, etags)
if !ins.DisableICMPUp {
up, rtt, loss := Ping(host, 250)
slist.PushSample(inputName, "icmp_up", up, etags)
slist.PushSample(inputName, "icmp_rtt", rtt, etags)
slist.PushSample(inputName, "icmp_packet_loss", loss, etags)
}

// snmp probe
if ins.DisableSnmpUp {
return
}
oid := ".1.3.6.1.2.1.1.1.0"
gs, err := ins.getConnection(i)
if err != nil {
Expand Down

0 comments on commit cd87ed5

Please sign in to comment.