Permalink
Browse files

working gem

  • Loading branch information...
1 parent 7841896 commit 7e903ba0f13d883a93dea16aa9e5b59b4c067e29 @portertech portertech committed Jul 17, 2011
View
@@ -0,0 +1,3 @@
+pkg/*
+*~
+\#*
View
@@ -1,3 +1,5 @@
+base_path = File.expand_path(File.dirname(__FILE__), __FILE__)
+
source "http://rubygems.org"
# Specify your gem's dependencies in sa-monitoring.gemspec
View
@@ -1,3 +1,13 @@
+PATH
+ remote: .
+ specs:
+ sa-monitoring (0.0.1)
+ amqp (= 0.7.1)
+ bundler
+ em-redis
+ json
+ uuidtools
+
GEM
remote: http://rubygems.org/
specs:
@@ -13,7 +23,4 @@ PLATFORMS
ruby
DEPENDENCIES
- amqp (= 0.7.1)
- em-redis
- json
- uuidtools
+ sa-monitoring!
@@ -1,22 +1,11 @@
-require 'rubygems'
-require 'bundler'
-Bundler.require(:default)
+#!/usr/bin/env ruby
-#
-# Read the CM created JSON config file
-#
-config_file = if ENV['dev']
- File.dirname(__FILE__) + '/../config.json'
-else
- '/etc/sa-monitoring/config.json'
-end
-
-config = JSON.parse(File.open(config_file, 'r').read)
+require 'sa-monitoring/config'
#
# Connect to RabbitMQ
#
-AMQP.start(:host => config['rabbitmq']['server']) do
+AMQP.start(:host => CONFIG['rabbitmq']['server']) do
amq = MQ.new
@@ -25,14 +14,14 @@
#
# Recieve checks, execute them, and publish results for processing
#
- config['client']['subscriptions'].each do |exchange|
+ CONFIG['client']['subscriptions'].each do |exchange|
amq.queue(exchange).bind(amq.fanout(exchange)).subscribe do |check_msg|
check = JSON.parse(check_msg)
execute_check = proc do
- output = IO.popen(config['checks'][check['name']]['command']).gets
+ output = IO.popen(CONFIG['checks'][check['name']]['command']).gets
{
'output' => output,
'status' => $?.to_i,
@@ -59,6 +48,6 @@ def post_init
end
EM.add_periodic_timer(30) do
- EM.connect(config['workers'].sample, 9000, OhaiClient)
+ EM.connect(CONFIG['workers'].sample, 9000, OhaiClient)
end
end
@@ -1,24 +1,15 @@
-require 'rubygems'
-require 'bundler'
-Bundler.require(:default, :server)
+#!/usr/bin/env ruby
-#
-# Read the CM created JSON config file
-#
-config_file = if ENV['dev']
- File.dirname(__FILE__) + '/../config.json'
-else
- '/etc/sa-monitoring/config.json'
-end
-
-config = JSON.parse(File.open(config_file, 'r').read)
+require 'sa-monitoring/config'
+require 'uuidtools'
+require 'em-redis'
#
# Connect to RabbitMQ
#
-AMQP.start(:host => config['rabbitmq']['server']) do
+AMQP.start(:host => CONFIG['rabbitmq']['server']) do
- redis = EM::Protocols::Redis.connect(:host => config['redis']['server'])
+ redis = EM::Protocols::Redis.connect(:host => CONFIG['redis']['server'])
amq = MQ.new
@@ -61,7 +52,7 @@
#
work = amq.direct('')
- config['checks'].each do |name, info|
+ CONFIG['checks'].each do |name, info|
work.publish({'name' => name, 'subscribers' => info['subscribers']}.to_json, :routing_key => 'checks')
end
View
@@ -1,7 +0,0 @@
-require "sa-monitoring/version"
-
-module Sa
- module Monitoring
- # Your code goes here...
- end
-end
@@ -0,0 +1,14 @@
+require 'rubygems' if RUBY_VERSION < '1.9.0'
+require 'amqp'
+require 'json'
+
+#
+# Read the CM created JSON config file
+#
+config_file = if ENV['dev']
+ File.dirname(__FILE__) + '/../../config.json'
+else
+ '/etc/sa-monitoring/config.json'
+end
+
+CONFIG = JSON.parse(File.open(config_file, 'r').read)
@@ -1,4 +1,4 @@
-module Sa
+module SA
module Monitoring
VERSION = "0.0.1"
end
View
@@ -4,14 +4,18 @@ require "sa-monitoring/version"
Gem::Specification.new do |s|
s.name = "sa-monitoring"
- s.version = Sa::Monitoring::VERSION
- s.authors = ["Sean Porter"]
- s.email = ["portertech@gmail.com"]
- s.homepage = ""
- s.summary = %q{TODO: Write a gem summary}
- s.description = %q{TODO: Write a gem description}
+ s.version = SA::Monitoring::VERSION
+ s.authors = ["Sean Porter", "Justin Kolberg"]
+ s.email = ["sean.porter@sonian.net"]
+ s.homepage = "https://github.com/sonian/sa-monitoring"
+ s.summary = %q{Monitor servers}
+ s.description = %q{Monitor servers}
- s.rubyforge_project = "sa-monitoring"
+ s.add_dependency('bundler')
+ s.add_dependency('amqp', '0.7.1')
+ s.add_dependency('json')
+ s.add_dependency('uuidtools')
+ s.add_dependency('em-redis')
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")

0 comments on commit 7e903ba

Please sign in to comment.