zabbixapi 4.1.2 → 4.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 +3 -5
- data/lib/zabbixapi.rb +6 -0
- data/lib/zabbixapi/basic/basic_alias.rb +0 -0
- data/lib/zabbixapi/basic/basic_func.rb +0 -0
- data/lib/zabbixapi/basic/basic_init.rb +0 -0
- data/lib/zabbixapi/basic/basic_logic.rb +0 -0
- data/lib/zabbixapi/classes/actions.rb +0 -0
- data/lib/zabbixapi/classes/applications.rb +0 -0
- data/lib/zabbixapi/classes/configurations.rb +0 -0
- data/lib/zabbixapi/classes/drules.rb +0 -0
- data/lib/zabbixapi/classes/errors.rb +0 -0
- data/lib/zabbixapi/classes/events.rb +17 -0
- data/lib/zabbixapi/classes/graphs.rb +0 -0
- data/lib/zabbixapi/classes/hostgroups.rb +0 -0
- data/lib/zabbixapi/classes/hosts.rb +0 -0
- data/lib/zabbixapi/classes/httptests.rb +0 -0
- data/lib/zabbixapi/classes/items.rb +2 -2
- data/lib/zabbixapi/classes/maintenance.rb +0 -0
- data/lib/zabbixapi/classes/mediatypes.rb +0 -0
- data/lib/zabbixapi/classes/proxies.rb +0 -0
- data/lib/zabbixapi/classes/screens.rb +0 -0
- data/lib/zabbixapi/classes/scripts.rb +0 -0
- data/lib/zabbixapi/classes/server.rb +1 -1
- data/lib/zabbixapi/classes/templates.rb +0 -0
- data/lib/zabbixapi/classes/triggers.rb +0 -0
- data/lib/zabbixapi/classes/unusable.rb +0 -0
- data/lib/zabbixapi/classes/usergroups.rb +12 -15
- data/lib/zabbixapi/classes/usermacros.rb +0 -0
- data/lib/zabbixapi/classes/users.rb +9 -7
- data/lib/zabbixapi/classes/valuemaps.rb +0 -0
- data/lib/zabbixapi/client.rb +11 -2
- data/lib/zabbixapi/version.rb +1 -1
- data/zabbixapi.gemspec +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58451fc1a06fa45c0ac63d0ec7d66c567455ae0eba7cc8a548cb223c8af3a987
|
4
|
+
data.tar.gz: 7574a95089d1a4c32bfb30273dfd731e726b2367e50edd849d8165e06e033868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d432eb203cfe6723dea2d47fbc4a0c064131e9e732e08f6c753e6ed567d29f83e307335ee52c670b4ab8fc4e22381dbee8c614957e710785816eaf5fad50857
|
7
|
+
data.tar.gz: 75cfa60403d32ab616e5caf6670c4b2a4bb3014606d6966a383a88e13e24284b49034fce287d0209a9e0637e53043b4235fe39ca70d194150c163924af32cd6f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#CHANGELOG
|
2
2
|
|
3
|
+
## 4.2.0
|
4
|
+
[PR #102](https://github.com/express42/zabbixapi/pull/102) Add events get method method. Fixed all testing failures. (Thanks @kevin-j-smith)
|
5
|
+
|
3
6
|
## 4.1.2
|
4
7
|
[PR #99](https://github.com/express42/zabbixapi/pull/99) Patch addressing log error function not found
|
5
8
|
|
data/README.md
CHANGED
@@ -36,12 +36,10 @@ We support only two last versions of zabbix (4.0 and 4.2), so you should conside
|
|
36
36
|
This library aims to support and is [tested against][travis] the following Ruby
|
37
37
|
versions:
|
38
38
|
|
39
|
-
* Ruby 2.0
|
40
|
-
* Ruby 2.1
|
41
|
-
* Ruby 2.2
|
42
|
-
* Ruby 2.3
|
43
39
|
* Ruby 2.4
|
44
|
-
*
|
40
|
+
* Ruby 2.5
|
41
|
+
* Ruby 2.6
|
42
|
+
* JRuby 9.2.10.0
|
45
43
|
|
46
44
|
If something doesn't work on one of these versions, it's a bug.
|
47
45
|
|
data/lib/zabbixapi.rb
CHANGED
@@ -10,6 +10,7 @@ require 'zabbixapi/classes/actions'
|
|
10
10
|
require 'zabbixapi/classes/applications'
|
11
11
|
require 'zabbixapi/classes/configurations'
|
12
12
|
require 'zabbixapi/classes/errors'
|
13
|
+
require 'zabbixapi/classes/events'
|
13
14
|
require 'zabbixapi/classes/graphs'
|
14
15
|
require 'zabbixapi/classes/hostgroups'
|
15
16
|
require 'zabbixapi/classes/hosts'
|
@@ -84,6 +85,11 @@ class ZabbixApi
|
|
84
85
|
@configurations ||= Configurations.new(@client)
|
85
86
|
end
|
86
87
|
|
88
|
+
# @return [ZabbixApi::Events]
|
89
|
+
def events
|
90
|
+
@events ||= Events.new(@client)
|
91
|
+
end
|
92
|
+
|
87
93
|
# @return [ZabbixApi::Graphs]
|
88
94
|
def graphs
|
89
95
|
@graphs ||= Graphs.new(@client)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ZabbixApi
|
2
|
+
class Events < Basic
|
3
|
+
# The method name used for interacting with Events via Zabbix API
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
def method_name
|
7
|
+
'event'
|
8
|
+
end
|
9
|
+
|
10
|
+
# The id field name used for identifying specific Event objects via Zabbix API
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
def indentify
|
14
|
+
'name'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -23,7 +23,7 @@ class ZabbixApi
|
|
23
23
|
key_: nil,
|
24
24
|
hostid: nil,
|
25
25
|
delay: 60,
|
26
|
-
history:
|
26
|
+
history: 3600,
|
27
27
|
status: 0,
|
28
28
|
type: 7,
|
29
29
|
snmp_community: '',
|
@@ -40,7 +40,7 @@ class ZabbixApi
|
|
40
40
|
snmpv3_authpassphrase: '',
|
41
41
|
snmpv3_privpassphrase: '',
|
42
42
|
formula: 0,
|
43
|
-
trends:
|
43
|
+
trends: 86400,
|
44
44
|
logtimefmt: '',
|
45
45
|
valuemapid: 0,
|
46
46
|
delay_flex: '',
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -30,9 +30,9 @@ class ZabbixApi
|
|
30
30
|
def permissions(data)
|
31
31
|
permission = data[:permission] || 2
|
32
32
|
result = @client.api_request(
|
33
|
-
method: 'usergroup.
|
33
|
+
method: 'usergroup.update',
|
34
34
|
params: {
|
35
|
-
|
35
|
+
usrgrpid: data[:usrgrpid],
|
36
36
|
rights: data[:hostgroupids].map { |t| { permission: permission, id: t } }
|
37
37
|
}
|
38
38
|
)
|
@@ -41,19 +41,13 @@ class ZabbixApi
|
|
41
41
|
|
42
42
|
# Add users to usergroup using Zabbix API
|
43
43
|
#
|
44
|
+
# @deprecated Zabbix has removed massAdd in favor of update.
|
44
45
|
# @param data [Hash] Needs to include userids and usrgrpids to mass add users to groups
|
45
46
|
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
46
47
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
47
48
|
# @return [Integer] Zabbix object id (usergroup)
|
48
49
|
def add_user(data)
|
49
|
-
|
50
|
-
method: 'usergroup.massAdd',
|
51
|
-
params: {
|
52
|
-
usrgrpids: data[:usrgrpids],
|
53
|
-
userids: data[:userids]
|
54
|
-
}
|
55
|
-
)
|
56
|
-
result ? result['usrgrpids'][0].to_i : nil
|
50
|
+
update_users(data)
|
57
51
|
end
|
58
52
|
|
59
53
|
# Update users in usergroups using Zabbix API
|
@@ -63,12 +57,15 @@ class ZabbixApi
|
|
63
57
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
64
58
|
# @return [Integer] Zabbix object id (usergroup)
|
65
59
|
def update_users(data)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
userids: data[:userids]
|
60
|
+
user_groups = data[:usrgrpids].map do |t|
|
61
|
+
{
|
62
|
+
usrgrpid: t,
|
63
|
+
userids: data[:userids],
|
71
64
|
}
|
65
|
+
end
|
66
|
+
result = @client.api_request(
|
67
|
+
method: 'usergroup.update',
|
68
|
+
params: user_groups,
|
72
69
|
)
|
73
70
|
result ? result['usrgrpids'][0].to_i : nil
|
74
71
|
end
|
File without changes
|
@@ -31,12 +31,14 @@ class ZabbixApi
|
|
31
31
|
def medias_helper(data, action)
|
32
32
|
result = @client.api_request(
|
33
33
|
method: "user.#{action}",
|
34
|
-
params:
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
params: data[:userids].map do |t|
|
35
|
+
{
|
36
|
+
userid: t,
|
37
|
+
user_medias: data[:media],
|
38
|
+
}
|
39
|
+
end,
|
38
40
|
)
|
39
|
-
result ? result['
|
41
|
+
result ? result['userids'][0].to_i : nil
|
40
42
|
end
|
41
43
|
|
42
44
|
# Add media to users using Zabbix API
|
@@ -46,7 +48,7 @@ class ZabbixApi
|
|
46
48
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
47
49
|
# @return [Integer] Zabbix object id (media)
|
48
50
|
def add_medias(data)
|
49
|
-
medias_helper(data, '
|
51
|
+
medias_helper(data, 'update')
|
50
52
|
end
|
51
53
|
|
52
54
|
# Update media for users using Zabbix API
|
@@ -56,7 +58,7 @@ class ZabbixApi
|
|
56
58
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
57
59
|
# @return [Integer] Zabbix object id (user)
|
58
60
|
def update_medias(data)
|
59
|
-
medias_helper(data, '
|
61
|
+
medias_helper(data, 'update')
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
File without changes
|
data/lib/zabbixapi/client.rb
CHANGED
@@ -18,6 +18,7 @@ class ZabbixApi
|
|
18
18
|
# @return [String]
|
19
19
|
def api_version
|
20
20
|
@api_version ||= api_request(method: 'apiinfo.version', params: {})
|
21
|
+
@api_version
|
21
22
|
end
|
22
23
|
|
23
24
|
# Log in to the Zabbix Server and generate an auth token using the API
|
@@ -33,6 +34,13 @@ class ZabbixApi
|
|
33
34
|
)
|
34
35
|
end
|
35
36
|
|
37
|
+
# ZabbixApi::Basic.log does not like @client.options[:debug]
|
38
|
+
#
|
39
|
+
# @return [boolean]
|
40
|
+
def debug?
|
41
|
+
return ! @options || @options[:debug]
|
42
|
+
end
|
43
|
+
|
36
44
|
# Initializes a new Client object
|
37
45
|
#
|
38
46
|
# @param options [Hash]
|
@@ -52,8 +60,9 @@ class ZabbixApi
|
|
52
60
|
@proxy_port = @proxy_uri.port
|
53
61
|
@proxy_user, @proxy_pass = @proxy_uri.userinfo.split(/:/) if @proxy_uri.userinfo
|
54
62
|
end
|
55
|
-
unless api_version =~ %r{^4.[0|
|
56
|
-
|
63
|
+
unless api_version =~ %r{^4.[0|4]\.\d+$}
|
64
|
+
message = "Zabbix API version: #{api_version} is not supported by this version of zabbixapi"
|
65
|
+
raise ZabbixApi::ApiError.new(message)
|
57
66
|
end
|
58
67
|
|
59
68
|
@auth_hash = auth
|
data/lib/zabbixapi/version.rb
CHANGED
data/zabbixapi.gemspec
CHANGED
@@ -9,7 +9,7 @@ require 'zabbixapi/version'
|
|
9
9
|
Gem::Specification.new do |spec|
|
10
10
|
spec.add_dependency 'http', '~> 2.0'
|
11
11
|
spec.add_dependency 'json', '~> 2.0'
|
12
|
-
spec.add_development_dependency 'bundler'
|
12
|
+
spec.add_development_dependency 'bundler'
|
13
13
|
|
14
14
|
spec.name = 'zabbixapi'
|
15
15
|
spec.version = ZabbixApi::VERSION
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zabbixapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev D.V.
|
8
8
|
- Ivan Evtuhovich
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0'
|
56
56
|
description: Allows you to work with zabbix api from ruby.
|
57
57
|
email:
|
58
58
|
- vadv.mkn@gmail.com
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/zabbixapi/classes/configurations.rb
|
75
75
|
- lib/zabbixapi/classes/drules.rb
|
76
76
|
- lib/zabbixapi/classes/errors.rb
|
77
|
+
- lib/zabbixapi/classes/events.rb
|
77
78
|
- lib/zabbixapi/classes/graphs.rb
|
78
79
|
- lib/zabbixapi/classes/hostgroups.rb
|
79
80
|
- lib/zabbixapi/classes/hosts.rb
|
@@ -99,7 +100,7 @@ homepage: https://github.com/express42/zabbixapi
|
|
99
100
|
licenses:
|
100
101
|
- MIT
|
101
102
|
metadata: {}
|
102
|
-
post_install_message:
|
103
|
+
post_install_message:
|
103
104
|
rdoc_options: []
|
104
105
|
require_paths:
|
105
106
|
- lib
|
@@ -114,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
118
|
+
rubygems_version: 3.1.2
|
119
|
+
signing_key:
|
119
120
|
specification_version: 4
|
120
121
|
summary: Simple and lightweight ruby module for working with the Zabbix API
|
121
122
|
test_files: []
|