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
c0d98ecd
Commit
c0d98ecd
authored
9 years ago
by
Matt Davis
Committed by
Cameron Sparr
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added initial support for gosensors module
parent
b44644b6
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/inputs/all/all.go
+1
-0
1 addition, 0 deletions
plugins/inputs/all/all.go
plugins/inputs/sensors/sensors.go
+88
-0
88 additions, 0 deletions
plugins/inputs/sensors/sensors.go
with
89 additions
and
0 deletions
plugins/inputs/all/all.go
+
1
−
0
View file @
c0d98ecd
...
...
@@ -28,6 +28,7 @@ import (
_
"github.com/influxdb/telegraf/plugins/inputs/rabbitmq"
_
"github.com/influxdb/telegraf/plugins/inputs/redis"
_
"github.com/influxdb/telegraf/plugins/inputs/rethinkdb"
_
"github.com/influxdb/telegraf/plugins/inputs/sensors"
_
"github.com/influxdb/telegraf/plugins/inputs/statsd"
_
"github.com/influxdb/telegraf/plugins/inputs/system"
_
"github.com/influxdb/telegraf/plugins/inputs/trig"
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/sensors/sensors.go
0 → 100644
+
88
−
0
View file @
c0d98ecd
package
sensors
import
(
"strings"
"github.com/md14454/gosensors"
"github.com/influxdb/telegraf/plugins/inputs"
)
type
Sensors
struct
{
Sensors
[]
string
}
func
(
_
*
Sensors
)
Description
()
string
{
return
"Monitor sensors using lm-sensors package"
}
var
sensorsSampleConfig
=
`
# By default, telegraf gathers stats from all sensors
# detected by the lm-sensors module.
#
# Only collect stats from the selected sensors. Sensors
# are listed as <chip name>:<feature name>. This
# information can be found by running the sensors command.
# e.g. sensors -u
# A * as the feature name will return all features of the chip
#
# sensors = ["coretemp-isa-0000:Core 0", "coretemp-isa-0001:*", ... ]
`
func
(
_
*
Sensors
)
SampleConfig
()
string
{
return
sensorsSampleConfig
}
func
(
s
*
Sensors
)
Gather
(
acc
inputs
.
Accumulator
)
error
{
gosensors
.
Init
()
defer
gosensors
.
Cleanup
()
for
_
,
chip
:=
range
gosensors
.
GetDetectedChips
()
{
for
_
,
feature
:=
range
chip
.
GetFeatures
()
{
chipName
:=
chip
.
String
()
featureLabel
:=
feature
.
GetLabel
()
if
len
(
s
.
Sensors
)
!=
0
{
var
found
bool
for
_
,
sensor
:=
range
s
.
Sensors
{
parts
:=
strings
.
SplitN
(
":"
,
sensor
,
2
)
if
parts
[
0
]
==
chipName
{
if
parts
[
1
]
==
"*"
||
parts
[
1
]
==
featureLabel
{
found
=
true
break
}
}
}
if
!
found
{
continue
}
}
tags
:=
map
[
string
]
string
{
"chip"
:
chipName
,
"adapter"
:
chip
.
AdapterName
(),
"feature-name"
:
feature
.
Name
,
"feature-label"
:
featureLabel
,
}
fieldName
:=
chipName
+
":"
+
featureLabel
fields
:=
map
[
string
]
interface
{}{
featureLabel
:
feature
.
GetValue
(),
}
acc
.
AddFields
(
"sensors"
,
fields
,
tags
)
}
}
return
nil
}
func
init
()
{
inputs
.
Add
(
"sensors"
,
func
()
inputs
.
Input
{
return
&
Sensors
{}
})
}
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