Use golang.org/x/sys/unix instead of syscall in diskio (#3384)
This commit is contained in:
@@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -166,14 +167,13 @@ func (s *DiskIOStats) Gather(acc telegraf.Accumulator) error {
|
||||
var varRegex = regexp.MustCompile(`\$(?:\w+|\{\w+\})`)
|
||||
|
||||
func (s *DiskIOStats) diskName(devName string) string {
|
||||
di, err := s.diskInfo(devName)
|
||||
if err != nil {
|
||||
// discard error :-(
|
||||
// We can't return error because it's non-fatal to the Gather().
|
||||
// And we have no logger, so we can't log it.
|
||||
if len(s.NameTemplates) == 0 {
|
||||
return devName
|
||||
}
|
||||
if di == nil {
|
||||
|
||||
di, err := s.diskInfo(devName)
|
||||
if err != nil {
|
||||
log.Printf("W! Error gathering disk info: %s", err)
|
||||
return devName
|
||||
}
|
||||
|
||||
@@ -200,14 +200,13 @@ func (s *DiskIOStats) diskName(devName string) string {
|
||||
}
|
||||
|
||||
func (s *DiskIOStats) diskTags(devName string) map[string]string {
|
||||
di, err := s.diskInfo(devName)
|
||||
if err != nil {
|
||||
// discard error :-(
|
||||
// We can't return error because it's non-fatal to the Gather().
|
||||
// And we have no logger, so we can't log it.
|
||||
if len(s.DeviceTags) == 0 {
|
||||
return nil
|
||||
}
|
||||
if di == nil {
|
||||
|
||||
di, err := s.diskInfo(devName)
|
||||
if err != nil {
|
||||
log.Printf("W! Error gathering disk info: %s", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user