diff --git a/plugins/inputs/snmp/snmp.go b/plugins/inputs/snmp/snmp.go index 4c2de93c9..3a95e84fa 100644 --- a/plugins/inputs/snmp/snmp.go +++ b/plugins/inputs/snmp/snmp.go @@ -398,15 +398,16 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error { // only if len(s.OidInstanceMapping) == 0 if len(OidInstanceMapping) >= 0 { if err := host.SNMPMap(acc, s.nameToOid, s.subTableMap); err != nil { - return err + log.Printf("SNMP Mapping error for host '%s': %s", host.Address, err) + continue } } // Launch Get requests if err := host.SNMPGet(acc, s.initNode); err != nil { - return err + log.Printf("SNMP Error for host '%s': %s", host.Address, err) } if err := host.SNMPBulk(acc, s.initNode); err != nil { - return err + log.Printf("SNMP Error for host '%s': %s", host.Address, err) } } return nil diff --git a/plugins/inputs/snmp/snmp_test.go b/plugins/inputs/snmp/snmp_test.go index 22414fb79..5822926dd 100644 --- a/plugins/inputs/snmp/snmp_test.go +++ b/plugins/inputs/snmp/snmp_test.go @@ -5,7 +5,7 @@ import ( "github.com/influxdata/telegraf/testutil" - // "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -45,7 +45,8 @@ func TestSNMPErrorGet2(t *testing.T) { var acc testutil.Accumulator err := s.Gather(&acc) - require.Error(t, err) + require.NoError(t, err) + assert.Equal(t, 0, len(acc.Metrics)) } func TestSNMPErrorBulk(t *testing.T) { @@ -65,7 +66,8 @@ func TestSNMPErrorBulk(t *testing.T) { var acc testutil.Accumulator err := s.Gather(&acc) - require.Error(t, err) + require.NoError(t, err) + assert.Equal(t, 0, len(acc.Metrics)) } func TestSNMPGet1(t *testing.T) {