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
5aca58ad
Commit
5aca58ad
authored
9 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
0.3.0: zookeeper and zfs
parent
a34418d7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/zfs/zfs.go
+6
-4
6 additions, 4 deletions
plugins/zfs/zfs.go
plugins/zookeeper/zookeeper.go
+11
-9
11 additions, 9 deletions
plugins/zookeeper/zookeeper.go
with
17 additions
and
13 deletions
plugins/zfs/zfs.go
+
6
−
4
View file @
5aca58ad
...
...
@@ -88,15 +88,15 @@ func gatherPoolStats(pool poolInfo, acc plugins.Accumulator) error {
}
tag
:=
map
[
string
]
string
{
"pool"
:
pool
.
name
}
fields
:=
make
(
map
[
string
]
interface
{})
for
i
:=
0
;
i
<
keyCount
;
i
++
{
value
,
err
:=
strconv
.
ParseInt
(
values
[
i
],
10
,
64
)
if
err
!=
nil
{
return
err
}
acc
.
Add
(
keys
[
i
],
value
,
tag
)
fields
[
keys
[
i
]]
=
value
}
acc
.
AddFields
(
"zfs_pool"
,
fields
,
tag
)
return
nil
}
...
...
@@ -124,6 +124,7 @@ func (z *Zfs) Gather(acc plugins.Accumulator) error {
}
}
fields
:=
make
(
map
[
string
]
interface
{})
for
_
,
metric
:=
range
kstatMetrics
{
lines
,
err
:=
internal
.
ReadLines
(
kstatPath
+
"/"
+
metric
)
if
err
!=
nil
{
...
...
@@ -140,9 +141,10 @@ func (z *Zfs) Gather(acc plugins.Accumulator) error {
key
:=
metric
+
"_"
+
rawData
[
0
]
rawValue
:=
rawData
[
len
(
rawData
)
-
1
]
value
,
_
:=
strconv
.
ParseInt
(
rawValue
,
10
,
64
)
acc
.
Add
(
key
,
value
,
tags
)
fields
[
key
]
=
value
}
}
acc
.
AddFields
(
"zfs"
,
fields
,
tags
)
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
plugins/zookeeper/zookeeper.go
+
11
−
9
View file @
5aca58ad
...
...
@@ -67,35 +67,37 @@ func (z *Zookeeper) gatherServer(address string, acc plugins.Accumulator) error
defer
c
.
Close
()
fmt
.
Fprintf
(
c
,
"%s
\n
"
,
"mntr"
)
rdr
:=
bufio
.
NewReader
(
c
)
scanner
:=
bufio
.
NewScanner
(
rdr
)
service
:=
strings
.
Split
(
address
,
":"
)
if
len
(
service
)
!=
2
{
return
fmt
.
Errorf
(
"Invalid service address: %s"
,
address
)
}
tags
:=
map
[
string
]
string
{
"server"
:
service
[
0
],
"port"
:
service
[
1
]}
fields
:=
make
(
map
[
string
]
interface
{})
for
scanner
.
Scan
()
{
line
:=
scanner
.
Text
()
re
:=
regexp
.
MustCompile
(
`^zk_(\w+)\s+([\w\.\-]+)`
)
parts
:=
re
.
FindStringSubmatch
(
string
(
line
))
service
:=
strings
.
Split
(
address
,
":"
)
if
len
(
parts
)
!=
3
||
len
(
service
)
!=
2
{
if
len
(
parts
)
!=
3
{
return
fmt
.
Errorf
(
"unexpected line in mntr response: %q"
,
line
)
}
tags
:=
map
[
string
]
string
{
"server"
:
service
[
0
],
"port"
:
service
[
1
]}
measurement
:=
strings
.
TrimPrefix
(
parts
[
1
],
"zk_"
)
sValue
:=
string
(
parts
[
2
])
iVal
,
err
:=
strconv
.
ParseInt
(
sValue
,
10
,
64
)
if
err
==
nil
{
acc
.
Add
(
measurement
,
iVal
,
tags
)
fields
[
measurement
]
=
iVal
}
else
{
acc
.
Add
(
measurement
,
sValue
,
tags
)
fields
[
measurement
]
=
sValue
}
}
acc
.
AddFields
(
"zookeeper"
,
fields
,
tags
)
return
nil
}
...
...
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