zabbixapi 4.0.0 → 4.1.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE.md +1 -1
- data/README.md +0 -1
- data/lib/zabbixapi.rb +12 -0
- data/lib/zabbixapi/classes/drules.rb +55 -0
- data/lib/zabbixapi/client.rb +10 -0
- data/lib/zabbixapi/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 487cf74b4af955baf4a18b789b90185235a789a1
|
4
|
+
data.tar.gz: d19ee4e5b3bf2e5f514795bc83a69cde75d8c29c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc2f217355f205c40eb991469834a45d84e7f89adf7f28a9b9233e64a085c06300fb13d49bb2c96064681ea3f44f986a84fa1952e86416b05b6547e1fcfd1480
|
7
|
+
data.tar.gz: acc66046eeb21fdccf0404d19c3eedef36bb31fdd49945e8eb3a6f7793e15c0f0d65f2c3128b9591af763b0157f9d0f29b1f06149d853c27798132a5899f9c51
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 4.1.0
|
2
|
+
|
3
|
+
[PR #82](https://github.com/express42/zabbixapi/pull/82) Add logout method (Thanks @baurmatt)
|
4
|
+
|
5
|
+
[PR #86](https://github.com/express42/zabbixapi/pull/86) Feature: add support for Discovery Rules (`drule` API) (Thanks @lehn-etracker)
|
6
|
+
|
1
7
|
## 4.0.0
|
2
8
|
|
3
9
|
[PR #90](https://github.com/express42/zabbixapi/pull/90) Add 4.0 support (Thanks @svdasein)
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
data/lib/zabbixapi.rb
CHANGED
@@ -28,6 +28,7 @@ require 'zabbixapi/classes/usergroups'
|
|
28
28
|
require 'zabbixapi/classes/usermacros'
|
29
29
|
require 'zabbixapi/classes/users'
|
30
30
|
require 'zabbixapi/classes/valuemaps'
|
31
|
+
require 'zabbixapi/classes/drules'
|
31
32
|
|
32
33
|
class ZabbixApi
|
33
34
|
# @return [ZabbixApi::Client]
|
@@ -54,6 +55,12 @@ class ZabbixApi
|
|
54
55
|
@client.api_request(:method => data[:method], :params => data[:params])
|
55
56
|
end
|
56
57
|
|
58
|
+
# Invalidate current authentication token
|
59
|
+
# @return [Boolean]
|
60
|
+
def logout
|
61
|
+
@client.logout
|
62
|
+
end
|
63
|
+
|
57
64
|
# Initializes a new ZabbixApi object
|
58
65
|
#
|
59
66
|
# @param options [Hash]
|
@@ -161,4 +168,9 @@ class ZabbixApi
|
|
161
168
|
def valuemaps
|
162
169
|
@valuemaps ||= ValueMaps.new(@client)
|
163
170
|
end
|
171
|
+
|
172
|
+
# @return [ZabbixApi::Drules]
|
173
|
+
def drules
|
174
|
+
@drules ||= Drules.new(@client)
|
175
|
+
end
|
164
176
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class ZabbixApi
|
2
|
+
class Drules < Basic
|
3
|
+
# The method name used for interacting with Drules via Zabbix API
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
def method_name
|
7
|
+
'drule'
|
8
|
+
end
|
9
|
+
|
10
|
+
# The id field name used for identifying specific Drule objects via Zabbix API
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
def indentify
|
14
|
+
'name'
|
15
|
+
end
|
16
|
+
|
17
|
+
# The default options used when creating Drule objects via Zabbix API
|
18
|
+
#
|
19
|
+
# @return [Hash]
|
20
|
+
def default_options
|
21
|
+
{
|
22
|
+
name: nil,
|
23
|
+
iprange: nil,
|
24
|
+
delay: 3600,
|
25
|
+
status: 0,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get or Create Drule object using Zabbix API
|
30
|
+
#
|
31
|
+
# @param data [Hash] Needs to include name to properly identify Drule via Zabbix API
|
32
|
+
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
33
|
+
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
34
|
+
# @return [Integer] Zabbix object id
|
35
|
+
def get_or_create(data)
|
36
|
+
log "[DEBUG] Call get_or_create with parameters: #{data.inspect}"
|
37
|
+
|
38
|
+
unless (id = get_id(name: data[:name]))
|
39
|
+
id = create(data)
|
40
|
+
end
|
41
|
+
id
|
42
|
+
end
|
43
|
+
|
44
|
+
# Create or update Drule object using Zabbix API
|
45
|
+
#
|
46
|
+
# @param data [Hash] Needs to include name to properly identify Drules via Zabbix API
|
47
|
+
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
48
|
+
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
49
|
+
# @return [Integer] Zabbix object id
|
50
|
+
def create_or_update(data)
|
51
|
+
druleid = get_id(name: data[:name])
|
52
|
+
druleid ? update(data.merge(druleid: druleid)) : create(data)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/zabbixapi/client.rb
CHANGED
@@ -32,6 +32,16 @@ class ZabbixApi
|
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
|
+
# Log out from the Zabbix Server
|
36
|
+
#
|
37
|
+
# @return [Boolean]
|
38
|
+
def logout
|
39
|
+
api_request(
|
40
|
+
:method => 'user.logout',
|
41
|
+
:params => []
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
35
45
|
# Initializes a new Client object
|
36
46
|
#
|
37
47
|
# @param options [Hash]
|
data/lib/zabbixapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zabbixapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev D.V.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-12-
|
12
|
+
date: 2018-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/zabbixapi/classes/actions.rb
|
74
74
|
- lib/zabbixapi/classes/applications.rb
|
75
75
|
- lib/zabbixapi/classes/configurations.rb
|
76
|
+
- lib/zabbixapi/classes/drules.rb
|
76
77
|
- lib/zabbixapi/classes/errors.rb
|
77
78
|
- lib/zabbixapi/classes/graphs.rb
|
78
79
|
- lib/zabbixapi/classes/hostgroups.rb
|