zbxapi 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/api_classes/api_dsl.rb +55 -6
- data/api_classes/dsl_host.rb +15 -13
- data/zbxapi.rb +6 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da5d57c042b37dff4802268848d2d82d54ad42f5
|
4
|
+
data.tar.gz: a66f80df000a511614d832c579c9f5652f882c34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fb0555b68e9adc08accb98ec5ac3ce75a574d5223f97026e5e03464fa6069943533836756fbe624f04a6b803dfe4ccbf0c8b2e10d2aaf61300dc3397c2872bd
|
7
|
+
data.tar.gz: 86dc9f211ece6963fcc2f8c1397b5ff4ccf1d6876b73a26fd6e28a1e69f9d239d6bb591940b23032f4d21b5ca35ba065fdb41d746d4ab000ed1bc9b79276cda6
|
data/api_classes/api_dsl.rb
CHANGED
@@ -29,6 +29,9 @@ require "zbxapi/exceptions"
|
|
29
29
|
require "pp"
|
30
30
|
|
31
31
|
class ZabbixAPI_ParametersDSL
|
32
|
+
class InvalidRequiredParameter<RuntimeError
|
33
|
+
end
|
34
|
+
|
32
35
|
attr_reader :valid_params, :required_params
|
33
36
|
|
34
37
|
def initialize(other_validparams,other_requiredparams)
|
@@ -38,27 +41,70 @@ class ZabbixAPI_ParametersDSL
|
|
38
41
|
@required_params=[]
|
39
42
|
end
|
40
43
|
|
44
|
+
#Inherit the valid and required parameters from the version string ver
|
41
45
|
def inherit(ver)
|
42
46
|
@valid_params=@other_valid_parameters[ver] || []
|
43
47
|
@required_params=@other_required_parameters[ver] || []
|
44
48
|
end
|
45
49
|
|
46
50
|
def add(*params)
|
51
|
+
location=caller.select {|i| i=~/api_classes\/dsl/}.first.split(":")[0..1].join(":")
|
52
|
+
#Iterate through the parameters and check to see if it's in the valid parameters list
|
53
|
+
#and check to see if it's been given before.
|
54
|
+
params.delete_if do |param|
|
55
|
+
if @valid_params.include? param
|
56
|
+
warn("Parameter '#{param}' is already a valid parameter, skipping: #{location}")
|
57
|
+
true
|
58
|
+
else
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
47
62
|
@valid_params+=params
|
48
63
|
@valid_params.flatten!
|
49
64
|
end
|
50
65
|
|
51
66
|
def remove(*params)
|
52
|
-
#TODO Add sanity checking to ensure that a removed parameter is also removed from the required list
|
53
67
|
@valid_params-=params
|
68
|
+
@required_params-=params
|
54
69
|
end
|
55
70
|
|
71
|
+
#Function to provide some syntactic sugar for the DSL
|
56
72
|
def from(var)
|
57
73
|
var
|
58
74
|
end
|
59
75
|
|
76
|
+
#Set the list of required parameters to the parameter list
|
77
|
+
def set_requires(*params)
|
78
|
+
location=caller.select {|i| i=~/api_classes\/dsl/}.first.split(":")[0..1].join(":")
|
79
|
+
#Iterate through the parameters and check to see if it's in the valid parameters list
|
80
|
+
#and check to see if it's been given before.
|
81
|
+
params.each do |param|
|
82
|
+
if !@valid_params.include? param
|
83
|
+
raise InvalidRequiredParameter.new("Parameter '#{param}' is not in the valid list of parameters: #{location}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
@required_params=params
|
88
|
+
@required_params.flatten!
|
89
|
+
end
|
90
|
+
|
91
|
+
#Append the parameters given to the required parameters list.
|
60
92
|
def requires(*params)
|
61
|
-
|
93
|
+
location=caller.select {|i| i=~/api_classes\/dsl/}.first.split(":")[0..1].join(":")
|
94
|
+
#Iterate through the parameters and check to see if it's in the valid parameters list
|
95
|
+
#and check to see if it's been given before.
|
96
|
+
params.delete_if do |param|
|
97
|
+
if !@valid_params.include? param
|
98
|
+
raise InvalidRequiredParameter.new("Parameter '#{param}' is not in the valid list of parameters: #{location}")
|
99
|
+
end
|
100
|
+
if @required_params.include? param
|
101
|
+
warn("Parameter '#{param}' is already a required parameter, skipping: #{location}")
|
102
|
+
true
|
103
|
+
else
|
104
|
+
false
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
62
108
|
@required_params+=params
|
63
109
|
@required_params.flatten!
|
64
110
|
end
|
@@ -376,14 +422,17 @@ class ZabbixAPI_Base
|
|
376
422
|
@api_aliases
|
377
423
|
end
|
378
424
|
|
379
|
-
|
425
|
+
# Define an alias for an existing method.
|
426
|
+
# From: the new method name
|
427
|
+
# To: the existing method which the alias "from" will point to
|
428
|
+
def self.api_alias(from,to)
|
380
429
|
@api_aliases={} if @api_aliases.nil?
|
381
430
|
@api_aliases[from]=to
|
382
431
|
|
383
|
-
@api_methods[
|
432
|
+
@api_methods[from]=@api_methods[to]
|
384
433
|
|
385
|
-
define_method(
|
386
|
-
self.class.api_methods[
|
434
|
+
define_method(from) do |params|
|
435
|
+
self.class.api_methods[from].do(@server,params)
|
387
436
|
end
|
388
437
|
end
|
389
438
|
|
data/api_classes/dsl_host.rb
CHANGED
@@ -90,15 +90,17 @@ class Host < ZabbixAPI_Base
|
|
90
90
|
end
|
91
91
|
|
92
92
|
parameters "2.4" do
|
93
|
-
|
94
|
-
"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
inherit from "2.0"
|
94
|
+
add "hostid","available","description","disable_until","error","errors_from",
|
95
|
+
"flags","inventory","ipmi_available","ipmi_disable_until","ipmi_error",
|
96
|
+
"ipmi_errors_from","jmx_available","jmx_disable_until","jmx_error",
|
97
|
+
"jmx_errors_from","maintenance_from","maintenance_status",
|
98
|
+
"maintenance_type","maintenanceid","snmp_available","snmp_disable_until",
|
99
|
+
"snmp_error","snmp_errors_from"
|
100
|
+
remove "dns","ip","ipmi_ip","port","useip","useipmi"
|
101
|
+
requires "host"
|
101
102
|
end
|
103
|
+
|
102
104
|
end
|
103
105
|
|
104
106
|
action :delete do
|
@@ -131,7 +133,7 @@ class Host < ZabbixAPI_Base
|
|
131
133
|
|
132
134
|
action :update do
|
133
135
|
parameters "2.4" do
|
134
|
-
add "hostid","host","available","description","disable_until","error",
|
136
|
+
add "host","hostid","host","available","description","disable_until","error",
|
135
137
|
"errors_from","flags","ipmi_authtype","ipmi_available",
|
136
138
|
"ipmi_disable_until","ipmi_error","ipmi_errors_from","ipmi_password",
|
137
139
|
"ipmi_privilege","ipmi_username","jmx_available","jmx_disable_until",
|
@@ -144,7 +146,7 @@ class Host < ZabbixAPI_Base
|
|
144
146
|
|
145
147
|
action :massupdate do
|
146
148
|
parameters "2.4" do
|
147
|
-
add "hostid","host","available","description","disable_until","error",
|
149
|
+
add "hostid","host","hosts","available","description","disable_until","error",
|
148
150
|
"errors_from","flags","ipmi_authtype","ipmi_available",
|
149
151
|
"ipmi_disable_until","ipmi_error","ipmi_errors_from","ipmi_password",
|
150
152
|
"ipmi_privilege","ipmi_username","jmx_available","jmx_disable_until",
|
@@ -155,7 +157,7 @@ class Host < ZabbixAPI_Base
|
|
155
157
|
end
|
156
158
|
end
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
160
|
+
api_alias :massAdd, :massadd
|
161
|
+
api_alias :massRemove, :massremove
|
162
|
+
api_alias :massUpdate, :massupdate
|
161
163
|
end
|
data/zbxapi.rb
CHANGED
@@ -195,10 +195,15 @@ class ZabbixAPI
|
|
195
195
|
'id'=>@id
|
196
196
|
}
|
197
197
|
|
198
|
+
# https://www.zabbix.com/documentation/2.4/manual/api/reference/apiinfo/version
|
199
|
+
# https://www.zabbix.com/documentation/2.4/manual/api/reference/user/login
|
198
200
|
# Zabbix Doc(2.4): This method is available to unauthenticated
|
199
201
|
# users and must be called without the auth parameter
|
200
202
|
# in the JSON-RPC request.
|
201
|
-
|
203
|
+
debug(4, :var => method,:msg => "Method:")
|
204
|
+
obj.delete("auth") if ["apiinfo.version",
|
205
|
+
"user.login",
|
206
|
+
].any? { |str| method =~ /#{str}/i }
|
202
207
|
|
203
208
|
debug(10, :msg=>"json_obj: #{obj}")
|
204
209
|
return obj.to_json
|
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.
|
4
|
+
version: 0.3.10
|
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-11-
|
11
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -39,29 +39,29 @@ files:
|
|
39
39
|
- zbxapi/utils.rb
|
40
40
|
- zbxapi/result.rb
|
41
41
|
- api_classes/api_dsl.rb
|
42
|
-
- api_classes/
|
43
|
-
- api_classes/dsl_dhost.rb
|
42
|
+
- api_classes/dsl_action.rb
|
44
43
|
- api_classes/dsl_event.rb
|
45
|
-
- api_classes/
|
44
|
+
- api_classes/dsl_alert.rb
|
46
45
|
- api_classes/dsl_user.rb
|
47
46
|
- api_classes/dsl_drule.rb
|
47
|
+
- api_classes/dsl_host.rb
|
48
|
+
- api_classes/dsl_trigger.rb
|
49
|
+
- api_classes/dsl_dcheck.rb
|
50
|
+
- api_classes/dsl_history.rb
|
51
|
+
- api_classes/dsl_mediatype.rb
|
48
52
|
- api_classes/dsl_hostgroup.rb
|
53
|
+
- api_classes/dsl_usermedia.rb
|
49
54
|
- api_classes/dsl_dservice.rb
|
50
|
-
- api_classes/
|
51
|
-
- api_classes/dsl_template.rb
|
55
|
+
- api_classes/dsl_item.rb
|
52
56
|
- api_classes/dsl_proxy.rb
|
53
|
-
- api_classes/
|
54
|
-
- api_classes/dsl_hostinterface.rb
|
55
|
-
- api_classes/dsl_action.rb
|
57
|
+
- api_classes/dsl_template.rb
|
56
58
|
- api_classes/dsl_maintenance.rb
|
57
|
-
- api_classes/
|
58
|
-
- api_classes/dsl_history.rb
|
59
|
-
- api_classes/dsl_dcheck.rb
|
60
|
-
- api_classes/dsl_trigger.rb
|
59
|
+
- api_classes/dsl_dhost.rb
|
61
60
|
- api_classes/dsl_configuration.rb
|
61
|
+
- api_classes/dsl_usergroup.rb
|
62
|
+
- api_classes/dsl_hostinterface.rb
|
62
63
|
- api_classes/dsl_usermacro.rb
|
63
|
-
- api_classes/
|
64
|
-
- api_classes/dsl_host.rb
|
64
|
+
- api_classes/dsl_graph.rb
|
65
65
|
homepage: https://github.com/red-tux/zbxapi
|
66
66
|
licenses:
|
67
67
|
- LGPL 2.1
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
requirements:
|
84
84
|
- Requires json
|
85
85
|
rubyforge_project: zbxapi
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.1.11
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Ruby wrapper to the Zabbix API
|