Document and add support to input plugins for logging alias (#6357)

This commit is contained in:
Greg
2019-09-23 16:39:50 -06:00
committed by Daniel Nelson
parent e42d2e39c6
commit 817c9a69a9
111 changed files with 961 additions and 659 deletions

View File

@@ -1,7 +1,6 @@
package snmp_legacy
import (
"fmt"
"io/ioutil"
"log"
"net"
@@ -24,6 +23,8 @@ type Snmp struct {
Subtable []Subtable
SnmptranslateFile string
Log telegraf.Logger
nameToOid map[string]string
initNode Node
subTableMap map[string]Subtable
@@ -297,7 +298,7 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error {
data, err := ioutil.ReadFile(s.SnmptranslateFile)
if err != nil {
log.Printf("E! Reading SNMPtranslate file error: %s", err)
s.Log.Errorf("Reading SNMPtranslate file error: %s", err.Error())
return err
} else {
for _, line := range strings.Split(string(data), "\n") {
@@ -395,16 +396,16 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error {
// only if len(s.OidInstanceMapping) == 0
if len(host.OidInstanceMapping) >= 0 {
if err := host.SNMPMap(acc, s.nameToOid, s.subTableMap); err != nil {
acc.AddError(fmt.Errorf("E! SNMP Mapping error for host '%s': %s", host.Address, err))
s.Log.Errorf("Mapping error for host %q: %s", host.Address, err.Error())
continue
}
}
// Launch Get requests
if err := host.SNMPGet(acc, s.initNode); err != nil {
acc.AddError(fmt.Errorf("E! SNMP Error for host '%s': %s", host.Address, err))
s.Log.Errorf("Error for host %q: %s", host.Address, err.Error())
}
if err := host.SNMPBulk(acc, s.initNode); err != nil {
acc.AddError(fmt.Errorf("E! SNMP Error for host '%s': %s", host.Address, err))
s.Log.Errorf("Error for host %q: %s", host.Address, err.Error())
}
}
return nil
@@ -801,7 +802,7 @@ func (h *Host) HandleResponse(
acc.AddFields(field_name, fields, tags)
case gosnmp.NoSuchObject, gosnmp.NoSuchInstance:
// Oid not found
log.Printf("E! [snmp input] Oid not found: %s", oid_key)
log.Printf("E! [inputs.snmp_legacy] oid %q not found", oid_key)
default:
// delete other data
}