Sha256: ec2ae3b136fc7749f8db23ec4be055f8d87a40527babf94017b24f99ecfb3cee

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

require 'riemann/tools'
require 'riemann/tools/mdstat_parser.tab'

module Riemann
  module Tools
    class Md
      include Riemann::Tools

      def mdstat_parser
        @mdstat_parser ||= MdstatParser.new
      end

      def tick
        status = File.read('/proc/mdstat')
        res = mdstat_parser.parse(status)

        state = res.values.all? { |value| value =~ /\AU+\z/ } ? 'ok' : 'critical'

        report(
          service: 'mdstat',
          description: status,
          state: state,
        )
      rescue Racc::ParseError => e
        report(
          service: 'mdstat',
          description: "Error parsing mdstat: #{e.message}",
          state: 'critical',
        )
      rescue Errno::ENOENT => e
        report(
          service: 'mdstat',
          description: e.message,
          state: 'critical',
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riemann-tools-1.6.0 lib/riemann/tools/md.rb
riemann-tools-1.5.0 lib/riemann/tools/md.rb