zbxapi 0.3.8 → 0.3.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c078a90f1aa2ae9df5568188547fe6140d5f16c
4
- data.tar.gz: e9623098f38c3b9b9a180bff52347fadf09b710b
3
+ metadata.gz: 38a9412b166183c0bd43d087a9aaa9a5ad87b81e
4
+ data.tar.gz: 5fcd9d06059a7c9c66fc67e4c7daf6dde306e57a
5
5
  SHA512:
6
- metadata.gz: b9c4da2662fbdb9c25288e840cb6af0892fbdf094a5eb75e796dd8b231e0917d8c8be7327e997d9bfde19cd45524cd58c25be61830fadc3aa8ec46d17f03ebeb
7
- data.tar.gz: 9e45e6997e456fa25532fbfae9aa694a34a945980417675f657b675f4e85e6a76a9b471b2b33c113cfe0176105e40c19d039df4a13b1bcba21559874180ac8b0
6
+ metadata.gz: 31ff6131737c3746f8f02e5a4f189407d459070c307a7d5a5abdb7f7a24bb3ca3321222e4d36c8bc2c55c59e9ef496d07f0fdd4f079b6f50d9958a1706a3ef44
7
+ data.tar.gz: 6ec95b61956ef2f18a08a3b03c5fb9395bb9f70bc77e7910d0e96b3b61a98e74ba8a3c1769b92c43adef615ff7e6edcc86e4caa710331c9e2da90e3a9f250d4e
@@ -19,7 +19,6 @@
19
19
  require "api_classes/api_dsl"
20
20
 
21
21
  class Host < ZabbixAPI_Base
22
- actions :update, :massAdd, :massUpdate, :massRemove
23
22
 
24
23
  action :get do
25
24
  #arg_processor "1.3" do |params|
@@ -46,6 +45,22 @@ class Host < ZabbixAPI_Base
46
45
  add "selectGroups"
47
46
  end
48
47
 
48
+ parameters "2.4" do
49
+ add "groupids","applicationids","dserviceids","graphids","hostids",
50
+ "httptestids","interfaceids","itemids","maintenanceids","monitored_hosts",
51
+ "proxy_hosts","proxyids","templated_hosts","templateids","triggerids",
52
+ "with_items","with_applications","with_graphs","with_httptests",
53
+ "with_monitored_httptests","with_monitored_items",
54
+ "with_monitored_triggers","with_simple_graph_items","with_triggers",
55
+ "withInventory","selectGroups","selectApplications","selectDiscoveries",
56
+ "selectDiscoveryRule","selectGraphs","selectHostDiscovery",
57
+ "selectHttpTests","selectInterfaces","selectInventory","selectItems",
58
+ "selectMacros","selectParentTemplates","selectScreens","selectTriggers",
59
+ "filter","limitSelects","search","searchInventory","sortfield",
60
+ "countOutput","editable","excludeSearch","limit","output","preservekeys",
61
+ "searchByAny","searchWildcardsEnabled","sortorder","startSearch"
62
+ end
63
+
49
64
  #parameters "3.0" do
50
65
  # inherit from "2.0"
51
66
  # remove "select_macros","preserve_keys","extendoutput"
@@ -73,6 +88,17 @@ class Host < ZabbixAPI_Base
73
88
  add "interfaces","macros"
74
89
  requires "interfaces"
75
90
  end
91
+
92
+ parameters "2.4" do
93
+ add "hostid","host","available","description","disable_until","error",
94
+ "errors_from","flags","ipmi_authtype","ipmi_available",
95
+ "ipmi_disable_until","ipmi_error","ipmi_errors_from","ipmi_password",
96
+ "ipmi_privilege","ipmi_username","jmx_available","jmx_disable_until",
97
+ "jmx_error","jmx_errors_from","maintenance_from","maintenance_status",
98
+ "maintenance_type","maintenanceid","name","proxy_hostid","snmp_available",
99
+ "snmp_disable_until","snmp_error","snmp_errors_from","status"
100
+ requires "host","groups","interfaces"
101
+ end
76
102
  end
77
103
 
78
104
  action :delete do
@@ -88,4 +114,48 @@ class Host < ZabbixAPI_Base
88
114
  end
89
115
  end
90
116
 
