poller: specify number of OIDs we tried to get

This commit is contained in:
Vincent Bernat
2022-03-26 12:49:15 +01:00
parent a5a8d8a55c
commit 794f9bf6e4

View File

@@ -147,13 +147,18 @@ func (p *realPoller) Poll(ctx context.Context, sampler string, port uint16, comm
} }
if err != nil { if err != nil {
p.metrics.failures.WithLabelValues(sampler, "get").Inc() p.metrics.failures.WithLabelValues(sampler, "get").Inc()
p.errLogger.Err(err).Str("sampler", sampler).Msg("unable to GET") p.errLogger.Err(err).
Str("sampler", sampler).
Msgf("unable to GET (%d OIDs)", len(requests))
return err return err
} }
if result.Error != gosnmp.NoError && result.ErrorIndex == 0 { if result.Error != gosnmp.NoError && result.ErrorIndex == 0 {
// There is some error affecting the whole request // There is some error affecting the whole request
p.metrics.failures.WithLabelValues(sampler, "get").Inc() p.metrics.failures.WithLabelValues(sampler, "get").Inc()
p.errLogger.Error().Str("sampler", sampler).Stringer("code", result.Error).Msg("unable to GET") p.errLogger.Error().
Str("sampler", sampler).
Stringer("code", result.Error).
Msgf("unable to GET (%d OIDs)", len(requests))
return fmt.Errorf("SNMP error %s(%d)", result.Error, result.Error) return fmt.Errorf("SNMP error %s(%d)", result.Error, result.Error)
} }