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
97a66b73
Commit
97a66b73
authored
9 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
Updating aerospike & apache plugins for 0.3.0
parent
50fc3ec9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/aerospike/aerospike.go
+17
-11
17 additions, 11 deletions
plugins/aerospike/aerospike.go
plugins/apache/apache.go
+21
-17
21 additions, 17 deletions
plugins/apache/apache.go
with
38 additions
and
28 deletions
plugins/aerospike/aerospike.go
+
17
−
11
View file @
97a66b73
...
@@ -247,26 +247,32 @@ func get(key []byte, host string) (map[string]string, error) {
...
@@ -247,26 +247,32 @@ func get(key []byte, host string) (map[string]string, error) {
return
data
,
err
return
data
,
err
}
}
func
readAerospikeStats
(
stats
map
[
string
]
string
,
acc
plugins
.
Accumulator
,
host
,
namespace
string
)
{
func
readAerospikeStats
(
for
key
,
value
:=
range
stats
{
stats
map
[
string
]
string
,
tags
:=
map
[
string
]
string
{
acc
plugins
.
Accumulator
,
"aerospike_host"
:
host
,
host
string
,
"namespace"
:
"_service"
,
namespace
string
,
}
)
{
fields
:=
make
(
map
[
string
]
interface
{})
if
namespace
!=
""
{
tags
:=
map
[
string
]
string
{
tags
[
"namespace"
]
=
namespace
"aerospike_host"
:
host
,
}
"namespace"
:
"_service"
,
}
if
namespace
!=
""
{
tags
[
"namespace"
]
=
namespace
}
for
key
,
value
:=
range
stats
{
// We are going to ignore all string based keys
// We are going to ignore all string based keys
val
,
err
:=
strconv
.
ParseInt
(
value
,
10
,
64
)
val
,
err
:=
strconv
.
ParseInt
(
value
,
10
,
64
)
if
err
==
nil
{
if
err
==
nil
{
if
strings
.
Contains
(
key
,
"-"
)
{
if
strings
.
Contains
(
key
,
"-"
)
{
key
=
strings
.
Replace
(
key
,
"-"
,
"_"
,
-
1
)
key
=
strings
.
Replace
(
key
,
"-"
,
"_"
,
-
1
)
}
}
acc
.
Add
(
key
,
val
,
tags
)
fields
[
key
]
=
val
}
}
}
}
acc
.
AddFields
(
"aerospike"
,
fields
,
tags
)
}
}
func
unmarshalMapInfo
(
infoMap
map
[
string
]
string
,
key
string
)
(
map
[
string
]
string
,
error
)
{
func
unmarshalMapInfo
(
infoMap
map
[
string
]
string
,
key
string
)
(
map
[
string
]
string
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
plugins/apache/apache.go
+
21
−
17
View file @
97a66b73
...
@@ -72,32 +72,33 @@ func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
...
@@ -72,32 +72,33 @@ func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
tags
:=
getTags
(
addr
)
tags
:=
getTags
(
addr
)
sc
:=
bufio
.
NewScanner
(
resp
.
Body
)
sc
:=
bufio
.
NewScanner
(
resp
.
Body
)
fields
:=
make
(
map
[
string
]
interface
{})
for
sc
.
Scan
()
{
for
sc
.
Scan
()
{
line
:=
sc
.
Text
()
line
:=
sc
.
Text
()
if
strings
.
Contains
(
line
,
":"
)
{
if
strings
.
Contains
(
line
,
":"
)
{
parts
:=
strings
.
SplitN
(
line
,
":"
,
2
)
parts
:=
strings
.
SplitN
(
line
,
":"
,
2
)
key
,
part
:=
strings
.
Replace
(
parts
[
0
],
" "
,
""
,
-
1
),
strings
.
TrimSpace
(
parts
[
1
])
key
,
part
:=
strings
.
Replace
(
parts
[
0
],
" "
,
""
,
-
1
),
strings
.
TrimSpace
(
parts
[
1
])
switch
key
{
switch
key
{
case
"Scoreboard"
:
case
"Scoreboard"
:
n
.
gatherScores
(
part
,
acc
,
tags
)
for
field
,
value
:=
range
n
.
gatherScores
(
part
)
{
fields
[
field
]
=
value
}
default
:
default
:
value
,
err
:=
strconv
.
ParseFloat
(
part
,
64
)
value
,
err
:=
strconv
.
ParseFloat
(
part
,
64
)
if
err
!=
nil
{
if
err
!=
nil
{
continue
continue
}
}
acc
.
Add
(
key
,
value
,
tags
)
fields
[
key
]
=
value
}
}
}
}
}
}
acc
.
AddFields
(
"apache"
,
fields
,
tags
)
return
nil
return
nil
}
}
func
(
n
*
Apache
)
gatherScores
(
data
string
,
acc
plugins
.
Accumulator
,
tags
map
[
string
]
string
)
{
func
(
n
*
Apache
)
gatherScores
(
data
string
)
map
[
string
]
interface
{}
{
var
waiting
,
open
int
=
0
,
0
var
waiting
,
open
int
=
0
,
0
var
S
,
R
,
W
,
K
,
D
,
C
,
L
,
G
,
I
int
=
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
var
S
,
R
,
W
,
K
,
D
,
C
,
L
,
G
,
I
int
=
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
...
@@ -129,17 +130,20 @@ func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[str
...
@@ -129,17 +130,20 @@ func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[str
}
}
}
}
acc
.
Add
(
"scboard_waiting"
,
float64
(
waiting
),
tags
)
fields
:=
map
[
string
]
interface
{}{
acc
.
Add
(
"scboard_starting"
,
float64
(
S
),
tags
)
"scboard_waiting"
:
float64
(
waiting
),
acc
.
Add
(
"scboard_reading"
,
float64
(
R
),
tags
)
"scboard_starting"
:
float64
(
S
),
acc
.
Add
(
"scboard_sending"
,
float64
(
W
),
tags
)
"scboard_reading"
:
float64
(
R
),
acc
.
Add
(
"scboard_keepalive"
,
float64
(
K
),
tags
)
"scboard_sending"
:
float64
(
W
),
acc
.
Add
(
"scboard_dnslookup"
,
float64
(
D
),
tags
)
"scboard_keepalive"
:
float64
(
K
),
acc
.
Add
(
"scboard_closing"
,
float64
(
C
),
tags
)
"scboard_dnslookup"
:
float64
(
D
),
acc
.
Add
(
"scboard_logging"
,
float64
(
L
),
tags
)
"scboard_closing"
:
float64
(
C
),
acc
.
Add
(
"scboard_finishing"
,
float64
(
G
),
tags
)
"scboard_logging"
:
float64
(
L
),
acc
.
Add
(
"scboard_idle_cleanup"
,
float64
(
I
),
tags
)
"scboard_finishing"
:
float64
(
G
),
acc
.
Add
(
"scboard_open"
,
float64
(
open
),
tags
)
"scboard_idle_cleanup"
:
float64
(
I
),
"scboard_open"
:
float64
(
open
),
}
return
fields
}
}
// Get tag(s) for the apache plugin
// Get tag(s) for the apache plugin
...
...
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