117
+ action :massadd do
118
+ parameters "2.4" do
119
+ add "hosts","groups","interfaces","macros","templates"
120
+ requires "hosts"
121
+ end
122
+ end
123
+
124
+ action :massremove do
125
+ parameters "2.4" do
126
+ add "hostids","groupids","interfaces","macros","templateids",
127
+ "templateids_clear"
128
+ requires "hostids"
129
+ end
130
+ end
131
+
132
+ action :update do
133
+ parameters "2.4" do
134
+ add "hostid","host","available","description","disable_until","error",
135
+ "errors_from","flags","ipmi_authtype","ipmi_available",
136
+ "ipmi_disable_until","ipmi_error","ipmi_errors_from","ipmi_password",
137
+ "ipmi_privilege","ipmi_username","jmx_available","jmx_disable_until",
138
+ "jmx_error","jmx_errors_from","maintenance_from","maintenance_status",
139
+ "maintenance_type","maintenanceid","name","proxy_hostid","snmp_available",
140
+ "snmp_disable_until","snmp_error","snmp_errors_from","status"
141
+ requires "host"
142
+ end
143
+ end
144
+
145
+ action :massupdate do
146
+ parameters "2.4" do
147
+ add "hostid","host","available","description","disable_until","error",
148
+ "errors_from","flags","ipmi_authtype","ipmi_available",
149
+ "ipmi_disable_until","ipmi_error","ipmi_errors_from","ipmi_password",
150
+ "ipmi_privilege","ipmi_username","jmx_available","jmx_disable_until",
151
+ "jmx_error","jmx_errors_from","maintenance_from","maintenance_status",
152
+ "maintenance_type","maintenanceid","name","proxy_hostid","snmp_available",
153
+ "snmp_disable_until","snmp_error","snmp_errors_from","status"
154
+ requires "host","hosts"
155
+ end
156
+ end
157
+
158
+ alias :massAdd :massadd
159
+ alias :massRemove :massremove
160
+ alias :massUpdate :massupdate
91
161
  end
@@ -27,15 +27,17 @@
27
27
  require "api_classes/api_dsl"
28
28
 
29
29
  class Trigger < ZabbixAPI_Base
30
- end
30
+ action :create do
31
+ parameters "2.4" do
32
+ add "triggerid","description","expression","comments","error","flags",
33
+ "lastchange","priority","state","status","templateid","type","url",
34
+ "value","dependencies"
35
+ requires "description","expression"
36
+ end
37
+ end
31
38
 
32
- Trigger.addDependencies
33
- Trigger.create
34
- Trigger.delete
35
- Trigger.deleteDependencies
36
- Trigger.exists
37
- Trigger.get do
38
- parameters "1.3",
39
+ action :get do
40
+ parameters "1.3",
39
41
  'triggerids', "select_functions", "nodeids", "groupids", "templateids",
40
42
  "hostids", "itemids", "applicationids", "functions", "inherited", "templated", "monitored",
41
43
  "active", "maintenance", "withUnacknowledgedEvents", "withAcknowledgedEvents",
@@ -44,6 +46,43 @@ Trigger.get do
44
46
  "startSearch", "excludeSearch", "searchWildcardsEnabled", "output", "expandData",
45
47
  "expandDescription", "select_groups", "select_hosts", "select_items", "select_dependencies",
46
48
  "countOutput", "groupOutput", "preservekeys", "sortfield", "sortorder", "limit"
49
+
50
+ parameters "2.4" do
51
+ add "triggerids","groupids","templateids","hostids","itemids",
52
+ "applicationids","functions","group","host","inherited","templated",
53
+ "monitored","active","maintenance","withUnacknowledgedEvents",
54
+ "withAcknowledgedEvents","withLastEventUnacknowledged","skipDependent",
55
+ "lastChangeSince","lastChangeTill","only_true","min_severity",
56
+ "expandComment","expandDescription","expandExpression","selectGroups",
57
+ "selectHosts","selectItems","selectFunctions","selectDependencies",
58
+ "selectDiscoveryRule","selectLastEvent","filter","limitSelects",
59
+ "sortfield","countOutput","editable","excludeSearch","limit","output",
60
+ "preservekeys","search","searchByAny","searchWildcardsEnabled",
61
+ "sortorder","startSearch"
62
+ #deprecate "expandData"
63
+ end
64
+ end
65
+
66
+ action :adddependencies do
67
+ parameters "2.4" do
68
+ add "triggerid","dependsOnTriggerid"
69
+ requires "triggerid","dependsOnTriggerid"
70
+ end
71
+ end
72
+
73
+ action :update do
74
+ parameters "2.4" do
75
+ add "triggerid","description","expression","comments","error","flags",
76
+ "lastchange","priority","state","status","templateid","type","url",
77
+ "value","dependencies"
78
+ requires "description","expression"
79
+ end
80
+ end
81
+
82
+ alias :addDependencies :adddependencies
47
83
  end
