Sha256: dfcad9f0b443c065b980c34adab6a74d320c26e33e07726cd8641f1a9d9383b3

Contents?: true

Size: 985 Bytes

Versions: 2

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

require 'riemann/tools'

# Gathers munin statistics and submits them to Riemann.
module Riemann
  module Tools
    class Munin
      include Riemann::Tools
      require 'munin-ruby'

      def initialize
        super

        @munin = ::Munin::Node.new
      end

      def tick
        services = opts[:services] || @munin.list
        services.each do |service_name|
          @munin.fetch(service_name).each do |service, parts|
            parts.each do |part, metric|
              report(
                service: "#{service} #{part}",
                metric: metric.to_f,
                state: 'ok',
                tags: ['munin'],
              )
            end
          end
        end
      end

      opt :munin_host, 'Munin hostname', default: 'localhost'
      opt :munin_port, 'Munin port', default: 4949
      opt :services, 'Munin services to translate (if not specified, all services are relayed)', type: :strings
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riemann-tools-1.12.0 tools/riemann-munin/lib/riemann/tools/munin.rb
riemann-tools-1.11.0 tools/riemann-munin/lib/riemann/tools/munin.rb