zabbixapi 0.5.0 → 0.5.1a
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +2 -0
- data/README.md +8 -0
- data/lib/zabbixapi.rb +6 -12
- data/lib/zabbixapi/basic/basic_alias.rb +17 -0
- data/lib/zabbixapi/basic/basic_func.rb +41 -0
- data/lib/zabbixapi/basic/basic_init.rb +33 -0
- data/lib/zabbixapi/basic/basic_logic.rb +70 -0
- data/lib/zabbixapi/{applications.rb → classes/applications.rb} +0 -0
- data/lib/zabbixapi/{errors.rb → classes/errors.rb} +0 -0
- data/lib/zabbixapi/classes/graphs.rb +40 -0
- data/lib/zabbixapi/classes/hostgroups.rb +26 -0
- data/lib/zabbixapi/classes/hosts.rb +58 -0
- data/lib/zabbixapi/classes/items.rb +54 -0
- data/lib/zabbixapi/classes/mediatypes.rb +31 -0
- data/lib/zabbixapi/classes/screens.rb +68 -0
- data/lib/zabbixapi/{server.rb → classes/server.rb} +0 -0
- data/lib/zabbixapi/{templates.rb → classes/templates.rb} +8 -70
- data/lib/zabbixapi/classes/triggers.rb +17 -0
- data/lib/zabbixapi/{usergroups.rb → classes/usergroups.rb} +11 -54
- data/lib/zabbixapi/classes/users.rb +32 -0
- data/lib/zabbixapi/client.rb +4 -2
- data/lib/zabbixapi/version.rb +1 -1
- data/spec/localhost.rb +1 -1
- metadata +23 -19
- data/lib/zabbixapi/graphs.rb +0 -83
- data/lib/zabbixapi/hostgroups.rb +0 -72
- data/lib/zabbixapi/hosts.rb +0 -86
- data/lib/zabbixapi/items.rb +0 -87
- data/lib/zabbixapi/mediatypes.rb +0 -109
- data/lib/zabbixapi/screens.rb +0 -132
- data/lib/zabbixapi/triggers.rb +0 -48
- data/lib/zabbixapi/users.rb +0 -67
data/lib/zabbixapi/triggers.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
class ZabbixApi
|
2
|
-
class Triggers
|
3
|
-
|
4
|
-
def initialize(client)
|
5
|
-
@client = client
|
6
|
-
end
|
7
|
-
|
8
|
-
def create(data)
|
9
|
-
result = @client.api_request(:method => "trigger.create", :params => [data])
|
10
|
-
result.empty? ? nil : result['triggerids'][0].to_i
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(data)
|
14
|
-
create(data)
|
15
|
-
end
|
16
|
-
|
17
|
-
def delete(data)
|
18
|
-
result = @client.api_request(:method => "trigger.delete", :params => [data])
|
19
|
-
result.empty? ? nil : result['triggerids'][0].to_i
|
20
|
-
end
|
21
|
-
|
22
|
-
def destroy(data)
|
23
|
-
delete(data)
|
24
|
-
end
|
25
|
-
|
26
|
-
def update(data)
|
27
|
-
result = @client.api_request(:method => "trigger.update", :params => data)
|
28
|
-
result.empty? ? nil : result['triggerids'][0].to_i
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_or_update(data)
|
32
|
-
triggerid = get_id(:description => data[:description], :templateid => data[:templateid])
|
33
|
-
triggerid ? update(data.merge(:triggerid => triggerid)) : create(data)
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_full_data(data)
|
37
|
-
@client.api_request(:method => "trigger.get", :params => {:filter => data, :output => "extend"})
|
38
|
-
end
|
39
|
-
|
40
|
-
def get_id(data)
|
41
|
-
result = get_full_data(data)
|
42
|
-
triggerid = nil
|
43
|
-
result.each { |template| triggerid = template['triggerid'].to_i if template['name'] == data[:name] }
|
44
|
-
triggerid
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
data/lib/zabbixapi/users.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
class ZabbixApi
|
2
|
-
class Users
|
3
|
-
|
4
|
-
def initialize(client)
|
5
|
-
@client = client
|
6
|
-
end
|
7
|
-
|
8
|
-
def create(data)
|
9
|
-
result = @client.api_request(:method => "user.create", :params => data)
|
10
|
-
result ? result['userids'][0].to_i : nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(data)
|
14
|
-
create(data)
|
15
|
-
end
|
16
|
-
|
17
|
-
def delete(data)
|
18
|
-
result = @client.api_request(:method => "user.delete", :params => [:userid => data])
|
19
|
-
result ? result['userids'][0].to_i : nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def get_full_data(data)
|
23
|
-
@client.api_request(
|
24
|
-
:method => "user.get",
|
25
|
-
:params => {
|
26
|
-
:filter => {
|
27
|
-
:name => data[:name]
|
28
|
-
},
|
29
|
-
:output => "extend"
|
30
|
-
}
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
def get(data)
|
35
|
-
get_full_data(data)
|
36
|
-
end
|
37
|
-
|
38
|
-
def create_or_update(data)
|
39
|
-
userid = get_id(:name => data[:name])
|
40
|
-
userid ? update(data.merge(:userid => userid)) : create(data)
|
41
|
-
end
|
42
|
-
|
43
|
-
def add_medias(data)
|
44
|
-
result = @client.api_request(
|
45
|
-
:method => "user.addMedia",
|
46
|
-
:params => {
|
47
|
-
:users => data[:userids].map { |t| {:userid => t} },
|
48
|
-
:medias => data[:media]
|
49
|
-
}
|
50
|
-
)
|
51
|
-
result ? result['userids'][0].to_i : nil
|
52
|
-
end
|
53
|
-
|
54
|
-
def get_id(data)
|
55
|
-
result = get_full_data(data)
|
56
|
-
userid = nil
|
57
|
-
result.each { |usr| userid = usr['userid'].to_i if usr['name'] == data[:name] }
|
58
|
-
userid
|
59
|
-
end
|
60
|
-
|
61
|
-
def update(data)
|
62
|
-
result = @client.api_request(:method => "user.update", :params => data)
|
63
|
-
result ? result['userids'][0].to_i : nil
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|