Skip to content
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

Merged
merged 3 commits into from
Oct 21, 2015

Conversation

alienth
Copy link
Contributor

@alienth alienth commented Oct 5, 2015

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 of processes_windows collector).

It writes metric information to linux.systemd.unit, and to os.service.running. The systemd metric tracks each possible ActiveState of a systemd service unit. The os metric simply tracks whether the service is running or not.

If WatchProc was set to true in the config, it also attempts to lookup the service process and sends process metrics via the processes_linux collector methods.

Example config:

[[SystemdService]]
   Name = "scollector"
   WatchProc = true

[[SystemdService]]
   Name = "redis-.*"

@alienth alienth force-pushed the systemd branch 9 times, most recently from 81e6264 to c48af03 Compare October 6, 2015 16:42
@@ -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) {
Copy link
Contributor

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

@alienth alienth force-pushed the systemd branch 7 times, most recently from fdb46d4 to b65072f Compare October 6, 2015 20:17
@@ -117,6 +117,9 @@ func main() {
for _, p := range conf.Process {
check(collectors.AddProcessConfig(p))
}
for _, p := range conf.SystemdService {
Copy link
Contributor

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.

@gbrayut
Copy link
Contributor

gbrayut commented Oct 7, 2015

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")

@alienth
Copy link
Contributor Author

alienth commented Oct 8, 2015

@captncraig / @gbrayut Requested changes made.

I pushed the followup commits as-is to make review easier. I plan to squash things down before merge.

@gbrayut
Copy link
Contributor

gbrayut commented Oct 8, 2015

LGTM... will try and test it tomorrow.

@alienth
Copy link
Contributor Author

alienth commented Oct 8, 2015

Squished down. I left the NameMatches change separate because my changes no longer require it, but it should still be done.

gbrayut added a commit that referenced this pull request Oct 21, 2015
Add collector for systemd service status.
@gbrayut gbrayut merged commit 8df4809 into bosun-monitor:master Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants