Giter Club home page Giter Club logo

srvstatus's Introduction

SRVSTATUS

version 1.0

Getting status of SystemD services using Telegraf+InfluxDB+Grafana

Alt text Alt text

Fork of https://grafana.com/grafana/dashboards/12552 and https://github.com/mkopnsrc/srvstatus

Main goal of this easy script is checking list of given SystemD services and sending their status including Up/Down time in to InfluxDB and Grafana dashboards.

The script is written on python and I tried to use standard lib's as much as possible, but you still need a pip install.

This script returns a Json format with services status coded by digits:

  active (running) = 4
  active (existed) = 3
  inactive (dead) = 2
  failed  = 1
  no match = 0

so you need to convert it back to string in Grafana.

Actually the last Telegraf version accepts the string values in json format, but if you want to use Grafana alerting you still need numeric format to put it on alert graphs.

Also script provide a service name and time recent service status in seconds, so you can use it in Grafana dashboards.

You can find the Grafana dashboard example in service_status.json file or on grafana.com:https://grafana.com/grafana/dashboards/13309

Installation

$ cd /opt && git clone https://github.com/ratibor78/srvstatus.git
$ cd /opt/srvstatus
$ virtualenv venv && source venv/bin/activate
$ pip install -r requirements.txt
$ chmod +x ./service.py

Rename settings.ini.back to settings.ini and specify a list of services that you need to check:

   [SERVICES]
    name = docker.service nginx.service

You can also add your own user services list:

   [USER_SERVICES]
    name = syncthing.service

Then configure the Telegraf exec plugin like this:

    [[inputs.exec]]

    commands = [
     "/opt/srvstatus/venv/bin/python /opt/srvstatus/service.py"
    ]

    timeout = "5s"
    name_override = "services_stats"
    data_format = "json"
    tag_keys = [
      "service"
    ]

That's all, now we can create nice and pretty Grafana dashboards for system services with alerting.

Good luck.

License

MIT

Free Software, Hell Yeah!

srvstatus's People

Contributors

ratibor78 avatar b4b857f6ee avatar mkopnsrc avatar pabloruan0710 avatar zzndb 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.