zabbix_api_gem 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -3
- data/lib/zabbix/client.rb +17 -4
- data/lib/zabbix/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0dc1d0b264ed6c36ccbf9253f530dfdd2fc7ff2eaa7c060dc9324944f00384f
|
4
|
+
data.tar.gz: 482565767d3e1a484223b28330f271ce9ab7ab51177b615f619a46c71199f227
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ac9b890f3a197fb09a746dbd1e027a0b2a43b81feeb7ff8e03a9a1a302d47f213ed0a3e15a1464ba2a93181f0d290763a498df09c1bae36d212040066b94e4
|
7
|
+
data.tar.gz: '09094378b9e9616719bce054bced52e39ea3718abec9f9031cc0a78c8bdc2c6600617dc7989177c1a59125cc79a317962b61ff98ba7719dfc41f7ecef2016ecf'
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -84,9 +84,10 @@ end
|
|
84
84
|
|
85
85
|
|Resource|API endpoint|
|
86
86
|
|:--|:--|
|
87
|
-
|
88
|
-
|.hosts|hosts.get|
|
89
|
-
|.problems|problems.get|
|
87
|
+
|hostgroups, hostgroup(hostgroup_id)|hostgroup.get|
|
88
|
+
|.hosts, host(host_id)|hosts.get|
|
89
|
+
|.problems, problem(event_id)|problems.get|
|
90
|
+
|.events, event(event_id)|problems.get|
|
90
91
|
|
91
92
|
|
92
93
|
|
data/lib/zabbix/client.rb
CHANGED
@@ -7,17 +7,30 @@ module Zabbix
|
|
7
7
|
# @see https://www.zabbix.com/documentation/current/en/manual/api
|
8
8
|
class Client < API
|
9
9
|
|
10
|
-
def self.def_rpc_call(method, rpc_method)
|
10
|
+
def self.def_rpc_call(method, rpc_method, id_field = nil)
|
11
11
|
self.send(:define_method, method) do |params = nil|
|
12
12
|
rpc_call(rpc_method, params)
|
13
13
|
end
|
14
|
+
if id_field
|
15
|
+
# strip trailing 's'
|
16
|
+
singular = method.to_s.chop.to_sym
|
17
|
+
self.send(:define_method, singular) do |ids,params = nil|
|
18
|
+
if ids.is_a?(Array)
|
19
|
+
rpc_call(rpc_method, {"#{id_field}":ids}.merge(params || {}))
|
20
|
+
else
|
21
|
+
rpc_call(rpc_method, {"#{id_field}":[ids]}.merge(params || {})).first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
14
25
|
end
|
15
26
|
|
16
27
|
def_rpc_call(:api_info, 'api.info')
|
17
28
|
def_rpc_call(:settings, 'settings.get')
|
18
|
-
def_rpc_call(:hostgroups, 'hostgroup.get')
|
19
|
-
def_rpc_call(:hosts, 'host.get')
|
20
|
-
def_rpc_call(:problems, 'problem.get')
|
29
|
+
def_rpc_call(:hostgroups, 'hostgroup.get', 'groupids')
|
30
|
+
def_rpc_call(:hosts, 'host.get', 'hostids')
|
31
|
+
def_rpc_call(:problems, 'problem.get', 'problemids')
|
32
|
+
def_rpc_call(:events, 'event.get', 'eventids')
|
33
|
+
def_rpc_call(:acknowledge_events, 'event.acknowledge')
|
21
34
|
|
22
35
|
end
|
23
36
|
end
|
data/lib/zabbix/version.rb
CHANGED