Skip to content

Commit

Permalink
Remove error log when snmp6 directory does not exists with nstat input (
Browse files Browse the repository at this point in the history
  • Loading branch information
deric authored and bitcharmer committed Oct 18, 2019
1 parent aa383e7 commit 660e3f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions plugins/inputs/nstat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ The sample config file
# 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

- nstat
Expand Down
13 changes: 7 additions & 6 deletions plugins/inputs/nstat/nstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ func (ns *Nstat) Gather(acc telegraf.Accumulator) error {
return err
}

// collect SNMP6 data
// collect SNMP6 data, if SNMP6 directory exists (IPv6 enabled)
snmp6, err := ioutil.ReadFile(ns.ProcNetSNMP6)
if err != nil {
return err
}
err = ns.gatherSNMP6(snmp6, acc)
if err != nil {
if err == nil {
err = ns.gatherSNMP6(snmp6, acc)
if err != nil {
return err
}
} else if !os.IsNotExist(err) {
return err
}
return nil
Expand Down

0 comments on commit 660e3f2

Please sign in to comment.