zabbixapi 0.1.6.1 → 0.1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/zabbixapi/group.rb +1 -1
- data/lib/zabbixapi/host.rb +1 -1
- data/lib/zabbixapi/mediatype.rb +52 -0
- data/lib/zabbixapi.rb +1 -0
- data/spec/item.rb +22 -4
- data/zabbixapi.gemspec +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
data/lib/zabbixapi/group.rb
CHANGED
data/lib/zabbixapi/host.rb
CHANGED
@@ -30,7 +30,7 @@ module Zabbix
|
|
30
30
|
'ipmi_username' => '',
|
31
31
|
'ipmi_password' => ''
|
32
32
|
}
|
33
|
-
host_options['groups'].nil? || host_options['groups'].map! { |group_id| {'groupid' =>
|
33
|
+
host_options['groups'].nil? || host_options['groups'].map! { |group_id| {'groupid' => group_id} }
|
34
34
|
host = merge_opt(host_default, host_options)
|
35
35
|
message = {
|
36
36
|
'method' => 'host.create',
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Zabbix
|
2
|
+
class ZabbixApi
|
3
|
+
|
4
|
+
def get_mediatype_id(mediatype)
|
5
|
+
message = {
|
6
|
+
'method' => 'mediatype.get',
|
7
|
+
'params' => {
|
8
|
+
'search' => {
|
9
|
+
'description' => mediatype
|
10
|
+
},
|
11
|
+
'output' => 'extend',
|
12
|
+
}
|
13
|
+
}
|
14
|
+
response = send_request(message)
|
15
|
+
response.empty? ? nil : response[0]['mediatypeid'].to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_mediatype(mediatype_options)
|
19
|
+
mediatype_default = {
|
20
|
+
'type' => '0',
|
21
|
+
'description' => '',
|
22
|
+
'smtp_server' => '',
|
23
|
+
'smtp_helo' => '',
|
24
|
+
'smtp_email' => '',
|
25
|
+
'exec_path' => '',
|
26
|
+
'gsm_modem' => '',
|
27
|
+
'username' => '',
|
28
|
+
'passwd' => ''
|
29
|
+
}
|
30
|
+
mediatype = merge_opt(mediatype_default, mediatype_options)
|
31
|
+
message = {
|
32
|
+
'method' => 'mediatype.create',
|
33
|
+
'params' => mediatype
|
34
|
+
}
|
35
|
+
response = send_request(message)
|
36
|
+
response.empty? ? nil : response['mediatypeids'][0].to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_mediatype(mediatype)
|
40
|
+
mediatype_id = get_mediatype_id(mediatype)
|
41
|
+
message = {
|
42
|
+
'method' => 'mediatype.delete',
|
43
|
+
'params' =>
|
44
|
+
[mediatype_id]
|
45
|
+
}
|
46
|
+
response = send_request(message)
|
47
|
+
response ? true : false
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/lib/zabbixapi.rb
CHANGED
data/spec/item.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'zabbixapi'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
-
#require 'webmock/rspec'
|
5
|
-
#include WebMock::API
|
6
|
-
|
7
4
|
# settings
|
8
5
|
api_url = 'http://zabbix.local/api_jsonrpc.php'
|
9
6
|
api_login = 'Admin'
|
@@ -44,7 +41,7 @@ end
|
|
44
41
|
# 04. Delete group
|
45
42
|
describe Zabbix::ZabbixApi, "delete_group" do
|
46
43
|
it "Delete some group" do
|
47
|
-
result = zbx.delete_group('some_group')
|
44
|
+
result = zbx.delete_group(zbx.get_group_id'some_group')
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
@@ -54,3 +51,24 @@ describe Zabbix::ZabbixApi, "delete_host" do
|
|
54
51
|
result = zbx.delete_host('my.example.com')
|
55
52
|
end
|
56
53
|
end
|
54
|
+
|
55
|
+
# 06. Mediatype create
|
56
|
+
mediatype_options = {
|
57
|
+
'type' => '0',
|
58
|
+
'description' => 'example_mediatype',
|
59
|
+
'smtp_server' => 'test.company.com',
|
60
|
+
'smtp_helo' => 'test.company.com',
|
61
|
+
'smtp_email' => 'test@test.company.com',
|
62
|
+
}
|
63
|
+
describe Zabbix::ZabbixApi, "create_mediatype" do
|
64
|
+
it "Create mediatype" do
|
65
|
+
result = zbx.add_mediatype(mediatype_options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# 07. Mediatype delete
|
70
|
+
describe Zabbix::ZabbixApi, "create_mediatype" do
|
71
|
+
it "Delete mediatype" do
|
72
|
+
result = zbx.delete_mediatype('example_mediatype')
|
73
|
+
end
|
74
|
+
end
|
data/zabbixapi.gemspec
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: 0.1.6.
|
4
|
+
version: 0.1.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby module for work with zabbix api v1.8.
|
15
15
|
email: vadv.mkn@gmail.com
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/zabbixapi/group.rb
|
26
26
|
- lib/zabbixapi/host.rb
|
27
27
|
- lib/zabbixapi/item.rb
|
28
|
+
- lib/zabbixapi/mediatype.rb
|
28
29
|
- lib/zabbixapi/screen.rb
|
29
30
|
- lib/zabbixapi/template.rb
|
30
31
|
- lib/zabbixapi/trigger.rb
|
@@ -64,4 +65,3 @@ signing_key:
|
|
64
65
|
specification_version: 3
|
65
66
|
summary: Ruby module for work with zabbix api.
|
66
67
|
test_files: []
|
67
|
-
has_rdoc: true
|