rubix 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +262 -0
- data/VERSION +1 -0
- data/bin/zabbix_api +60 -0
- data/bin/zabbix_pipe +77 -0
- data/lib/rubix.rb +42 -0
- data/lib/rubix/connection.rb +111 -0
- data/lib/rubix/examples/es_monitor.rb +130 -0
- data/lib/rubix/examples/hbase_monitor.rb +87 -0
- data/lib/rubix/examples/mongo_monitor.rb +125 -0
- data/lib/rubix/log.rb +70 -0
- data/lib/rubix/model.rb +56 -0
- data/lib/rubix/models/application.rb +76 -0
- data/lib/rubix/models/host.rb +127 -0
- data/lib/rubix/models/host_group.rb +74 -0
- data/lib/rubix/models/item.rb +122 -0
- data/lib/rubix/models/template.rb +81 -0
- data/lib/rubix/monitor.rb +167 -0
- data/lib/rubix/monitors/chef_monitor.rb +82 -0
- data/lib/rubix/monitors/cluster_monitor.rb +84 -0
- data/lib/rubix/response.rb +124 -0
- data/lib/rubix/sender.rb +301 -0
- data/spec/rubix/connection_spec.rb +43 -0
- data/spec/rubix/models/host_group_spec.rb +56 -0
- data/spec/rubix/monitor_spec.rb +81 -0
- data/spec/rubix/monitors/chef_monitor_spec.rb +11 -0
- data/spec/rubix/monitors/cluster_monitor_spec.rb +11 -0
- data/spec/rubix/response_spec.rb +35 -0
- data/spec/rubix/sender_spec.rb +9 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/response_helper.rb +17 -0
- metadata +140 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rubix::Response do
|
4
|
+
|
5
|
+
def mock_response code, params={}
|
6
|
+
mock("Mock Net::HTTPResponse instance").tap do |mr|
|
7
|
+
mr.stub!(:code).and_return(code.to_s)
|
8
|
+
mr.stub!(:body).and_return({"jsonrpc" => "2.0"}.merge(params).to_json)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should regard any non-200 responses as errors" do
|
13
|
+
Rubix::Response.new(mock_response(500)).error?.should be_true
|
14
|
+
Rubix::Response.new(mock_response(404)).error?.should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should regard 200 responses with an error hash as errors" do
|
18
|
+
Rubix::Response.new(mock_response(200, 'error' => 'foobar')).error?.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be able to tell when a successful response is empty" do
|
22
|
+
Rubix::Response.new(mock_response(200, 'result' => '')).has_data?.should be_false
|
23
|
+
Rubix::Response.new(mock_response(200, 'result' => [])).has_data?.should be_false
|
24
|
+
Rubix::Response.new(mock_response(200, 'result' => {})).has_data?.should be_false
|
25
|
+
Rubix::Response.new(mock_response(200, 'result' => 'hi')).has_data?.should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to tell the type of a successful response" do
|
29
|
+
Rubix::Response.new(mock_response(200, 'result' => 'foobar')).string?.should be_true
|
30
|
+
Rubix::Response.new(mock_response(200, 'result' => ['foobar'])).array?.should be_true
|
31
|
+
Rubix::Response.new(mock_response(200, 'result' => {'foo' => 'bar'})).hash?.should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
RUBIX_ROOT = File.expand_path(__FILE__, '../../lib')
|
4
|
+
$: << RUBIX_ROOT unless $:.include?(RUBIX_ROOT)
|
5
|
+
require 'rubix'
|
6
|
+
|
7
|
+
Rubix.logger = false
|
8
|
+
|
9
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |path| require path }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.mock_with :rspec
|
13
|
+
config.include Rubix::ResponseSpecs
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rubix
|
2
|
+
module ResponseSpecs
|
3
|
+
def mock_response result={}, code=200
|
4
|
+
response = mock("Net::HTTPResponse")
|
5
|
+
response.stub!(:body).and_return({"jsonrpc" => "2.0", "result" => result}.to_json)
|
6
|
+
response.stub!(:code).and_return(code.to_s)
|
7
|
+
Rubix::Response.new(response)
|
8
|
+
end
|
9
|
+
|
10
|
+
def mock_error message='', code=200
|
11
|
+
response = mock("Net::HTTPResponse")
|
12
|
+
response.stub!(:body).and_return({"jsonrpc" => "2.0", "error" => message}.to_json)
|
13
|
+
response.stub!(:code).and_return(code.to_s)
|
14
|
+
Rubix::Response.new(response)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dhruv Bansal
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-11-18 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: json
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: configliere
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 31
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 4
|
60
|
+
- 8
|
61
|
+
version: 0.4.8
|
62
|
+
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
description: Rubix provides abstractions for connecting to Zabbix's API, an ORM for wrapping Zabbix resources, a set of scripts for writing data to Zabbix, and a collection of Monitor classes for building periodic monitors.
|
65
|
+
email:
|
66
|
+
- dhruv@infochimps.com
|
67
|
+
executables:
|
68
|
+
- zabbix_api
|
69
|
+
- zabbix_pipe
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files: []
|
73
|
+
|
74
|
+
files:
|
75
|
+
- bin/zabbix_api
|
76
|
+
- bin/zabbix_pipe
|
77
|
+
- lib/rubix.rb
|
78
|
+
- lib/rubix/models/template.rb
|
79
|
+
- lib/rubix/models/item.rb
|
80
|
+
- lib/rubix/models/host.rb
|
81
|
+
- lib/rubix/models/host_group.rb
|
82
|
+
- lib/rubix/models/application.rb
|
83
|
+
- lib/rubix/examples/es_monitor.rb
|
84
|
+
- lib/rubix/examples/mongo_monitor.rb
|
85
|
+
- lib/rubix/examples/hbase_monitor.rb
|
86
|
+
- lib/rubix/sender.rb
|
87
|
+
- lib/rubix/log.rb
|
88
|
+
- lib/rubix/response.rb
|
89
|
+
- lib/rubix/monitor.rb
|
90
|
+
- lib/rubix/model.rb
|
91
|
+
- lib/rubix/monitors/chef_monitor.rb
|
92
|
+
- lib/rubix/monitors/cluster_monitor.rb
|
93
|
+
- lib/rubix/connection.rb
|
94
|
+
- spec/rubix/models/host_group_spec.rb
|
95
|
+
- spec/rubix/monitor_spec.rb
|
96
|
+
- spec/rubix/monitors/chef_monitor_spec.rb
|
97
|
+
- spec/rubix/monitors/cluster_monitor_spec.rb
|
98
|
+
- spec/rubix/response_spec.rb
|
99
|
+
- spec/rubix/sender_spec.rb
|
100
|
+
- spec/rubix/connection_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- spec/support/response_helper.rb
|
103
|
+
- LICENSE
|
104
|
+
- README.rdoc
|
105
|
+
- VERSION
|
106
|
+
homepage: http://github.com/dhruvbansal/rubix
|
107
|
+
licenses: []
|
108
|
+
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 1.8.5
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: A Ruby client for configuring and writing data to Zabbix
|
139
|
+
test_files: []
|
140
|
+
|