rubix 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/Gemfile +30 -0
- data/LICENSE.md +95 -0
- data/README.rdoc +2 -0
- data/Rakefile +35 -0
- data/VERSION +1 -1
- data/bin/zabbix_api +6 -6
- data/lib/rubix/auto_sender.rb +16 -16
- data/lib/rubix/connection.rb +6 -6
- data/lib/rubix/response.rb +10 -10
- data/spec/spec_helper.rb +3 -1
- metadata +71 -11
- data/LICENSE +0 -20
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
# --------------------------------------------------------------------------
|
6
|
+
|
7
|
+
# Only gems that you want listed as development dependencies in the gemspec
|
8
|
+
group :development do
|
9
|
+
gem 'bundler', "~> 1.1"
|
10
|
+
gem 'rake', :require => false
|
11
|
+
gem 'yard', ">= 0.7", :require => false
|
12
|
+
end
|
13
|
+
|
14
|
+
group :docs do
|
15
|
+
gem 'redcarpet', ">= 2.1", :platform => [:ruby]
|
16
|
+
gem 'kramdown', :platform => [:jruby]
|
17
|
+
end
|
18
|
+
|
19
|
+
# Gems for testing and coverage
|
20
|
+
group :test do
|
21
|
+
gem 'simplecov', ">= 0.5", :platform => [:ruby_19], :require => false
|
22
|
+
end
|
23
|
+
|
24
|
+
# Gems you would use if hacking on this gem (rather than with it)
|
25
|
+
group :support do
|
26
|
+
gem 'pry'
|
27
|
+
gem 'guard', ">= 1.0", :platform => [:ruby_19]
|
28
|
+
gem 'guard-rspec', ">= 0.6", :platform => [:ruby_19]
|
29
|
+
gem 'guard-yard', :platform => [:ruby_19]
|
30
|
+
end
|
data/LICENSE.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# License for Rubix
|
2
|
+
|
3
|
+
The rubix code is __Copyright (c) 2011, 2012 Infochimps, Inc__
|
4
|
+
|
5
|
+
This code is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an **AS IS** BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
10
|
+
|
11
|
+
__________________________________________________________________________
|
12
|
+
|
13
|
+
# Apache License
|
14
|
+
|
15
|
+
|
16
|
+
Apache License
|
17
|
+
Version 2.0, January 2004
|
18
|
+
http://www.apache.org/licenses/
|
19
|
+
|
20
|
+
_TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION_
|
21
|
+
|
22
|
+
## 1. Definitions.
|
23
|
+
|
24
|
+
* **License** shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
25
|
+
|
26
|
+
* **Licensor** shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
27
|
+
|
28
|
+
* **Legal Entity** shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
29
|
+
|
30
|
+
* **You** (or **Your**) shall mean an individual or Legal Entity exercising permissions granted by this License.
|
31
|
+
|
32
|
+
* **Source** form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
33
|
+
|
34
|
+
* **Object** form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
35
|
+
|
36
|
+
* **Work** shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
37
|
+
|
38
|
+
* **Derivative Works** shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
39
|
+
|
40
|
+
* **Contribution** shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
41
|
+
|
42
|
+
* **Contributor** shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
43
|
+
|
44
|
+
## 2. Grant of Copyright License.
|
45
|
+
|
46
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
47
|
+
|
48
|
+
## 3. Grant of Patent License.
|
49
|
+
|
50
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
51
|
+
|
52
|
+
## 4. Redistribution.
|
53
|
+
|
54
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
55
|
+
|
56
|
+
- (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
57
|
+
- (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
58
|
+
- (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
59
|
+
- (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
60
|
+
|
61
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
62
|
+
|
63
|
+
## 5. Submission of Contributions.
|
64
|
+
|
65
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
66
|
+
|
67
|
+
## 6. Trademarks.
|
68
|
+
|
69
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
70
|
+
|
71
|
+
## 7. Disclaimer of Warranty.
|
72
|
+
|
73
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
74
|
+
|
75
|
+
## 8. Limitation of Liability.
|
76
|
+
|
77
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
78
|
+
|
79
|
+
## 9. Accepting Warranty or Additional Liability.
|
80
|
+
|
81
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
82
|
+
|
83
|
+
_END OF TERMS AND CONDITIONS_
|
84
|
+
|
85
|
+
## APPENDIX: How to apply the Apache License to your work.
|
86
|
+
|
87
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets `[]` replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
88
|
+
|
89
|
+
> Copyright [yyyy] [name of copyright owner]
|
90
|
+
>
|
91
|
+
> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
92
|
+
>
|
93
|
+
> http://www.apache.org/licenses/LICENSE-2.0
|
94
|
+
>
|
95
|
+
> Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Rubix
|
2
2
|
|
3
|
+
{<img src="https://secure.travis-ci.org/infochimps-labs/rubix.png?branch=master" alt="Build Status" />}[http://travis-ci.org/infochimps-labs/rubix]
|
4
|
+
|
3
5
|
Rubix is a Ruby client for Zabbix[http://www.zabbix.com/] that makes
|
4
6
|
it easier to programatically control Zabbix resources so that they can
|
5
7
|
be coordinated in complex, dynamic, and distributed environments like
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems' unless defined?(Gem)
|
2
|
+
require 'bundler/setup'
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
task :default => :rspec
|
7
|
+
task :spec => :rspec
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
RSpec::Core::RakeTask.new(:rspec) do |spec|
|
11
|
+
Bundler.setup(:default, :development, :test)
|
12
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Run RSpec with code coverage"
|
16
|
+
task :cov do
|
17
|
+
ENV['GORILLIB_COV'] = "yep"
|
18
|
+
Rake::Task[:rspec].execute
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'yard'
|
22
|
+
YARD::Rake::YardocTask.new do
|
23
|
+
Bundler.setup(:default, :development, :docs)
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Build rubix"
|
27
|
+
task :build do
|
28
|
+
system "gem build rubix.gemspec"
|
29
|
+
end
|
30
|
+
|
31
|
+
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
32
|
+
desc "Release rubix-#{version}"
|
33
|
+
task :release => :build do
|
34
|
+
system "gem push rubix-#{version}.gem"
|
35
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.8
|
data/bin/zabbix_api
CHANGED
@@ -25,28 +25,28 @@ def bail msg=nil
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def connect
|
28
|
-
Rubix.connect(Settings[:url], Settings[:username], Settings[:password])
|
28
|
+
Rubix.connect(Settings[:url], Settings[:username], Settings[:password])
|
29
29
|
end
|
30
30
|
|
31
31
|
def perform_query
|
32
32
|
begin
|
33
33
|
method = Settings.rest[0]
|
34
|
-
params =
|
34
|
+
params = MultiJson.parse(Settings.rest[1])
|
35
35
|
response = Rubix.connection.request(method, params)
|
36
|
-
|
36
|
+
|
37
37
|
if Settings[:pretty]
|
38
|
-
puts
|
38
|
+
puts MultiJson.dump(response.parsed, :pretty => true)
|
39
39
|
else
|
40
40
|
puts response.parsed.to_json
|
41
41
|
end
|
42
42
|
exit(0)
|
43
|
-
rescue
|
43
|
+
rescue MultiJson::DecodeError => e
|
44
44
|
bail("Invalid JSON -- #{e.message}")
|
45
45
|
rescue Rubix::Error => e
|
46
46
|
bail($e.message)
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def drop_into_a_shell
|
51
51
|
require 'irb'
|
52
52
|
ARGV.clear
|
data/lib/rubix/auto_sender.rb
CHANGED
@@ -130,7 +130,7 @@ module Rubix
|
|
130
130
|
|
131
131
|
# @return [Array<Rubix::Application>] The applications used to create items
|
132
132
|
attr_accessor :applications
|
133
|
-
|
133
|
+
|
134
134
|
#
|
135
135
|
# == Initialization ==
|
136
136
|
#
|
@@ -172,7 +172,7 @@ module Rubix
|
|
172
172
|
end
|
173
173
|
|
174
174
|
# Will this sender auto-vivify hosts, groups, items, &c.?
|
175
|
-
#
|
175
|
+
#
|
176
176
|
# @return [true, false]
|
177
177
|
def auto_vivify?
|
178
178
|
!fast?
|
@@ -252,9 +252,9 @@ module Rubix
|
|
252
252
|
end
|
253
253
|
|
254
254
|
public
|
255
|
-
|
255
|
+
|
256
256
|
#
|
257
|
-
# == Sending Data ==
|
257
|
+
# == Sending Data ==
|
258
258
|
#
|
259
259
|
|
260
260
|
# Run this sender.
|
@@ -276,7 +276,7 @@ module Rubix
|
|
276
276
|
end
|
277
277
|
|
278
278
|
protected
|
279
|
-
|
279
|
+
|
280
280
|
# Process each line of a file.
|
281
281
|
#
|
282
282
|
# @param [String] path the path to the file to process
|
@@ -285,12 +285,12 @@ module Rubix
|
|
285
285
|
process_file_handle(f)
|
286
286
|
f.close
|
287
287
|
end
|
288
|
-
|
288
|
+
|
289
289
|
# Process each line of standard input.
|
290
290
|
def process_stdin
|
291
291
|
process_file_handle($stdin)
|
292
292
|
end
|
293
|
-
|
293
|
+
|
294
294
|
# Process each line read from the pipe.
|
295
295
|
#
|
296
296
|
# The pipe will be opened in a non-blocking read mode. This
|
@@ -310,7 +310,7 @@ module Rubix
|
|
310
310
|
end
|
311
311
|
f.close
|
312
312
|
end
|
313
|
-
|
313
|
+
|
314
314
|
# Process each line of a given file handle.
|
315
315
|
#
|
316
316
|
# @param [File] f the file to process
|
@@ -334,7 +334,7 @@ module Rubix
|
|
334
334
|
end
|
335
335
|
|
336
336
|
public
|
337
|
-
|
337
|
+
|
338
338
|
# Process a single line of text.
|
339
339
|
#
|
340
340
|
# @param [String] line
|
@@ -394,7 +394,7 @@ module Rubix
|
|
394
394
|
# }
|
395
395
|
#
|
396
396
|
# Or when sending for another host:
|
397
|
-
#
|
397
|
+
#
|
398
398
|
# {
|
399
399
|
# 'host': 'shazaam',
|
400
400
|
# 'applications': 'silly',
|
@@ -407,12 +407,12 @@ module Rubix
|
|
407
407
|
# @param [String] line a line of JSON data
|
408
408
|
def process_line_of_json_in_new_pipe line
|
409
409
|
begin
|
410
|
-
json =
|
411
|
-
rescue
|
410
|
+
json = MultiJson.load(line)
|
411
|
+
rescue MultiJson::DecodeError => e
|
412
412
|
error("Malformed JSON")
|
413
413
|
return
|
414
414
|
end
|
415
|
-
|
415
|
+
|
416
416
|
data = json.delete('data')
|
417
417
|
unless data && data.is_a?(Array)
|
418
418
|
error("A line of JSON input must a have an Array key 'data'")
|
@@ -441,7 +441,7 @@ module Rubix
|
|
441
441
|
warn("The elements of the 'data' Array must be Hashes with a 'key' and a 'value'")
|
442
442
|
next
|
443
443
|
end
|
444
|
-
|
444
|
+
|
445
445
|
tsv_line = [key, value].map(&:to_s).join("\t")
|
446
446
|
daughter_pipe.process_line(tsv_line)
|
447
447
|
end
|
@@ -487,7 +487,7 @@ module Rubix
|
|
487
487
|
item = Item.find(:key => key, :host_id => host.id)
|
488
488
|
unless item
|
489
489
|
Item.new(:key => key, :host_id => host.id, :applications => applications, :value_type => Item.value_type_from_value(value)).save
|
490
|
-
|
490
|
+
|
491
491
|
# There is a time lag of about 15-30 seconds between (successfully)
|
492
492
|
# creating an item on the Zabbix server and having the Zabbix accept
|
493
493
|
# new data for that item.
|
@@ -503,7 +503,7 @@ module Rubix
|
|
503
503
|
sleep settings['create_item_sleep']
|
504
504
|
end
|
505
505
|
end
|
506
|
-
|
506
|
+
|
507
507
|
# Parse the +text+ output by +zabbix_sender+.
|
508
508
|
#
|
509
509
|
# @param [String] key
|
data/lib/rubix/connection.rb
CHANGED
@@ -2,7 +2,7 @@ require 'uri'
|
|
2
2
|
require 'cgi'
|
3
3
|
require 'net/http'
|
4
4
|
require 'net/https'
|
5
|
-
require '
|
5
|
+
require 'multi_json'
|
6
6
|
|
7
7
|
require 'rubix/log'
|
8
8
|
|
@@ -41,7 +41,7 @@ module Rubix
|
|
41
41
|
|
42
42
|
# @return [Rubix::Response] the last response from the Zabbix API -- useful for logging purposes
|
43
43
|
attr_reader :last_response
|
44
|
-
|
44
|
+
|
45
45
|
# Set up a connection to a Zabbix API.
|
46
46
|
#
|
47
47
|
# The +uri_or_string+ can be either a string or a <tt>URI</tt>
|
@@ -100,7 +100,7 @@ module Rubix
|
|
100
100
|
send_web_request(verb, path, data)
|
101
101
|
end
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
# Has this connection already been authorized and provided with a
|
105
105
|
# authorization token from the Zabbix API?
|
106
106
|
def authorized?
|
@@ -128,7 +128,7 @@ module Rubix
|
|
128
128
|
@uri = URI.parse(string)
|
129
129
|
end
|
130
130
|
@server = Net::HTTP.new(uri.host, uri.port)
|
131
|
-
if @uri.scheme == 'https'
|
131
|
+
if @uri.scheme == 'https'
|
132
132
|
@server.use_ssl = true
|
133
133
|
end
|
134
134
|
return @server
|
@@ -219,13 +219,13 @@ module Rubix
|
|
219
219
|
raise RequestError.new("Could not connect to the Zabbix server at #{host_with_port}")
|
220
220
|
end
|
221
221
|
end
|
222
|
-
|
222
|
+
|
223
223
|
# Generate the raw POST request to send to the Zabbix API
|
224
224
|
#
|
225
225
|
# @param [Hash, #to_json] raw_params the complete parameters of the request.
|
226
226
|
# @return [Net::HTTP::Post]
|
227
227
|
def raw_api_request raw_params
|
228
|
-
json_body = raw_params
|
228
|
+
json_body = MultiJson.dump(raw_params)
|
229
229
|
Rubix.logger.log(Logger::DEBUG, "SEND: #{json_body}") if Rubix.logger
|
230
230
|
Net::HTTP::Post.new(uri.path).tap do |req|
|
231
231
|
req['Content-Type'] = 'application/json-rpc'
|
data/lib/rubix/response.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'multi_json'
|
2
2
|
|
3
3
|
module Rubix
|
4
4
|
|
@@ -25,7 +25,7 @@ module Rubix
|
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
28
|
-
# == Parsing ==
|
28
|
+
# == Parsing ==
|
29
29
|
#
|
30
30
|
|
31
31
|
# The parsed JSON body.
|
@@ -37,15 +37,15 @@ module Rubix
|
|
37
37
|
@parsed = {}
|
38
38
|
else
|
39
39
|
begin
|
40
|
-
@parsed =
|
41
|
-
rescue
|
40
|
+
@parsed = MultiJson.load(@body) if @code == 200
|
41
|
+
rescue MultiJson::DecodeError => e
|
42
42
|
@parsed = {}
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
48
|
-
# == Error Handling ==
|
48
|
+
# == Error Handling ==
|
49
49
|
#
|
50
50
|
|
51
51
|
# Was the response *not* a 200?
|
@@ -74,7 +74,7 @@ module Rubix
|
|
74
74
|
def success?
|
75
75
|
!error?
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
# Was the response a *Zabbix* error, implying a 200 with an
|
79
79
|
# +error+ key.
|
80
80
|
#
|
@@ -119,7 +119,7 @@ module Rubix
|
|
119
119
|
end
|
120
120
|
|
121
121
|
#
|
122
|
-
# == Inspecting contents ==
|
122
|
+
# == Inspecting contents ==
|
123
123
|
#
|
124
124
|
|
125
125
|
# The contents of the +result+ key. Returns +nil+ if an error.
|
@@ -169,7 +169,7 @@ module Rubix
|
|
169
169
|
|
170
170
|
# Is the contents of the *first* element of the +result+ key an
|
171
171
|
# Array?
|
172
|
-
#
|
172
|
+
#
|
173
173
|
# @return [true, false]
|
174
174
|
def array?
|
175
175
|
return false if error?
|
@@ -177,7 +177,7 @@ module Rubix
|
|
177
177
|
end
|
178
178
|
|
179
179
|
# Is the contents of the +result+ key a String?
|
180
|
-
#
|
180
|
+
#
|
181
181
|
# @return [true, false]
|
182
182
|
def string?
|
183
183
|
return false if error?
|
@@ -191,6 +191,6 @@ module Rubix
|
|
191
191
|
return false if error?
|
192
192
|
result == true || result == false
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
end
|
196
196
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dhruv Bansal
|
9
|
+
- Infochimps
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
14
31
|
- !ruby/object:Gem::Dependency
|
15
32
|
name: rspec
|
16
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,21 +61,53 @@ dependencies:
|
|
44
61
|
- !ruby/object:Gem::Version
|
45
62
|
version: '0'
|
46
63
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
64
|
+
name: oj
|
48
65
|
requirement: !ruby/object:Gem::Requirement
|
49
66
|
none: false
|
50
67
|
requirements:
|
51
|
-
- -
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
52
77
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: chef
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: multi_json
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
54
103
|
type: :runtime
|
55
104
|
prerelease: false
|
56
105
|
version_requirements: !ruby/object:Gem::Requirement
|
57
106
|
none: false
|
58
107
|
requirements:
|
59
|
-
- -
|
108
|
+
- - ! '>='
|
60
109
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
110
|
+
version: '0'
|
62
111
|
- !ruby/object:Gem::Dependency
|
63
112
|
name: configliere
|
64
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +115,7 @@ dependencies:
|
|
66
115
|
requirements:
|
67
116
|
- - ! '>='
|
68
117
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.4.
|
118
|
+
version: 0.4.16
|
70
119
|
type: :runtime
|
71
120
|
prerelease: false
|
72
121
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +123,7 @@ dependencies:
|
|
74
123
|
requirements:
|
75
124
|
- - ! '>='
|
76
125
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.4.
|
126
|
+
version: 0.4.16
|
78
127
|
- !ruby/object:Gem::Dependency
|
79
128
|
name: multipart-post
|
80
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +145,7 @@ description: Rubix provides abstractions for connecting to Zabbix's API, an ORM
|
|
96
145
|
of Monitor classes for building periodic monitors.
|
97
146
|
email:
|
98
147
|
- dhruv@infochimps.com
|
148
|
+
- coders@infochimps.org
|
99
149
|
executables:
|
100
150
|
- zabbix_api
|
101
151
|
- zabbix_pipe
|
@@ -183,11 +233,15 @@ files:
|
|
183
233
|
- spec/support/response_helper.rb
|
184
234
|
- spec/support/configliere_helper.rb
|
185
235
|
- spec/data/test_template.xml
|
186
|
-
- LICENSE
|
236
|
+
- LICENSE.md
|
187
237
|
- README.rdoc
|
188
238
|
- VERSION
|
239
|
+
- CHANGELOG.md
|
240
|
+
- Rakefile
|
241
|
+
- Gemfile
|
189
242
|
homepage: http://github.com/dhruvbansal/rubix
|
190
|
-
licenses:
|
243
|
+
licenses:
|
244
|
+
- Apache 2.0
|
191
245
|
post_install_message:
|
192
246
|
rdoc_options: []
|
193
247
|
require_paths:
|
@@ -198,12 +252,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
252
|
- - ! '>='
|
199
253
|
- !ruby/object:Gem::Version
|
200
254
|
version: '0'
|
255
|
+
segments:
|
256
|
+
- 0
|
257
|
+
hash: 2230274127708473823
|
201
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
259
|
none: false
|
203
260
|
requirements:
|
204
261
|
- - ! '>='
|
205
262
|
- !ruby/object:Gem::Version
|
206
263
|
version: '0'
|
264
|
+
segments:
|
265
|
+
- 0
|
266
|
+
hash: 2230274127708473823
|
207
267
|
requirements: []
|
208
268
|
rubyforge_project:
|
209
269
|
rubygems_version: 1.8.23
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Dhruv Bansal
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|