Remove error log when snmp6 directory does not exists with nstat input (#5403) (#5413)

This commit is contained in:
Tomas Barton 2019-02-13 01:17:09 +01:00 committed by Daniel Nelson
parent ce507e522f
commit ee5827ccbd
2 changed files with 9 additions and 6 deletions

View File

@ -36,6 +36,8 @@ The sample config file
# dump_zeros = true # dump_zeros = true
``` ```
In case that `proc_net_snmp6` path doesn't exist (e.g. IPv6 is not enabled) no error would be raised.
### Measurements & Fields ### Measurements & Fields
- nstat - nstat

View File

@ -83,13 +83,14 @@ func (ns *Nstat) Gather(acc telegraf.Accumulator) error {
return err return err
} }
// collect SNMP6 data // collect SNMP6 data, if SNMP6 directory exists (IPv6 enabled)
snmp6, err := ioutil.ReadFile(ns.ProcNetSNMP6) snmp6, err := ioutil.ReadFile(ns.ProcNetSNMP6)
if err == nil {
err = ns.gatherSNMP6(snmp6, acc)
if err != nil { if err != nil {
return err return err
} }
err = ns.gatherSNMP6(snmp6, acc) } else if !os.IsNotExist(err) {
if err != nil {
return err return err
} }
return nil return nil