Created
February 27, 2013 08:04
-
-
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)
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
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