Skip to content

Instantly share code, notes, and snippets.

@fredoliveira
Created March 10, 2011 14:26
Show Gist options
  • Select an option

  • Save fredoliveira/864159 to your computer and use it in GitHub Desktop.

Select an option

Save fredoliveira/864159 to your computer and use it in GitHub Desktop.
A script (should be added to cron) to dynamically update munin hosts
require 'rubygems'
require 'AWS'
ACCESS_KEY_ID = ""
SECRET_KEY = ""
NODEGROUP = ""
@ec2 = AWS::EC2::Base.new(:secret_access_key => SECRET_KEY, :access_key_id => ACCESS_KEY_ID)
output = ""
for reservation in @ec2.describe_instances.reservationSet.item do
if reservation.groupSet.item.first.groupId == NODEGROUP
for instance in reservation.instancesSet.item do
output += "[appservers;#{instance.privateDnsName}]\n"
output += " address #{instance.ipAddress}\n\n"
end
end
end
File.open("/etc/munin/munin-conf.d/hosts.conf", 'w+') {|f| f.write(output) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment