Git Product home page Git Product logo

collectd-systemd's Introduction

collectd-systemd

Build status Coverage

A collectd plugin which checks if given systemd services are in "running" state and sends graphite metrics with 1.0 or 0.0 value.

The plugin is particularly useful together with grafana's alerting.

Quick start

Make sure Python dbus bindings are installed in your system:

  • Debian/Ubuntu: sudo apt-get install python-dbus
  • Fedora/CentOS: sudo yum install dbus-python

Copy collectd_systemd.py to collectd Python plugin directory (usually /usr/lib64/collectd/python/ or /usr/lib/collectd/python/). Add following snippet do /etc/collectd.conf:

LoadPlugin python

<Plugin python>
    ModulePath "/usr/lib64/collectd/python"
    Import "collectd_systemd"

    <Module collectd_systemd>
        Service sshd nginx postgresql
        Service httpd
    </Module>
</Plugin>

If your service has dash in the name, you need to wrap that name in double quotes:

<Module collectd_systemd>
    Service "celery-bots" "gunicorn-data"
</Module>

Restart collectd daemon and open grafana web ui. Add a new graph with following query:

aliasSub(collectd.*.systemd-*.gauge-running, '.+systemd-(.+)\..+', '\1')

You should see all configured systemd services in the graph. Now it's enough to add an alert for values lower than 1.0 to be paged when services are down.

Configuration

Following configuration options are supported:

  • Service: one or more systemd services to monitor. Separate multiple services with spaces. Multiple services lines can be specified when they will be concatinated.
  • Interval: check interval. It's ok to keep the default (60 seconds)
  • Verbose: enable verbose logging (off by default)

Running tests

Install tox using pip or Linux package manager.

Type tox to run tests.

Selinux

On Redhat systems some selinux policy may be needed. Create a file collectd_systemd.te:

policy_module(collectd_systemd,0.1);
require {
    type collectd_t;
    type initrc_exec_t;
}
dbus_session_client(system,collectd_t)
init_status(collectd_t)
init_dbus_chat(collectd_t)
systemd_status_all_unit_files(collectd_t)
allow collectd_t initrc_exec_t:service { status };

Create a file collectd_systemd.pp and install it:

make -f /usr/share/selinux/devel/Makefile collectd_systemd.pp
semodule -i collectd_systemd.pp

collectd-systemd's People

Contributors

bjsignalfx avatar mbachry avatar rwmanos avatar sorrowless avatar traylenator avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.