ntpq: don't index ntp fields that dont exist

closes #1634
This commit is contained in:
Cameron Sparr
2016-08-16 09:06:19 +01:00
parent 4ce8dd5f9a
commit 7600757f16
3 changed files with 37 additions and 2 deletions

View File

@@ -119,7 +119,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
// Get integer metrics from output
for key, index := range intI {
if index == -1 {
if index == -1 || index >= len(fields) {
continue
}
if fields[index] == "-" {
@@ -169,7 +169,7 @@ func (n *NTPQ) Gather(acc telegraf.Accumulator) error {
// get float metrics from output
for key, index := range floatI {
if index == -1 {
if index == -1 || index >= len(fields) {
continue
}
if fields[index] == "-" {