Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added a plugin for Resmon #24

Merged
merged 1 commit into from

2 participants

@goblin

Hi,

We've created a quick plugin that can pull metrics from Resmon and push them into Riemann.

Resmon can collect many interesting metrics and has a few plugins itself.

I guess the primary usage for the riemann-resmon plugin would be for people already running Resmon, with just one line for localhost in the hosts file. We however will prefer to have the riemann-resmon just running on one machine, polling multiple Resmons over HTTP. The plugin supports both scenarios.

@aphyr
Owner

Cool, thanks Goblin! :)

@aphyr aphyr merged commit 108a2a0 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 22, 2013
  1. @goblin

    added riemann-resmon

    goblin authored
This page is out of date. Refresh to see the latest.
Showing with 49 additions and 0 deletions.
  1. +49 −0 bin/riemann-resmon
View
49 bin/riemann-resmon
@@ -0,0 +1,49 @@
+#!/usr/bin/env ruby
+
+require File.expand_path('../../lib/riemann/tools', __FILE__)
+
+class Riemann::Tools::Resmon
+ include Riemann::Tools
+ require 'nokogiri'
+ require 'faraday'
+
+ opt :resmon_hostfile, 'File with hostnames running Resmon (one URI per line)', type: :string
+
+ def initialize
+ @hosts = File.read(options[:resmon_hostfile]).split("\n")
+ super
+ end
+
+ def tick
+ @hosts.each do |host|
+ uri = URI(host)
+
+ doc = Nokogiri::XML(
+ Faraday.new(uri).get.body
+ )
+
+ results = doc.xpath('//ResmonResults/ResmonResult').each do |result|
+ timestamp = result.xpath('last_update').first.text
+ result.xpath('metric').each do |metric|
+ hash = {
+ host: uri.host,
+ service: "#{result.attributes['module'].value}`#{result.attributes['service'].value}`#{metric.attributes['name'].value}",
+ time: timestamp.to_i
+ }
+ case metric.attributes['type'].value
+ when /[iIlLn]/
+ hash[:metric] = metric.text
+ when 's'
+ hash[:description] = metric.text
+ when '0'
+ raise 'dunno what 0 is yet'
+ end
+
+ report(hash)
+ end
+ end
+ end
+ end
+end
+
+Riemann::Tools::Resmon.run
Something went wrong with that request. Please try again.