-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f33d813
commit 9a44057
Showing
3 changed files
with
88 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package systemd | ||
|
||
import ( | ||
"regexp" | ||
|
||
"flashcat.cloud/categraf/config" | ||
"flashcat.cloud/categraf/inputs" | ||
"github.com/coreos/go-systemd/v22/dbus" | ||
) | ||
|
||
const ( | ||
// minSystemdVersionSystemState is the minimum SystemD version for availability of | ||
// the 'SystemState' manager property and the timer property 'LastTriggerUSec' | ||
// https://github.com/prometheus/node_exporter/issues/291 | ||
minSystemdVersionSystemState = 212 | ||
inputName = `systemd` | ||
) | ||
|
||
type ( | ||
Systemd struct { | ||
config.PluginConfig | ||
Enable bool `toml:"enable"` | ||
|
||
UnitInclude string `toml:"unit_include"` | ||
UnitExclude string `toml:"unit_exclude"` | ||
|
||
unitIncludePattern *regexp.Regexp `toml:"-"` | ||
unitExcludePattern *regexp.Regexp `toml:"-"` | ||
|
||
SystemdPrivate bool `toml:"systemd_private"` | ||
EnableTaskMetrics bool `toml:"enable_task_metrics"` | ||
EnableRestartMetrics bool `toml:"enable_restarts_metrics"` | ||
EnableStartTimeMetrics bool `toml:"enable_start_time_metrics"` | ||
|
||
conn *dbus.Conn | ||
} | ||
unit struct { | ||
dbus.UnitStatus | ||
} | ||
) | ||
|
||
var _ inputs.SampleGatherer = new(Systemd) | ||
|
||
var ( | ||
systemdVersionRE = regexp.MustCompile(`[0-9]{3,}(\.[0-9]+)?`) | ||
unitStatesName = []string{"active", "activating", "deactivating", "inactive", "failed"} | ||
) | ||
|
||
func init() { | ||
inputs.Add(inputName, func() inputs.Input { | ||
return &Systemd{} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
package systemd | ||
|
||
import ( | ||
"flashcat.cloud/categraf/types" | ||
) | ||
|
||
func (s *Systemd) Init() error { | ||
return nil | ||
} | ||
|
||
func (s *Systemd) Gather(slist *types.SampleList) { | ||
} |