-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add collector for systemd service status. #1374
Conversation
81e6264
to
c48af03
Compare
@@ -60,7 +60,7 @@ func c_dotnet_loading() (opentsdb.MultiDataPoint, error) { | |||
} | |||
var md opentsdb.MultiDataPoint | |||
for _, v := range dst { | |||
if !nameMatches(v.Name, regexesDotNet) { | |||
if !util.NameMatches(v.Name, regexesDotNet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing a "bosun.org/util" import. Adding that should fix travis ci builds
fdb46d4
to
b65072f
Compare
@@ -117,6 +117,9 @@ func main() { | |||
for _, p := range conf.Process { | |||
check(collectors.AddProcessConfig(p)) | |||
} | |||
for _, p := range conf.SystemdService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a new way to do this kind of init stuff, but unfortunately didn't convert all these old ones in main. See what I did to the haproxy one here: https://github.com/bosun-monitor/bosun/blob/master/cmd/scollector/collectors/haproxy_unix.go#L16
That should make the collectors more self contained.
I would add osServiceRunningDesc = "0: active, 1: inactive" as a const in scollector/collectors/collecors.go and use that for the os.service.running description. That way it can be shared with windows. You can also move the metric name to a const in that same file (ex: osServiceRunning = "os.service.running") |
@captncraig / @gbrayut Requested changes made. I pushed the followup commits as-is to make review easier. I plan to squash things down before merge. |
LGTM... will try and test it tomorrow. |
Squished down. I left the NameMatches change separate because my changes no longer require it, but it should still be done. |
Add collector for systemd service status.
Utilizes dbus API to determine state of services managed by systemd. It will track the state of services listed under
[[SystemdService]]
entries in the config (modeled off ofprocesses_windows
collector).It writes metric information to
linux.systemd.unit
, and toos.service.running
. Thesystemd
metric tracks each possibleActiveState
of a systemd service unit. Theos
metric simply tracks whether the service is running or not.If
WatchProc
was set totrue
in the config, it also attempts to lookup the service process and sends process metrics via theprocesses_linux
collector methods.Example config: