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
5030373a
Unverified
Commit
5030373a
authored
6 years ago
by
Daniel Nelson
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reuse transport on next interval in jolokia agent (#4137)
parent
5b599337
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/inputs/jolokia2/jolokia_agent.go
+16
-8
16 additions, 8 deletions
plugins/inputs/jolokia2/jolokia_agent.go
with
16 additions
and
8 deletions
plugins/inputs/jolokia2/jolokia_agent.go
+
16
−
8
View file @
5030373a
...
@@ -23,6 +23,7 @@ type JolokiaAgent struct {
...
@@ -23,6 +23,7 @@ type JolokiaAgent struct {
Metrics
[]
MetricConfig
`toml:"metric"`
Metrics
[]
MetricConfig
`toml:"metric"`
gatherer
*
Gatherer
gatherer
*
Gatherer
clients
[]
*
Client
}
}
func
(
ja
*
JolokiaAgent
)
SampleConfig
()
string
{
func
(
ja
*
JolokiaAgent
)
SampleConfig
()
string
{
...
@@ -60,20 +61,27 @@ func (ja *JolokiaAgent) Gather(acc telegraf.Accumulator) error {
...
@@ -60,20 +61,27 @@ func (ja *JolokiaAgent) Gather(acc telegraf.Accumulator) error {
ja
.
gatherer
=
NewGatherer
(
ja
.
createMetrics
())
ja
.
gatherer
=
NewGatherer
(
ja
.
createMetrics
())
}
}
var
wg
sync
.
WaitGroup
// Initialize clients once
if
ja
.
clients
==
nil
{
for
_
,
url
:=
range
ja
.
URLs
{
ja
.
clients
=
make
([]
*
Client
,
0
,
len
(
ja
.
URLs
))
client
,
err
:=
ja
.
createClient
(
url
)
for
_
,
url
:=
range
ja
.
URLs
{
if
err
!=
nil
{
client
,
err
:=
ja
.
createClient
(
url
)
acc
.
AddError
(
fmt
.
Errorf
(
"Unable to create client for %s: %v"
,
url
,
err
))
if
err
!=
nil
{
continue
acc
.
AddError
(
fmt
.
Errorf
(
"Unable to create client for %s: %v"
,
url
,
err
))
continue
}
ja
.
clients
=
append
(
ja
.
clients
,
client
)
}
}
}
var
wg
sync
.
WaitGroup
for
_
,
client
:=
range
ja
.
clients
{
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
(
client
*
Client
)
{
go
func
(
client
*
Client
)
{
defer
wg
.
Done
()
defer
wg
.
Done
()
err
=
ja
.
gatherer
.
Gather
(
client
,
acc
)
err
:
=
ja
.
gatherer
.
Gather
(
client
,
acc
)
if
err
!=
nil
{
if
err
!=
nil
{
acc
.
AddError
(
fmt
.
Errorf
(
"Unable to gather metrics for %s: %v"
,
client
.
URL
,
err
))
acc
.
AddError
(
fmt
.
Errorf
(
"Unable to gather metrics for %s: %v"
,
client
.
URL
,
err
))
}
}
...
...
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