Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
7600757f
Commit
7600757f
authored
8 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
ntpq: don't index ntp fields that dont exist
closes #1634
parent
4ce8dd5f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
plugins/inputs/ntpq/ntpq.go
+2
-2
2 additions, 2 deletions
plugins/inputs/ntpq/ntpq.go
plugins/inputs/ntpq/ntpq_test.go
+34
-0
34 additions, 0 deletions
plugins/inputs/ntpq/ntpq_test.go
with
37 additions
and
2 deletions
CHANGELOG.md
+
1
−
0
View file @
7600757f
...
...
@@ -138,6 +138,7 @@ consistent with the behavior of `collection_jitter`.
-
[
#1586
](
https://github.com/influxdata/telegraf/pull/1586
)
: Remove IF NOT EXISTS from influxdb output database creation.
-
[
#1600
](
https://github.com/influxdata/telegraf/issues/1600
)
: Fix quoting with text values in postgresql_extensible plugin.
-
[
#1425
](
https://github.com/influxdata/telegraf/issues/1425
)
: Fix win_perf_counter "index out of range" panic.
-
[
#1634
](
https://github.com/influxdata/telegraf/issues/1634
)
: Fix ntpq panic when field is missing.
## v0.13.1 [2016-05-24]
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/ntpq/ntpq.go
+
2
−
2
View file @
7600757f
...
...
@@ -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
]
==
"-"
{
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/ntpq/ntpq_test.go
+
34
−
0
View file @
7600757f
...
...
@@ -41,6 +41,35 @@ func TestSingleNTPQ(t *testing.T) {
acc
.
AssertContainsTaggedFields
(
t
,
"ntpq"
,
fields
,
tags
)
}
func
TestMissingJitterField
(
t
*
testing
.
T
)
{
tt
:=
tester
{
ret
:
[]
byte
(
missingJitterField
),
err
:
nil
,
}
n
:=
&
NTPQ
{
runQ
:
tt
.
runqTest
,
}
acc
:=
testutil
.
Accumulator
{}
assert
.
NoError
(
t
,
n
.
Gather
(
&
acc
))
fields
:=
map
[
string
]
interface
{}{
"when"
:
int64
(
101
),
"poll"
:
int64
(
256
),
"reach"
:
int64
(
37
),
"delay"
:
float64
(
51.016
),
"offset"
:
float64
(
233.010
),
}
tags
:=
map
[
string
]
string
{
"remote"
:
"uschi5-ntp-002."
,
"state_prefix"
:
"*"
,
"refid"
:
"10.177.80.46"
,
"stratum"
:
"2"
,
"type"
:
"u"
,
}
acc
.
AssertContainsTaggedFields
(
t
,
"ntpq"
,
fields
,
tags
)
}
func
TestBadIntNTPQ
(
t
*
testing
.
T
)
{
tt
:=
tester
{
ret
:
[]
byte
(
badIntParseNTPQ
),
...
...
@@ -381,6 +410,11 @@ var singleNTPQ = ` remote refid st t when poll reach delay
*uschi5-ntp-002. 10.177.80.46 2 u 101 256 37 51.016 233.010 17.462
`
var
missingJitterField
=
` remote refid st t when poll reach delay offset jitter
==============================================================================
*uschi5-ntp-002. 10.177.80.46 2 u 101 256 37 51.016 233.010
`
var
badHeaderNTPQ
=
`remote refid foobar t when poll reach delay offset jitter
==============================================================================
*uschi5-ntp-002. 10.177.80.46 2 u 101 256 37 51.016 233.010 17.462
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment