Skip to content

Commit

Permalink
add systemd plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed Jan 4, 2023
1 parent 543b372 commit f33d813
Show file tree
Hide file tree
Showing 6 changed files with 439 additions and 1 deletion.
1 change: 1 addition & 0 deletions agent/metrics_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
_ "flashcat.cloud/categraf/inputs/sqlserver"
_ "flashcat.cloud/categraf/inputs/switch_legacy"
_ "flashcat.cloud/categraf/inputs/system"
_ "flashcat.cloud/categraf/inputs/systemd"
_ "flashcat.cloud/categraf/inputs/tomcat"
_ "flashcat.cloud/categraf/inputs/vsphere"
_ "flashcat.cloud/categraf/inputs/zookeeper"
Expand Down
9 changes: 9 additions & 0 deletions conf/input.systemd/systemd.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# # collect interval
# interval = 15

enable=false # 设置为true 打开采集
#unit_include=".+"
#unit_exclude=""
enable_start_time_metrics=true #是否采集service unit的启动时间信息 单位秒
enable_task_metrics=true # 是否采集service unit task的metrics
enable_restarts_metrics=true #是否采集service unit重启的次数信息
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ require (
)

require (
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
Expand All @@ -84,7 +85,10 @@ require (
github.com/jackc/pgtype v1.12.0 // indirect
)

require github.com/vmware/govmomi v0.29.0
require (
github.com/coreos/go-systemd/v22 v22.3.2
github.com/vmware/govmomi v0.29.0
)

replace gopkg.in/yaml.v2 => github.com/rfratto/go-yaml v0.0.0-20211119180816-77389c3526dc

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
Expand Down Expand Up @@ -446,6 +447,7 @@ github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY9
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godror/godror v0.33.0 h1:ZK1W7GohHVDPoLp/37U9QCSHARnYB4vVxNJya+CyWQ4=
github.com/godror/godror v0.33.0/go.mod h1:qHYnDISFm/h0vM+HDwg0LpyoLvxRKFRSwvhYF7ufjZ8=
Expand Down
12 changes: 12 additions & 0 deletions inputs/systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# systemd 插件
[node_exporter](https://github.com/prometheus/node_exporter/blob/master/collector/systemd_linux.go)fork 并改动

## Configuration
```toml
enable=false # 设置为true 打开采集
#unit_include=".+"
#unit_exclude=""
enable_start_time_metrics=true #是否采集service unit的启动时间信息 单位秒
enable_task_metrics=true # 是否采集service unit task的metrics
enable_restarts_metrics=true #是否采集service unit重启的次数信息
```
Loading

0 comments on commit f33d813

Please sign in to comment.