zabbixapi_mgx 5.0.0.pre.alpha2 → 7.2.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/lib/zabbixapi/classes/actions.rb +1 -1
- data/lib/zabbixapi/classes/hosts.rb +1 -2
- data/lib/zabbixapi/classes/problems.rb +0 -1
- data/lib/zabbixapi/classes/proxies.rb +1 -1
- data/lib/zabbixapi/classes/templates.rb +6 -9
- data/lib/zabbixapi/classes/usergroups.rb +2 -2
- data/lib/zabbixapi/classes/users.rb +2 -2
- data/lib/zabbixapi/client.rb +4 -6
- data/lib/zabbixapi/version.rb +1 -1
- data/lib/zabbixapi.rb +0 -6
- metadata +8 -9
- data/lib/zabbixapi/classes/applications.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba3a08c63fe50a869bcac02554129a491824376447f9909cdf8fcd7ac1b94822
|
4
|
+
data.tar.gz: 16341e9118f66db1cca7eb2ee1e52a3906321578712ea857edf1628228a71e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f338d70e0ae66c3ab623bf416c9a74da7173d34713e74ccfcca2a89bc171917f0b7560cfc2ac9b40614b523c5a6692275e8ed8d6bcc0c31b573ee60586cefabd
|
7
|
+
data.tar.gz: '0770190620835682928d1abc3f8a13d772b9df4b32db54b2c49c97b3960d7b3dfa1f766c2cad60a090d602009e1a666304b5fd77f6caeb32908f665b2cec7acf'
|
@@ -30,7 +30,7 @@ class ZabbixApi
|
|
30
30
|
key.to_sym => data[key.to_sym]
|
31
31
|
},
|
32
32
|
output: 'extend',
|
33
|
-
|
33
|
+
selectHostGroups: 'extend'
|
34
34
|
}
|
35
35
|
)
|
36
36
|
end
|
@@ -45,7 +45,6 @@ class ZabbixApi
|
|
45
45
|
status: 0,
|
46
46
|
available: 1,
|
47
47
|
groups: [],
|
48
|
-
proxy_hostid: nil
|
49
48
|
}
|
50
49
|
end
|
51
50
|
|
@@ -71,7 +71,6 @@ class ZabbixApi
|
|
71
71
|
groupids: data[:groupids] || nil,
|
72
72
|
hostids: data[:hostids] || nil,
|
73
73
|
objectids: data[:objectids] || nil,
|
74
|
-
applicationids: data[:applicationids] || nil,
|
75
74
|
tags: data[:tags] || nil,
|
76
75
|
time_from: data[:time_from] || nil,
|
77
76
|
time_till: data[:time_till] || nil,
|
@@ -50,9 +50,9 @@ class ZabbixApi
|
|
50
50
|
templateid
|
51
51
|
end
|
52
52
|
|
53
|
-
# Mass update Templates
|
53
|
+
# Mass update Templates using Zabbix API
|
54
54
|
#
|
55
|
-
# @param data [Hash] Should include
|
55
|
+
# @param data [Hash] Should include templates_id array
|
56
56
|
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
57
57
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
58
58
|
# @return [Boolean]
|
@@ -60,16 +60,15 @@ class ZabbixApi
|
|
60
60
|
result = @client.api_request(
|
61
61
|
method: 'template.massUpdate',
|
62
62
|
params: {
|
63
|
-
hosts: data[:hosts_id].map { |t| { hostid: t } },
|
64
63
|
templates: data[:templates_id].map { |t| { templateid: t } }
|
65
64
|
}
|
66
65
|
)
|
67
66
|
result.empty? ? false : true
|
68
67
|
end
|
69
68
|
|
70
|
-
# Mass add Templates
|
69
|
+
# Mass add Templates using Zabbix API
|
71
70
|
#
|
72
|
-
# @param data [Hash] Should include
|
71
|
+
# @param data [Hash] Should include templates_id array
|
73
72
|
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
74
73
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
75
74
|
# @return [Boolean]
|
@@ -77,16 +76,15 @@ class ZabbixApi
|
|
77
76
|
result = @client.api_request(
|
78
77
|
method: 'template.massAdd',
|
79
78
|
params: {
|
80
|
-
hosts: data[:hosts_id].map { |t| { hostid: t } },
|
81
79
|
templates: data[:templates_id].map { |t| { templateid: t } }
|
82
80
|
}
|
83
81
|
)
|
84
82
|
result.empty? ? false : true
|
85
83
|
end
|
86
84
|
|
87
|
-
# Mass remove Templates
|
85
|
+
# Mass remove Templates using Zabbix API
|
88
86
|
#
|
89
|
-
# @param data [Hash] Should include
|
87
|
+
# @param data [Hash] Should include templates_id array
|
90
88
|
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
91
89
|
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
92
90
|
# @return [Boolean]
|
@@ -94,7 +92,6 @@ class ZabbixApi
|
|
94
92
|
result = @client.api_request(
|
95
93
|
method: 'template.massRemove',
|
96
94
|
params: {
|
97
|
-
hostids: data[:hosts_id],
|
98
95
|
templateids: data[:templates_id],
|
99
96
|
groupids: data[:group_id],
|
100
97
|
force: 1
|
@@ -33,7 +33,7 @@ class ZabbixApi
|
|
33
33
|
method: 'usergroup.update',
|
34
34
|
params: {
|
35
35
|
usrgrpid: data[:usrgrpid],
|
36
|
-
|
36
|
+
hostgroup_rights: data[:hostgroupids].map { |t| { permission: permission, id: t } }
|
37
37
|
}
|
38
38
|
)
|
39
39
|
result ? result['usrgrpids'][0].to_i : nil
|
@@ -60,7 +60,7 @@ class ZabbixApi
|
|
60
60
|
user_groups = data[:usrgrpids].map do |t|
|
61
61
|
{
|
62
62
|
usrgrpid: t,
|
63
|
-
|
63
|
+
users: data[:userids].map { |t| { userid: t } }
|
64
64
|
}
|
65
65
|
end
|
66
66
|
result = @client.api_request(
|
@@ -25,7 +25,7 @@ class ZabbixApi
|
|
25
25
|
#
|
26
26
|
# @return [String]
|
27
27
|
def identify
|
28
|
-
'
|
28
|
+
'username'
|
29
29
|
end
|
30
30
|
|
31
31
|
def medias_helper(data, action)
|
@@ -34,7 +34,7 @@ class ZabbixApi
|
|
34
34
|
params: data[:userids].map do |t|
|
35
35
|
{
|
36
36
|
userid: t,
|
37
|
-
|
37
|
+
medias: data[:media],
|
38
38
|
}
|
39
39
|
end,
|
40
40
|
)
|
data/lib/zabbixapi/client.rb
CHANGED
@@ -71,7 +71,7 @@ class ZabbixApi
|
|
71
71
|
@proxy_port = @proxy_uri.port
|
72
72
|
@proxy_user, @proxy_pass = @proxy_uri.userinfo.split(/:/) if @proxy_uri.userinfo
|
73
73
|
end
|
74
|
-
unless api_version =~ %r{^
|
74
|
+
unless api_version =~ %r{^7.[0|2]\.\d+$}
|
75
75
|
message = "Zabbix API version: #{api_version} is not supported by this version of zabbixapi"
|
76
76
|
if @options[:ignore_version]
|
77
77
|
puts "[WARNING] #{message}" if @options[:debug]
|
@@ -95,8 +95,6 @@ class ZabbixApi
|
|
95
95
|
jsonrpc: '2.0'
|
96
96
|
}
|
97
97
|
|
98
|
-
message[:auth] = @auth_hash unless body[:method] == 'apiinfo.version' || body[:method] == 'user.login'
|
99
|
-
|
100
98
|
JSON.generate(message)
|
101
99
|
end
|
102
100
|
|
@@ -125,9 +123,9 @@ class ZabbixApi
|
|
125
123
|
http.read_timeout = timeout
|
126
124
|
|
127
125
|
request = Net::HTTP::Post.new(uri.request_uri)
|
128
|
-
request.basic_auth @options[:http_user], @options[:http_password] if @options[:http_user]
|
129
126
|
request.add_field('Content-Type', 'application/json-rpc')
|
130
|
-
request.body
|
127
|
+
request.add_field('Authorization', "Bearer #{@auth_hash}") unless body[:method] == 'apiinfo.version' || body[:method] == 'user.login'
|
128
|
+
request.body = message_json(body)
|
131
129
|
|
132
130
|
response = http.request(request)
|
133
131
|
|
@@ -161,7 +159,7 @@ class ZabbixApi
|
|
161
159
|
# @param body [Hash]
|
162
160
|
# @return [Hash, String]
|
163
161
|
def api_request(body)
|
164
|
-
_request
|
162
|
+
_request body
|
165
163
|
end
|
166
164
|
end
|
167
165
|
end
|
data/lib/zabbixapi/version.rb
CHANGED
data/lib/zabbixapi.rb
CHANGED
@@ -7,7 +7,6 @@ require 'zabbixapi/basic/basic_init'
|
|
7
7
|
require 'zabbixapi/basic/basic_logic'
|
8
8
|
|
9
9
|
require 'zabbixapi/classes/actions'
|
10
|
-
require 'zabbixapi/classes/applications'
|
11
10
|
require 'zabbixapi/classes/configurations'
|
12
11
|
require 'zabbixapi/classes/errors'
|
13
12
|
require 'zabbixapi/classes/events'
|
@@ -77,11 +76,6 @@ class ZabbixApi
|
|
77
76
|
@actions ||= Actions.new(@client)
|
78
77
|
end
|
79
78
|
|
80
|
-
# @return [ZabbixApi::Applications]
|
81
|
-
def applications
|
82
|
-
@applications ||= Applications.new(@client)
|
83
|
-
end
|
84
|
-
|
85
79
|
# @return [ZabbixApi::Configurations]
|
86
80
|
def configurations
|
87
81
|
@configurations ||= Configurations.new(@client)
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zabbixapi_mgx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.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: 2025-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/zabbixapi/basic/basic_init.rb
|
71
71
|
- lib/zabbixapi/basic/basic_logic.rb
|
72
72
|
- lib/zabbixapi/classes/actions.rb
|
73
|
-
- lib/zabbixapi/classes/applications.rb
|
74
73
|
- lib/zabbixapi/classes/configurations.rb
|
75
74
|
- lib/zabbixapi/classes/drules.rb
|
76
75
|
- lib/zabbixapi/classes/errors.rb
|
@@ -102,7 +101,7 @@ homepage: https://github.com/express42/zabbixapi
|
|
102
101
|
licenses:
|
103
102
|
- MIT
|
104
103
|
metadata: {}
|
105
|
-
post_install_message:
|
104
|
+
post_install_message:
|
106
105
|
rdoc_options: []
|
107
106
|
require_paths:
|
108
107
|
- lib
|
@@ -113,12 +112,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
112
|
version: 2.0.0
|
114
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
114
|
requirements:
|
116
|
-
- - "
|
115
|
+
- - ">="
|
117
116
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
117
|
+
version: '0'
|
119
118
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
121
|
-
signing_key:
|
119
|
+
rubygems_version: 3.4.20
|
120
|
+
signing_key:
|
122
121
|
specification_version: 4
|
123
122
|
summary: Simple and lightweight ruby module for working with the Zabbix API
|
124
123
|
test_files: []
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class ZabbixApi
|
2
|
-
class Applications < Basic
|
3
|
-
# The method name used for interacting with Applications via Zabbix API
|
4
|
-
#
|
5
|
-
# @return [String]
|
6
|
-
def method_name
|
7
|
-
'application'
|
8
|
-
end
|
9
|
-
|
10
|
-
# The id field name used for identifying specific Application objects via Zabbix API
|
11
|
-
#
|
12
|
-
# @return [String]
|
13
|
-
def identify
|
14
|
-
'name'
|
15
|
-
end
|
16
|
-
|
17
|
-
# Get or Create Application object using Zabbix API
|
18
|
-
#
|
19
|
-
# @param data [Hash] Needs to include name and hostid to properly identify Applications via Zabbix API
|
20
|
-
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
21
|
-
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
22
|
-
# @return [Integer] Zabbix object id
|
23
|
-
def get_or_create(data)
|
24
|
-
log "[DEBUG] Call get_or_create with parameters: #{data.inspect}"
|
25
|
-
|
26
|
-
unless (id = get_id(name: data[:name], hostid: data[:hostid]))
|
27
|
-
id = create(data)
|
28
|
-
end
|
29
|
-
id
|
30
|
-
end
|
31
|
-
|
32
|
-
# Create or update Application object using Zabbix API
|
33
|
-
#
|
34
|
-
# @param data [Hash] Needs to include name and hostid to properly identify Applications via Zabbix API
|
35
|
-
# @raise [ApiError] Error returned when there is a problem with the Zabbix API call.
|
36
|
-
# @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK.
|
37
|
-
# @return [Integer] Zabbix object id
|
38
|
-
def create_or_update(data)
|
39
|
-
applicationid = get_id(name: data[:name], hostid: data[:hostid])
|
40
|
-
applicationid ? update(data.merge(applicationid: applicationid)) : create(data)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|