zabbixapi 0.5.0b4 → 0.5.0b5
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.
- data/lib/zabbixapi/hostgroups.rb +10 -0
- data/lib/zabbixapi/screens.rb +6 -2
- data/lib/zabbixapi/version.rb +1 -1
- data/spec/localhost.rb +4 -0
- metadata +3 -3
data/lib/zabbixapi/hostgroups.rb
CHANGED
@@ -23,6 +23,16 @@ class ZabbixApi
|
|
23
23
|
delete(data)
|
24
24
|
end
|
25
25
|
|
26
|
+
def create_or_update(data)
|
27
|
+
userid = get_id(:name => data[:name])
|
28
|
+
userid ? update(data.merge(:groupid => userid)) : create(data)
|
29
|
+
end
|
30
|
+
|
31
|
+
def update(data)
|
32
|
+
result = @client.api_request(:method => "hostgroup.update", :params => data)
|
33
|
+
result ? result['groupids'][0].to_i : nil
|
34
|
+
end
|
35
|
+
|
26
36
|
def get_or_create(data)
|
27
37
|
unless hostgroupid = get_id(data)
|
28
38
|
hostgroupid = update(data)
|
data/lib/zabbixapi/screens.rb
CHANGED
@@ -94,7 +94,7 @@ class ZabbixApi
|
|
94
94
|
# Create screen all graphs for host
|
95
95
|
#
|
96
96
|
# * *Args* :
|
97
|
-
# - +data+ -> Hash with :host=> "hostname", :graphsid => [], [:hsize, :vsize]
|
97
|
+
# - +data+ -> Hash with :host=> "hostname", :graphsid => [], [:hsize, :vsize, :valign, :halign]
|
98
98
|
# * *Returns* :
|
99
99
|
# - Nil or Integer
|
100
100
|
def get_or_create_for_host(data)
|
@@ -102,6 +102,8 @@ class ZabbixApi
|
|
102
102
|
graphids = data[:graphids]
|
103
103
|
screenitems = []
|
104
104
|
hsize = data[:hsize] || 3
|
105
|
+
valign = data[:valign] || 2
|
106
|
+
halign = data[:halign] || 2
|
105
107
|
vsize = data[:vsize] || ((graphids.size/hsize) + 1).to_i
|
106
108
|
screenid = get_id(:name => screen_name)
|
107
109
|
unless screenid
|
@@ -111,7 +113,9 @@ class ZabbixApi
|
|
111
113
|
:resourcetype => 0,
|
112
114
|
:resourceid => graphid,
|
113
115
|
:x => (index % hsize).to_i,
|
114
|
-
:y => (index % graphids.size/hsize).to_i
|
116
|
+
:y => (index % graphids.size/hsize).to_i,
|
117
|
+
:valign =>valign,
|
118
|
+
:halign =>halign
|
115
119
|
}
|
116
120
|
end
|
117
121
|
screenid = create(
|
data/lib/zabbixapi/version.rb
CHANGED
data/spec/localhost.rb
CHANGED
@@ -51,6 +51,10 @@ describe ZabbixApi, "test_api" do
|
|
51
51
|
zbx.hostgroups.get_or_create(:name => hostgroup).should be_kind_of(Integer)
|
52
52
|
end
|
53
53
|
|
54
|
+
it "HOSTGROUP: Create or update" do
|
55
|
+
zbx.hostgroups.create_or_update(:name => hostgroup).should be_kind_of(Integer)
|
56
|
+
end
|
57
|
+
|
54
58
|
it "HOSTGROUP: Get all" do
|
55
59
|
zbx.hostgroups.all.should be_kind_of(Hash)
|
56
60
|
end
|
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.5.
|
4
|
+
version: 0.5.0b5
|
5
5
|
prerelease: 5
|
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-
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allows you to work with zabbix api from ruby.
|
15
15
|
email:
|
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
segments:
|
61
61
|
- 0
|
62
|
-
hash:
|
62
|
+
hash: -1736011782781099386
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|