Skip to content

Instantly share code, notes, and snippets.

@levinalex
Created February 13, 2009 18:19
Show Gist options
  • Save levinalex/64033 to your computer and use it in GitHub Desktop.
Save levinalex/64033 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# burning_down_lighthouse
#
# very crude munin plugin that shows current open lighthouse tickets by milestone
require 'rubygems'
require 'lighthouse'
require 'yaml'
dir = File.dirname(__FILE__)
config = YAML.load_file(dir + "/../config/lighthouse.yaml")
Lighthouse.token = config["token"]
Lighthouse.account = config["account"]
projects = Lighthouse::Project.find(:all)
project = projects.first
open_tickets_in_milestones = []
milestones = {}
project.milestones.each do |mst|
open_tickets_in_milestones << { :id => mst.id, :count => mst.open_tickets_count}
milestones[mst.id] = mst
end
tickets_outside_milestones = open_tickets_in_milestones.inject(project.open_tickets_count) { |s,t| s - t[:count] }
open_tickets_in_milestones << { :id => 0, :count => tickets_outside_milestones }
if $ARGV[0] == "config"
puts <<-EOF.map { |l| l.strip }
graph_title Open tickets in Lighthouse
graph_category other
graph_info This shows how many open tickets there are in Lighthouse for #{config['account']}
none.label none
none.draw AREA
none.info kein Milestone
EOF
milestones.values.sort_by { |m| m.permalink }.each do |mst|
n = mst.permalink.gsub(/[^a-z]/,"")
puts "#{n}.label #{n}"
puts "#{n}.draw STACK"
puts "#{n}.info #{mst.title}"
end
else
open_tickets_in_milestones.sort_by { |x| x[:id] }.each do |oim|
stone = milestones[oim[:id]]
name = stone ? stone.permalink.gsub(/[^a-z]/,"") : "none"
puts "#{name}.value #{oim[:count]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment