diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
commit | 87d772a7d708fec12f48cd8adc0dedff6e1025da (patch) | |
tree | 1fee344c64cc3f43074a01981e21126c8482a522 /src/go/collectors/go.d.plugin/modules/snmp/collect.go | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/snmp/collect.go | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/snmp/collect.go b/src/go/collectors/go.d.plugin/modules/snmp/collect.go deleted file mode 100644 index 9f0e78d7e..000000000 --- a/src/go/collectors/go.d.plugin/modules/snmp/collect.go +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -package snmp - -import ( - "github.com/gosnmp/gosnmp" -) - -func (s *SNMP) collect() (map[string]int64, error) { - collected := make(map[string]int64) - - if err := s.collectOIDs(collected); err != nil { - return nil, err - } - - return collected, nil -} - -func (s *SNMP) collectOIDs(collected map[string]int64) error { - for i, end := 0, 0; i < len(s.oids); i += s.Options.MaxOIDs { - if end = i + s.Options.MaxOIDs; end > len(s.oids) { - end = len(s.oids) - } - - oids := s.oids[i:end] - resp, err := s.snmpClient.Get(oids) - if err != nil { - s.Errorf("cannot get SNMP data: %v", err) - return err - } - - for i, oid := range oids { - if i >= len(resp.Variables) { - continue - } - - switch v := resp.Variables[i]; v.Type { - case gosnmp.Boolean, - gosnmp.Counter32, - gosnmp.Counter64, - gosnmp.Gauge32, - gosnmp.TimeTicks, - gosnmp.Uinteger32, - gosnmp.OpaqueFloat, - gosnmp.OpaqueDouble, - gosnmp.Integer: - collected[oid] = gosnmp.ToBigInt(v.Value).Int64() - default: - s.Debugf("skipping OID '%s' (unsupported type '%s')", oid, v.Type) - } - } - } - - return nil -} |