zbxapi 0.1.369 → 0.1.386
Sign up to get free protection for your applications and to get access to all the features.
- data/zbxapi.rb +22 -11
- data/zbxapi/revision.rb +1 -1
- metadata +9 -25
data/zbxapi.rb
CHANGED
@@ -19,8 +19,8 @@
|
|
19
19
|
#--
|
20
20
|
##########################################
|
21
21
|
# Subversion information
|
22
|
-
# $Id: zbxapi.rb
|
23
|
-
# $Revision:
|
22
|
+
# $Id: zbxapi.rb 386 2012-04-23 07:01:49Z nelsonab $
|
23
|
+
# $Revision: 386 $
|
24
24
|
##########################################
|
25
25
|
#++
|
26
26
|
|
@@ -70,7 +70,7 @@ class ZabbixAPI
|
|
70
70
|
|
71
71
|
include ZDebug
|
72
72
|
|
73
|
-
attr_accessor :method, :params, :debug_level, :auth
|
73
|
+
attr_accessor :method, :params, :debug_level, :auth, :verify_ssl
|
74
74
|
|
75
75
|
#subordinate class
|
76
76
|
attr_accessor :user # [User#new]
|
@@ -79,6 +79,7 @@ class ZabbixAPI
|
|
79
79
|
@id=0
|
80
80
|
@auth=''
|
81
81
|
@url=nil
|
82
|
+
@verify_ssl = true
|
82
83
|
|
83
84
|
private
|
84
85
|
@user_name=''
|
@@ -201,6 +202,8 @@ class ZabbixAPI
|
|
201
202
|
raise ZbxAPI_ExceptionBadServerUrl
|
202
203
|
rescue Errno::ECONNREFUSED
|
203
204
|
raise ZbxAPI_ExceptionBadServerUrl
|
205
|
+
rescue => e
|
206
|
+
raise ZbxAPI_ExceptionBadAuth.new('General Login error, check host connectivity.')
|
204
207
|
end
|
205
208
|
end
|
206
209
|
|
@@ -269,19 +272,27 @@ class ZabbixAPI
|
|
269
272
|
|
270
273
|
end
|
271
274
|
|
275
|
+
def get_http_obj
|
276
|
+
if @proxy
|
277
|
+
http = Net::HTTP::Proxy(@proxy[:address],@proxy[:port],
|
278
|
+
@proxy[:user],@proxy[:password]).new(@url.host,@url.port)
|
279
|
+
else
|
280
|
+
http = Net::HTTP.new(@url.host, @url.port)
|
281
|
+
end
|
282
|
+
http.use_ssl=true if @url.class==URI::HTTPS
|
283
|
+
if ! @verify_ssl
|
284
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @url.class==URI::HTTPS
|
285
|
+
end
|
286
|
+
http
|
287
|
+
end
|
288
|
+
|
272
289
|
#Sends JSON encoded string to server
|
273
290
|
#truncate_length determines how many characters at maximum should be displayed while debugging before
|
274
291
|
#truncation should occur.
|
275
292
|
def do_request(json_obj,truncate_length=5000)
|
276
293
|
redirects=0
|
277
294
|
begin # This is here for redirects
|
278
|
-
|
279
|
-
http = Net::HTTP::Proxy(@proxy[:address],@proxy[:port],
|
280
|
-
@proxy[:user],@proxy[:password]).new(@url.host,@url.port)
|
281
|
-
else
|
282
|
-
http = Net::HTTP.new(@url.host, @url.port)
|
283
|
-
end
|
284
|
-
http.use_ssl=true if @url.class==URI::HTTPS
|
295
|
+
http=get_http_obj
|
285
296
|
response = nil
|
286
297
|
headers={'Content-Type'=>'application/json-rpc',
|
287
298
|
'User-Agent'=>'Zbx Ruby CLI'}
|
@@ -323,7 +334,7 @@ class ZabbixAPI
|
|
323
334
|
retry if redirects<=5
|
324
335
|
raise ZbxAPI_GeneralError, "Too many redirects"
|
325
336
|
rescue NoMethodError
|
326
|
-
raise ZbxAPI_GeneralError.new("Unable to connect to #{@url.host}", :retry=>false)
|
337
|
+
raise ZbxAPI_GeneralError.new("Unable to connect to #{@url.host} : \"#{e}\"", :retry=>false)
|
327
338
|
end
|
328
339
|
end
|
329
340
|
|
data/zbxapi/revision.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zbxapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 369
|
10
|
-
version: 0.1.369
|
4
|
+
version: 0.1.386
|
11
5
|
platform: ruby
|
12
6
|
authors:
|
13
7
|
- A. Nelson
|
@@ -15,23 +9,19 @@ autorequire:
|
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
11
|
|
18
|
-
date:
|
12
|
+
date: 2012-04-23 00:00:00 -04:00
|
19
13
|
default_executable:
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
22
16
|
name: json
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
20
|
requirements:
|
27
21
|
- - ">="
|
28
22
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
23
|
version: "0"
|
33
|
-
|
34
|
-
version_requirements: *id001
|
24
|
+
version:
|
35
25
|
description: Provides a straight forward interface to manipulate Zabbix servers using the Zabbix API.
|
36
26
|
email: nelsonab@red-tux.net
|
37
27
|
executables: []
|
@@ -68,27 +58,21 @@ rdoc_options: []
|
|
68
58
|
require_paths:
|
69
59
|
- .
|
70
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
61
|
requirements:
|
73
62
|
- - ">="
|
74
63
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 3
|
76
|
-
segments:
|
77
|
-
- 0
|
78
64
|
version: "0"
|
65
|
+
version:
|
79
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
67
|
requirements:
|
82
68
|
- - ">="
|
83
69
|
- !ruby/object:Gem::Version
|
84
|
-
hash: 3
|
85
|
-
segments:
|
86
|
-
- 0
|
87
70
|
version: "0"
|
71
|
+
version:
|
88
72
|
requirements:
|
89
73
|
- Requires json
|
90
74
|
rubyforge_project: zbxapi
|
91
|
-
rubygems_version: 1.3.
|
75
|
+
rubygems_version: 1.3.5
|
92
76
|
signing_key:
|
93
77
|
specification_version: 3
|
94
78
|
summary: Ruby wrapper to the Zabbix API
|