From f94843630759bef2f94113d5ad27c9e7a3bb37d7 Mon Sep 17 00:00:00 2001 From: kongfei Date: Tue, 7 May 2024 14:49:53 +0800 Subject: [PATCH] chore: snmp up and icmp up could be disabled --- inputs/snmp/instances.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/inputs/snmp/instances.go b/inputs/snmp/instances.go index 65bd39d1..e2d0534d 100644 --- a/inputs/snmp/instances.go +++ b/inputs/snmp/instances.go @@ -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 @@ -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 {