Created
November 20, 2010 17:19
-
-
Save ipl31/707980 to your computer and use it in GitHub Desktop.
Ruby Gmetric example that counts dir listings and sends them to a ganglia cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Simple ganglia gmetric plugin using the gmetric gem. | |
#Counts entries in a dir and reports them to the ganglia cluster using | |
#the gmetric ruby gem | |
require 'rubygems' | |
require 'gmetric' | |
#Tmax indicates freshness, if TN(seconds since metric was updated) exceeds tmax then ganglia will expect a new value | |
#Dmax indicates how long an old metric should be retained | |
#decsripitions taken from http://monami.sourceforge.net/tutorial/ar01s06.html | |
tmax = 60 | |
dmax = 300 | |
#first argument is a host gmond host in the cluster | |
#second argument is the port | |
gmondhost = ARGV[0] | |
gmondport = ARGV[1] | |
dir = '/home/ken/' | |
graph_name = "Directory Listing Count in #{dir}" | |
units = "Files/Directories" | |
file_count = Dir.entries(dir).count | |
Ganglia::GMetric.send(gmondhost, gmondport, { | |
:name => graph_name, | |
:units => units, | |
:type => 'uint8', | |
:value => file_count, | |
:tmax => 60, | |
:dmax => 300 | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment