Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Pure Ruby interface for generating Ganglia gmetric packets

branch: master
Octocat-spinner-32 lib close connection after writing October 20, 2010
Octocat-spinner-32 spec Gemfile March 11, 2013
Octocat-spinner-32 .gitignore Gemfile March 11, 2013
Octocat-spinner-32 Gemfile Gemfile March 11, 2013
Octocat-spinner-32 README.md Update README.md August 14, 2013
Octocat-spinner-32 Rakefile Version bump to 0.1.0 January 28, 2010
Octocat-spinner-32 VERSION bump to 0.1.3; bugfix to close connection October 20, 2010
Octocat-spinner-32 gmetric.gemspec Gemfile March 11, 2013
README.md

GMetric

A pure Ruby client for generating Ganglia 3.1.x+ gmetric meta and metric packets and talking to your gmond / gmetad nodes over UDP protocol. Supports host spoofing, and all the same parameters as the gmetric command line executable.

http://www.igvita.com/2010/01/28/cluster-monitoring-with-ganglia-ruby/

Example: Sending a gmetric to a gmond over UDP

Ganglia::GMetric.send("127.0.0.1", 8670, {
  :name => 'pageviews',
  :units => 'req/min',
  :type => 'uint8',
  :value => 7000,
  :tmax => 60,
  :dmax => 300,
  :group => 'test'
})

Example: Generating the Meta and Metric packets

g = Ganglia::GMetric.pack(
  :slope => 'positive',
  :name => 'ruby',
  :value => rand(100),
  :tmax => 60,
  :units => '',
  :dmax => 60,
  :type => 'uint8'
)

# g[0] = meta packet
# g[1] = gmetric packet

s = UDPSocket.new
s.connect("127.0.0.1", 8670)
s.send g[0], 0
s.send g[1], 0

Spoofing a hostname in gmetrics

To spoof a hostname with the gmetric library you will need to add the following keys to your gmetric. This works with both GMetric.send() and GMetric.pack().

  • spoof - takes a value of 1 or True
  • hostname - expects a value of ip_address:hostname.

License

The MIT License, Copyright (c) 2009 Ilya Grigorik

Something went wrong with that request. Please try again.