Browse files

fix a bug with how stats for tubes are stored, better readme.

  • Loading branch information...
1 parent 6f1d8a2 commit 6c8b0e7199fb3a88a884a3aa50a29bcf9d1216b0 @woodhull woodhull committed Mar 16, 2011
Showing with 16 additions and 13 deletions.
  1. +11 −10 README.markdown
  2. +5 −3 nagios/beanstalk-rate.rb
View
21 README.markdown
@@ -68,28 +68,29 @@ allowing the export to be loaded into another server.
Ensures the number of jobs in the default tube fall within a reasonable range.
- usage: beanstalk-jobs.rb host:11300 warn_jobs err_jobs
+ usage: beanstalk-jobs.rb --host localhost --port 11300 --warn 10 --error 20
-warn\_jobs and err\_jobs respectively set the maximum number of jobs found
-before a warning or error is issued.
+warn and error respectively set the maximum number of jobs found
+before a warning or error is issued. Optionally the --tube argument can be used to restrict
+statistics to a particular tube.
### beanstalk-workers.rb
Ensures that the number of workers within the queue is within range.
- usage: beanstalk-workers.rb host:11300 warn_workers error_workers
+ usage: beanstalk-workers.rb --host localhost --port 11300 --warn 10 --error 5
-warn\_workers and error\_workers respectively specify the minimum workers
+warn and error respectively specify the minimum workers
that should be in place before a warning or error is issued.
+Optionally the --tube argument can be used to restrict
+statistics to a particular tube.
### beanstalk-rate.rb
Ensures the growth rate of a particular stat is within range.
- usage: beanstalk-rate.rb host:11300 stat_name err_min warn_min warn_max err_max
+ usage: beanstalk-rate.rb host:11300 --host localhost --port 11300 --warnlow 0.05 --errorlow 0.01 --warnhigh 0.75 --errorhigh 0.99 --stat stat_name
All min and max values are required and are interpreted as floats. The rates
-are expressed as units per second.
-
-**Note**: this only works for stats in the default stat values right now.
-More work is needed to support tube specific stats.
+are expressed as units per second. Optionally the --tube argument can be used to restrict
+statistics to a particular tube.
View
8 nagios/beanstalk-rate.rb
@@ -9,13 +9,15 @@ class PersistedStat
attr_reader :host, :stat_name, :val, :timestamp
- def initialize(host, stat_name, path="/var/tmp/beanstalk_stat")
+ def initialize(host, stat_name, tube=nil, path="/var/tmp/beanstalk_stat")
f=nil
@host=host
@stat_name=stat_name
+ @tube = tube
+ @stat_storage_name = "#{tube}#{stat_name}"
@dir=File.join(path, host.gsub(/:/, '_'))
- @filename=File.join(@dir, stat_name)
+ @filename=File.join(@dir, @stat_storage_name)
@timestamp=File.stat(@filename).mtime
f=open(@filename)
@@ -130,7 +132,7 @@ def rate(v)
exit
end
-pstat=PersistedStat.new server, stat
+pstat=PersistedStat.new server, stat, options[:tube]
rate = pstat.rate(val)

0 comments on commit 6c8b0e7

Please sign in to comment.