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
be3374a3
Commit
be3374a3
authored
9 years ago
by
Rene Zbinden
Committed by
Cameron Sparr
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
remove interval configuration
parent
264ac0b0
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
plugins/inputs/sysstat/README.md
+0
-7
0 additions, 7 deletions
plugins/inputs/sysstat/README.md
plugins/inputs/sysstat/sysstat.go
+19
-15
19 additions, 15 deletions
plugins/inputs/sysstat/sysstat.go
plugins/inputs/sysstat/sysstat_test.go
+29
-1
29 additions, 1 deletion
plugins/inputs/sysstat/sysstat_test.go
with
48 additions
and
23 deletions
plugins/inputs/sysstat/README.md
+
0
−
7
View file @
be3374a3
...
...
@@ -11,11 +11,6 @@ the created binary data file with the `sadf` utility.
```
toml
# Sysstat metrics collector
[[inputs.sysstat]]
## Collect interval in seconds. This value has to be equal
## to the telegraf collect interval.
collect_interval
=
30
# required
#
#
## Path to the sadc command.
sadc_path
=
"/usr/lib/sa/sadc"
# required
#
...
...
@@ -127,7 +122,6 @@ And more if you define some `device_tags`.
With the configuration below:
```
toml
[[inputs.sysstat]]
collect_interval
=
30
sadc_path
=
"/usr/lib/sa/sadc"
# required
activities
=
[
"DISK"
,
"SNMP"
,
"INT"
]
group
=
true
...
...
@@ -196,7 +190,6 @@ $ telegraf -config telegraf.conf -input-filter sysstat -test
If you change the group value to false like below:
```
toml
[[inputs.sysstat]]
collect_interval
=
30
sadc_path
=
"/usr/lib/sa/sadc"
# required
activities
=
[
"DISK"
,
"SNMP"
,
"INT"
]
group
=
false
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/sysstat/sysstat.go
+
19
−
15
View file @
be3374a3
...
...
@@ -21,18 +21,14 @@ import (
)
var
(
firstTimestamp
time
.
Time
execCommand
=
exec
.
Command
// execCommand is used to mock commands in tests.
dfltActivities
=
[]
string
{
"DISK"
}
)
const
parseInterval
=
1
// parseInterval is the interval (in seconds) where the parsing takes place.
const
parseInterval
=
1
// parseInterval is the interval (in seconds) where the parsing
of the binary file
takes place.
type
Sysstat
struct
{
// Interval that defines how long data is collected by Sadc cmd.
//
// This value has to be the same as the thelegraf collection interval.
Interval
int
`toml:"collect_interval"`
// Sadc represents the path to the sadc collector utility.
Sadc
string
`toml:"sadc_path"`
...
...
@@ -66,6 +62,7 @@ type Sysstat struct {
// DeviceTags adds the possibility to add additional tags for devices.
DeviceTags
map
[
string
][]
map
[
string
]
string
`toml:"device_tags"`
tmpFile
string
interval
int
}
func
(
*
Sysstat
)
Description
()
string
{
...
...
@@ -73,11 +70,6 @@ func (*Sysstat) Description() string {
}
var
sampleConfig
=
`
## Collect interval in seconds. This value has to be equal
## to the telegraf collect interval.
collect_interval = 5 # required
#
#
## Path to the sadc command.
sadc_path = "/usr/lib/sa/sadc" # required
#
...
...
@@ -101,7 +93,7 @@ var sampleConfig = `
# group = false
#
#
## Options for the sa
s
f command. The values on the left represent the sadf options and
## Options for the sa
d
f command. The values on the left represent the sadf options and
## the values on the right their description (wich are used for grouping and prefixing metrics).
[inputs.sysstat.options]
-C = "cpu"
...
...
@@ -109,7 +101,6 @@ var sampleConfig = `
-b = "io"
-d = "disk" # requires DISK activity
-H = "hugepages"
"-I ALL" = "interrupts" # requires INT activity
"-n ALL" = "network"
"-P ALL" = "per_cpu"
-q = "queue"
...
...
@@ -120,6 +111,7 @@ var sampleConfig = `
-v = "inode"
-W = "swap"
-w = "task"
# "-I ALL" = "interrupts" # requires INT activity
#
#
## Device tags can be used to add additional tags for devices. For example the configuration below
...
...
@@ -133,7 +125,14 @@ func (*Sysstat) SampleConfig() string {
}
func
(
s
*
Sysstat
)
Gather
(
acc
telegraf
.
Accumulator
)
error
{
ts
:=
time
.
Now
()
.
Add
(
time
.
Duration
(
s
.
Interval
)
*
time
.
Second
)
if
s
.
interval
==
0
{
if
firstTimestamp
.
IsZero
()
{
firstTimestamp
=
time
.
Now
()
}
else
{
s
.
interval
=
int
(
time
.
Since
(
firstTimestamp
)
.
Seconds
())
}
}
ts
:=
time
.
Now
()
.
Add
(
time
.
Duration
(
s
.
interval
)
*
time
.
Second
)
if
err
:=
s
.
collect
();
err
!=
nil
{
return
err
}
...
...
@@ -187,7 +186,12 @@ func (s *Sysstat) collect() error {
options
=
append
(
options
,
"-S"
,
act
)
}
s
.
tmpFile
=
path
.
Join
(
"/tmp"
,
fmt
.
Sprintf
(
"sysstat-%d"
,
time
.
Now
()
.
Unix
()))
collectInterval
:=
s
.
Interval
-
parseInterval
// collectInterval has to be smaller than the telegraf data collection interval
collectInterval
:=
s
.
interval
-
parseInterval
// collectInterval has to be smaller than the telegraf data collection interval
if
collectInterval
<
0
{
// If true, interval is not defined yet and Gather is run for the first time.
collectInterval
=
1
// In that case we only collect for 1 second.
}
options
=
append
(
options
,
strconv
.
Itoa
(
collectInterval
),
"2"
,
s
.
tmpFile
)
cmd
:=
execCommand
(
s
.
Sadc
,
options
...
)
out
,
err
:=
cmd
.
CombinedOutput
()
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/sysstat/sysstat_test.go
+
29
−
1
View file @
be3374a3
...
...
@@ -8,12 +8,13 @@ import (
"os/exec"
"path"
"testing"
"time"
"github.com/influxdata/telegraf/testutil"
)
var
s
=
Sysstat
{
I
nterval
:
10
,
i
nterval
:
10
,
Sadc
:
"/usr/lib/sa/sadc"
,
Group
:
false
,
Activities
:
[]
string
{
"DISK"
,
"SNMP"
},
...
...
@@ -303,3 +304,30 @@ dell-xps 5 2016-03-25 16:18:10 UTC sdb %util 0.30
// some code here to check arguments perhaps?
os
.
Exit
(
0
)
}
// TestGatherInterval checks that interval is correctly set.
func
TestGatherInterval
(
t
*
testing
.
T
)
{
// overwriting exec commands with mock commands
execCommand
=
fakeExecCommand
defer
func
()
{
execCommand
=
exec
.
Command
}()
var
acc
testutil
.
Accumulator
s
.
interval
=
0
wantedInterval
:=
3
err
:=
s
.
Gather
(
&
acc
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
time
.
Sleep
(
time
.
Duration
(
wantedInterval
)
*
time
.
Second
)
err
=
s
.
Gather
(
&
acc
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
s
.
interval
!=
wantedInterval
{
t
.
Errorf
(
"wrong interval: got %d, want %d"
,
s
.
interval
,
wantedInterval
)
}
}
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