Giter Club home page Giter Club logo

telegraf-drbd_collector's Introduction

telegraf-drbd_collector

Basic script for use with the telegraf exec input plugin to collect DRBD status data into influxdb for display in a grafana dashboard.

Configuration

v1

[[inputs.exec]]
  commands = [
    "/usr/local/bin/drbd_collector"
  ]
  timeout = "5s"
  name_suffix = ""
  data_format = "influx"

v2

[[inputs.exec]]
  commands = [
    "/usr/local/bin/drbd_collector-v2 --statistics"
  ]
  timeout = "5s"
  name_suffix = ""
  data_format = "influx"
Frequency

You can reduce the frequency of just the drbd_collector by adding an interval entry to the [[inputs.exec]] configuration:

[[inputs.exec]]
  commands = [
    "/usr/local/bin/drbd_collector-v2 --statistics"
  ]
  timeout = "5s"
  interval = "30s"
  name_suffix = ""
  data_format = "influx"

Sudoers

By default the telegraf service runs as the telegraf user which will prevent the drbd_collector script from running the drdbadm command. Add the following to the suders.conf file to permit sudo access:

telegraf ALL=(ALL) NOPASSWD: /usr/sbin/drbdsetup

To prevent log spam from sudo access also add the following:

Defaults:telegraf !syslog

Metrics

  • state
  • role
  • disk
  • resync

Tags

  • resource
  • volume

Optional Metrics

When using the v2 script and the --statistics parameter these additional metrics will be provided per volume

  • read
  • written
  • sent
  • received

Example Output

drbd,host=node04,resource=nfs,volume=0 disk=0i,role=2i,state=8i 1708126124000000000
drbd,host=node04,resource=nfs,volume=1 disk=0i,role=2i,state=8i 1708126124000000000
drbd,host=node04,resource=nfs,volume=2 disk=0i,role=2i,state=8i 1708126124000000000

Notes

The state, role, and disk metrics are sent to influx as integer values rather than strings. This permits Grafana dashboard panels to make use of Thresholds for cell coloring along with use in alerting. You can use Value Mappings within the Grafana panel to convert back to text values for display purposes.

The resync metric is only provided in the output when it is present in the drbdadm status.

ToDo

Potentially rewrite in go for inclusion as telegraf plugin.

telegraf-drbd_collector's People

Contributors

wmandra avatar

Stargazers

 avatar

Watchers

 avatar

telegraf-drbd_collector's Issues

Parse /proc/drbd rather than drbd-utils output

Currently the drbd_collector script executes drbdsetup sh-status for every telegraf update (typically every 10s).

as an alternative the /proc/drbd file is also available in the 8.4 kernel module that ships with Debian, but has been removed in the newer DRBD 9.x kernel modules.

Example output:

version: 8.4.11 (api:1/proto:86-101)
srcversion: 488C1124B879DCE7CD031DA 
 0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
 1: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:827027 dw:830872 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
 2: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

This would allow additional metrics to be collected into influx:

  • ns: network sent
  • nr: network received
  • dw: disk write
  • dr: disk read

Another alternative would be to continue to use drbdsetup but switch to the status --statistics command instead.
Example output:

nfs role:Secondary
  volume:0 disk:UpToDate
      read:0 written:0
  volume:1 disk:UpToDate
      read:0 written:987304
  volume:2 disk:UpToDate
      read:0 written:0
  peer role:Primary
    volume:0 replication:Established peer-disk:UpToDate
        received:0 sent:0
    volume:1 replication:Established peer-disk:UpToDate
        received:983459 sent:0
    volume:2 replication:Established peer-disk:UpToDate
        received:0 sent:0

/proc/drbd is slightly easier to parse in a single pass, but we also lose the resource name.

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.