// Gather retrieves all the configured fields and tables. // Any error encountered does not halt the process. The errors are accumulated // and returned at the end. func (s *Snmp) Gather(acc telegraf.Accumulator) error { if err := s.init(); err != nil { return err } for _, agent := range s.Agents { gs, err := s.getConnection(agent) if err != nil { acc.AddError(Errorf(err, "agent %s", agent)) continue } // First is the top-level fields. We treat the fields as table prefixes with an empty index. t := Table{ Name: s.Name, Fields: s.Fields, } topTags := map[string]string{} if err := s.gatherTable(acc, gs, t, topTags, false); err != nil { acc.AddError(Errorf(err, "agent %s", agent)) } // Now is the real tables. for _, t := range s.Tables { if err := s.gatherTable(acc, gs, t, topTags, true); err != nil { acc.AddError(Errorf(err, "agent %s", agent)) } } } return nil }