Sha256: 437cf4f6a357fde50a115a14e23647cb4295fc2f817650580b492c64dc5ab202

Contents?: true

Size: 975 Bytes

Versions: 4

Compression:

Stored size: 975 Bytes

Contents

module Watchmen
	
	def self.test
		@watchmen.each do |cmd|
			puts "Running #{cmd.name}:"
			puts cmd.data
			puts "Done."
		end
	end
	
	def self.data
		@watchmen.inject({}) do |acc,watchman|
			if !CityWatch.config[:watchmen] || (CityWatch.config[:watchmen].is_a?(Array) ? CityWatch.config[:watchmen].include?(watchman.name.to_sym) : CityWatch.config[:watchmen][watchman.name.to_sym])
				acc[watchman.name] = watchman.data
			end
			acc
		end
	end
	
	def self.register(cls)
		@watchmen ||= []
		@watchmen << cls
	end
	
	def self.get(name)
		@watchmen.select {|w| w.name.to_s == name.to_s }.first
	end
	
	def self.each
		@watchmen.each do |w|
			yield w
		end
	end
	
end

require 'city_watch/util/watchman'
require 'city_watch/watchmen/sysinfo'
require 'city_watch/watchmen/unicorns'
require 'city_watch/watchmen/nginx'
require 'city_watch/watchmen/cpu_usage'
require 'city_watch/watchmen/disk_usage'
require 'city_watch/watchmen/uptime'
require 'city_watch/watchmen/redis'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
city-watch-0.7.8 lib/city_watch/watchmen.rb
city-watch-0.7.7 lib/city_watch/watchmen.rb
city-watch-0.7.6 lib/city_watch/watchmen.rb
city-watch-0.7.5 lib/city_watch/watchmen.rb