Skip to content
Snippets Groups Projects

Using prometheus to alert on

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Kevin Lyda

    Dump the output of this into /var/lib/node_exporter/textfile_collector/mdadm-monitor.prom and then add this to your alerting rules:

    # Mdadm monitor not running.  Last TestMessage event was 1800 seconds ago.
    ALERT MdadmMonitorNotRunning
      IF mdadm_monitor{event="TestMessage"} < (time() - 1800)
      FOR 80m
      ANNOTATIONS {
        summary = "Mdadm Monitor has problems on {{$labels.instance}} failed.",
        description = "Mdadm Monitor has problems on {{$labels.instance}} failed.",
      }
    
    # Mdadm monitor sees a problem.  An event has fired in last 1800 seconds.
    ALERT MdadmMonitorErrorDetected
      IF mdadm_monitor{event!="TestMessage"} > (time() - 1800)
      FOR 30m
      ANNOTATIONS {
        summary = "Mdadm Monitor has seen an event on {{$labels.instance}}.",
        description = "Mdadm Monitor has an event ({{$labels.event}}) on {{$labels.instance}}.",
      }
    mdadm-monitor.sh 274 B
    #!/bin/bash
    
    now=$(date '+s/$/ %s/')
    
    cat << EOF
    # HELP mdadm_monitor Follows events on the arrays.
    # TYPE mdadm_monitor gauge
    EOF
    mdadm --monitor --scan --test --oneshot -p /bin/echo \
      | awk '{print("mdadm_monitor{event=\"" $1 "\",device=\"" $2 "\"}");}' \
      | sed "$now"
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment