Permalink
Browse files

hostname => graphite_identifier in the monitors.

  • Loading branch information...
Dhruv Bansal
Dhruv Bansal committed Sep 29, 2010
1 parent 9c4b0eb commit 2f06b3e239611b9aa12fa5b162364d3d9a56cea7
View
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+require 'rubygems'
+require 'graphiterb/script'
+Configliere.use :commandline, :config_file
+Settings.resolve!
+Graphiterb::Monitors::System.new('system', :iters => 5, :time => 5).run! if $0 == __FILE__
View
@@ -11,4 +11,4 @@ def get_metrics metrics, since
end
end
-ToyMonitor.new('toy').run! if $0 == __FILE__
+ToyMonitor.new('toy', :iters => 5, :time => 5).run! if $0 == __FILE__
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{graphiterb}
- s.version = "0.2.11"
+ s.version = "0.2.12"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Philip (flip) Kromer (@mrflip)"]
- s.date = %q{2010-09-22}
+ s.date = %q{2010-09-28}
s.description = %q{Uses http://github.com/mrflip/configliere and http://graphite.wikidot.com}
s.email = %q{info@infochimps.org}
s.extra_rdoc_files = [
@@ -24,11 +24,6 @@ Gem::Specification.new do |s|
"README.textile",
"Rakefile",
"VERSION",
- "examples/api_call_monitor.rb",
- "examples/file_monitor.rb",
- "examples/loadavg_graphite_sender.rb",
- "examples/run_servers.sh",
- "examples/storage_monitor.rb",
"examples/toy.rb",
"graphiterb.gemspec",
"lib/graphiterb.rb",
@@ -55,11 +50,7 @@ Gem::Specification.new do |s|
s.test_files = [
"spec/graphiterb_spec.rb",
"spec/spec_helper.rb",
- "examples/toy.rb",
- "examples/storage_monitor.rb",
- "examples/loadavg_graphite_sender.rb",
- "examples/file_monitor.rb",
- "examples/api_call_monitor.rb"
+ "examples/toy.rb"
]
if s.respond_to? :specification_version then
@@ -11,7 +11,7 @@ module Graphiterb
#
# By default incrementing 'my_value' which actually increment a
# counter stored at the key
- # 'graphiterb_accumulator:my_value:HOSTNAME'.
+ # 'graphiterb_accumulator:my_value:GRAPHITE_IDENTIFIER'.
#
# See Graphiterb::Monitors::AccumulationsConsumer for the periodic
# monitor that will consume the accumulated counts.
@@ -87,7 +87,7 @@ def increment *args
# @param [Array<String>, String] args
# @return [String]
def scope *args
- [main_scope, args, hostname].flatten.compact.map(&:to_s).join('.')
+ [main_scope, args, graphite_identifier].flatten.compact.map(&:to_s).join('.')
end
end
@@ -27,9 +27,9 @@ def dirs
def get_metrics metrics, since
recent = Directory.recency_filter
dirs.each do |dir|
- metrics << [scope(dir.name, 'num_files', hostname), dir.num_files(&recent) ]
- metrics << [scope(dir.name, 'size', hostname), dir.size(&recent) ]
- metrics << [scope(dir.name, 'lines', hostname), dir.line_counts(&recent) ]
+ metrics << [scope(dir.name, 'num_files', graphite_identifier), dir.num_files(&recent) ]
+ metrics << [scope(dir.name, 'size', graphite_identifier), dir.size(&recent) ]
+ metrics << [scope(dir.name, 'lines', graphite_identifier), dir.line_counts(&recent) ]
end
end
@@ -21,7 +21,7 @@ def get_metrics metrics, since
# "/dev/sdb1", "39373712", "20488716", "16884908", "55%", "/"
df.each do |handle, size, spaceused, spacefree, percentfree, location|
disk_name = handle.gsub(/^\//, '').split('/')
- metrics << [scope(hostname, disk_name, 'available'), spacefree.to_i]
+ metrics << [scope(graphite_identifier, disk_name, 'available'), spacefree.to_i]
end
end
end
@@ -57,24 +57,24 @@ def get_metrics metrics, since
df.each do |handle, size, spaceused, spacefree, percentused, location|
disk_name = handle.gsub(/^\//, '').split('/')
percent_free = (100.0 * spacefree.to_f / (spaceused.to_f + spacefree.to_f)) rescue 0.0
- metrics << [scope(hostname, disk_name, 'available'), percent_free]
+ metrics << [scope(graphite_identifier, disk_name, 'available'), percent_free]
end
lines = top
- metrics << [scope(hostname, 'cpu', 'avg_usage'), cpu(lines)]
+ metrics << [scope(graphite_identifier, 'cpu', 'avg_usage'), cpu(lines)]
proc_total, proc_running = processes(lines)
- metrics << [scope(hostname, 'processes', 'total'), proc_total ]
- metrics << [scope(hostname, 'processes', 'running'), proc_running ]
+ metrics << [scope(graphite_identifier, 'processes', 'total'), proc_total ]
+ metrics << [scope(graphite_identifier, 'processes', 'running'), proc_running ]
mem_used, mem_free = memory(lines)
swap_used, swap_free = swap(lines)
- metrics << [scope(hostname, 'memory', 'used'), mem_used ]
- metrics << [scope(hostname, 'memory', 'free'), mem_free ]
- metrics << [scope(hostname, 'swap', 'used'), swap_used ]
- metrics << [scope(hostname, 'swap', 'free'), swap_free ]
+ metrics << [scope(graphite_identifier, 'memory', 'used'), mem_used ]
+ metrics << [scope(graphite_identifier, 'memory', 'free'), mem_free ]
+ metrics << [scope(graphite_identifier, 'swap', 'used'), swap_used ]
+ metrics << [scope(graphite_identifier, 'swap', 'free'), swap_free ]
end
end

0 comments on commit 2f06b3e

Please sign in to comment.