48
- Trigger.update
84
+
85
+ Trigger.delete
86
+ Trigger.deleteDependencies
87
+ Trigger.exists
49
88
 
data/zbxapi.rb CHANGED
@@ -70,20 +70,8 @@ class ZabbixAPI
70
70
 
71
71
  attr_accessor :method, :params, :debug_level, :auth, :verify_ssl, :proxy_server
72
72
 
73
- @id=0
74
- @auth=''
75
- @url=nil
76
- @verify_ssl=true
77
- @proxy_server=nil
78
- @custom_headers={}
79
-
80
- private
81
- @user_name=''
82
- @password=''
83
-
84
-
85
- class Redirect < Exception #:nodoc: all
86
- end
73
+ class Redirect < Exception #:nodoc: all
74
+ end
87
75
 
88
76
  public
89
77
 
@@ -112,6 +100,16 @@ class ZabbixAPI
112
100
  options={:debug=>0,:returntype=>:result}
113
101
  end
114
102
 
103
+ #intialization of instance variables must happen inside of instantiation
104
+ @id=0
105
+ @auth=''
106
+ @url=nil
107
+ @verify_ssl=true
108
+ @proxy_server=nil
109
+ @custom_headers={}
110
+ @user_name=''
111
+ @password=''
112
+
115
113
  set_debug_level(options[:debug] || 0)
116
114
  @returntype=options[:returntype] || :result
117
115
  @orig_url=url #save the original url
@@ -167,7 +165,6 @@ class ZabbixAPI
167
165
  debug(6,:msg=>"query: #{@url.query}, fragment: #{@url.fragment}")
168
166
 
169
167
  if block_given?
170
- puts "block"
171
168
  yield(self)
172
169
  end
173
170
  end
@@ -197,6 +194,12 @@ class ZabbixAPI
197
194
  'auth'=>@auth,
198
195
  'id'=>@id
199
196
  }
197
+
198
+ # Zabbix Doc(2.4): This method is available to unauthenticated
199
+ # users and must be called without the auth parameter
200
+ # in the JSON-RPC request.
201
+ obj.delete("auth") if method =~ /APIInfo/i
202
+
200
203
  debug(10, :msg=>"json_obj: #{obj}")
201
204
  return obj.to_json
202
205
  end
@@ -254,7 +257,7 @@ class ZabbixAPI
254
257
  raise ZbxAPI_ExceptionBadAuth.new('Invalid User or Password',:error_code=>e.error_code)
255
258
  end
256
259
  rescue SocketError
257
- raise ZbxAPI_ExceptionBadServerUrl
260
+ raise ZbxAPI_ExceptionBadServerUrl.new("Socket Error")
258
261
  rescue JSON::ParserError
259
262
  raise ZbxAPI_ExceptionBadServerUrl
260
263
  rescue Errno::ECONNREFUSED
@@ -399,7 +402,6 @@ class ZabbixAPI
399
402
  http=select_http_obj
400
403
  response = nil
401
404
  # http.set_debug_output($stderr) #Uncomment to see low level HTTP debug
402
-
403
405
  headers={
404
406
  'Content-Type'=>'application/json-rpc',
405
407
  'User-Agent'=>'Zbx Ruby CLI'
@@ -435,12 +437,12 @@ class ZabbixAPI
435
437
  end
436
438
  end
437
439
 
438
- return resp
440
+ return resp
439
441
 
440
- rescue Redirect
441
- redirects+=1
442
- retry if redirects<=5
443
- raise ZbxAPI_GeneralError, "Too many redirects"
442
+ rescue Redirect
443
+ redirects+=1
444
+ retry if redirects<=5
445
+ raise ZbxAPI_GeneralError, "Too many redirects"
444
446
  rescue NoMethodError
445
447
  raise ZbxAPI_GeneralError.new("Unable to connect to #{@url.host}: \"#{e}\"", :retry=>false)
446
448
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zbxapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - A. Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-10 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json