Skip to content

Instantly share code, notes, and snippets.

@matthewskelton
Created February 27, 2013 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewskelton/5046121 to your computer and use it in GitHub Desktop.
Save matthewskelton/5046121 to your computer and use it in GitHub Desktop.
Outline of drawing an xmas tree with Graphite (see https://github.com/matthewskelton/GraphiteGreetings)
require 'Graphite'
require 'Logger'
# Change these as needed for your environment
server = "my.graphite.server.url"
log = Logger.new(STDOUT)
prefix = "Test.Me.XmasTree."
# Create the logger to send stats to Graphite with specific timings
logger = Graphite::Logger.new(server,log)
# Define the offsets
#
# Use Now as a starting point,
# or set a specific time e.g. Time.utc(2012,12,22,19,10,30)
# We need a 20-minute window to plot
t = Time.now
t0 = Time.at(t.to_i - (20 * 60)) # 20 mins ago
t1 = Time.at(t0.to_i + (60 * 1)) # Left base of tree
t2 = Time.at(t0.to_i + (60 * 3)) # Lower tinsel2
# etc.
# Inject the stats - the order is determined by the default Graphite colours
logger.log(t21,{prefix + "Tinsel1" => 3})
logger.log(t18,{prefix + "Tinsel1" => 6})
# etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment