use AddError everywhere (#2372)
This commit is contained in:
committed by
Daniel Nelson
parent
801f6cb8a0
commit
06baf7cf78
@@ -5,7 +5,7 @@ package ntpq
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"log"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -132,7 +132,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
|
||||
case strings.HasSuffix(when, "h"):
|
||||
m, err := strconv.Atoi(strings.TrimSuffix(fields[index], "h"))
|
||||
if err != nil {
|
||||
log.Printf("E! Error ntpq: parsing int: %s", fields[index])
|
||||
acc.AddError(fmt.Errorf("E! Error ntpq: parsing int: %s", fields[index]))
|
||||
continue
|
||||
}
|
||||
// seconds in an hour
|
||||
@@ -141,7 +141,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
|
||||
case strings.HasSuffix(when, "d"):
|
||||
m, err := strconv.Atoi(strings.TrimSuffix(fields[index], "d"))
|
||||
if err != nil {
|
||||
log.Printf("E! Error ntpq: parsing int: %s", fields[index])
|
||||
acc.AddError(fmt.Errorf("E! Error ntpq: parsing int: %s", fields[index]))
|
||||
continue
|
||||
}
|
||||
// seconds in a day
|
||||
@@ -150,7 +150,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
|
||||
case strings.HasSuffix(when, "m"):
|
||||
m, err := strconv.Atoi(strings.TrimSuffix(fields[index], "m"))
|
||||
if err != nil {
|
||||
log.Printf("E! Error ntpq: parsing int: %s", fields[index])
|
||||
acc.AddError(fmt.Errorf("E! Error ntpq: parsing int: %s", fields[index]))
|
||||
continue
|
||||
}
|
||||
// seconds in a day
|
||||
@@ -161,7 +161,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
|
||||
|
||||
m, err := strconv.Atoi(fields[index])
|
||||
if err != nil {
|
||||
log.Printf("E! Error ntpq: parsing int: %s", fields[index])
|
||||
acc.AddError(fmt.Errorf("E! Error ntpq: parsing int: %s", fields[index]))
|
||||
continue
|
||||
}
|
||||
mFields[key] = int64(m)
|
||||
@@ -178,7 +178,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
|
||||
|
||||
m, err := strconv.ParseFloat(fields[index], 64)
|
||||
if err != nil {
|
||||
log.Printf("E! Error ntpq: parsing float: %s", fields[index])
|
||||
acc.AddError(fmt.Errorf("E! Error ntpq: parsing float: %s", fields[index]))
|
||||
continue
|
||||
}
|
||||
mFields[key] = m
|
||||
|
||||
Reference in New Issue
Block a user