zabbixapi 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/README.md +123 -0
- data/Rakefile +1 -0
- data/lib/zabbixapi/applications.rb +37 -0
- data/lib/zabbixapi/client.rb +65 -0
- data/lib/zabbixapi/errors.rb +12 -0
- data/lib/zabbixapi/graphs.rb +47 -0
- data/lib/zabbixapi/hostgroups.rb +42 -0
- data/lib/zabbixapi/hosts.rb +80 -0
- data/lib/zabbixapi/items.rb +81 -0
- data/lib/zabbixapi/server.rb +12 -0
- data/lib/zabbixapi/templates.rb +78 -0
- data/lib/zabbixapi/triggers.rb +42 -0
- data/lib/zabbixapi/users.rb +59 -0
- data/lib/zabbixapi/version.rb +3 -0
- data/lib/zabbixapi.rb +51 -12
- data/spec/localhost.rb +227 -75
- data/spec/run.rb +265 -0
- data/zabbixapi.gemspec +15 -15
- metadata +35 -57
- data/README.rdoc +0 -65
- data/examples/basic_auth.rb +0 -30
- data/examples/config.yml +0 -4
- data/examples/maintenance-example.rb +0 -55
- data/examples/populate_new_zabbix.sh +0 -84
- data/examples/zabbix_availability +0 -73
- data/examples/zabbix_clear_default +0 -36
- data/examples/zabbix_cpufan-sersor +0 -114
- data/examples/zabbix_cputemp-sersor +0 -112
- data/examples/zabbix_disk_io +0 -152
- data/examples/zabbix_filesystem +0 -249
- data/examples/zabbix_group +0 -25
- data/examples/zabbix_hlsp +0 -100
- data/examples/zabbix_host +0 -37
- data/examples/zabbix_iops +0 -131
- data/examples/zabbix_ipmi-cpufan-sersor +0 -101
- data/examples/zabbix_ipmi_systemp +0 -110
- data/examples/zabbix_la +0 -136
- data/examples/zabbix_mailer +0 -125
- data/examples/zabbix_mdadm +0 -72
- data/examples/zabbix_megaraid +0 -71
- data/examples/zabbix_memory +0 -290
- data/examples/zabbix_named +0 -71
- data/examples/zabbix_net +0 -218
- data/examples/zabbix_nginx +0 -167
- data/examples/zabbix_nginx_500 +0 -112
- data/examples/zabbix_ntp +0 -71
- data/examples/zabbix_nv-gputemp +0 -111
- data/examples/zabbix_pgsql +0 -125
- data/examples/zabbix_server_process +0 -71
- data/examples/zabbix_smart_blade +0 -94
- data/examples/zabbix_ssh +0 -71
- data/examples/zabbix_varnish +0 -71
- data/lib/zabbixapi/application.rb +0 -40
- data/lib/zabbixapi/base.rb +0 -158
- data/lib/zabbixapi/graph.rb +0 -59
- data/lib/zabbixapi/group.rb +0 -66
- data/lib/zabbixapi/host.rb +0 -70
- data/lib/zabbixapi/item.rb +0 -130
- data/lib/zabbixapi/maintenance.rb +0 -78
- data/lib/zabbixapi/mediatype.rb +0 -53
- data/lib/zabbixapi/screen.rb +0 -119
- data/lib/zabbixapi/template.rb +0 -128
- data/lib/zabbixapi/trigger.rb +0 -71
- data/lib/zabbixapi/user.rb +0 -0
- data/lib/zabbixapi/usermacro.rb +0 -46
data/examples/zabbix_memory
DELETED
@@ -1,290 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'yaml'
|
5
|
-
require 'getopt/std'
|
6
|
-
require 'zabbixapi'
|
7
|
-
|
8
|
-
opt = Getopt::Std.getopts("g:E:")
|
9
|
-
|
10
|
-
group_name = opt["g"]
|
11
|
-
zabbix_env = opt["E"]
|
12
|
-
|
13
|
-
template_name = "TMPL_Memory"
|
14
|
-
|
15
|
-
# read config
|
16
|
-
config = YAML::load(open('./config.yml'))
|
17
|
-
|
18
|
-
api_url = config[zabbix_env]["api_url"]
|
19
|
-
api_login = config[zabbix_env]["api_login"]
|
20
|
-
api_password = config[zabbix_env]["api_password"]
|
21
|
-
|
22
|
-
# Esablish new connection
|
23
|
-
zbx = Zabbix::ZabbixApi.new(api_url, api_login, api_password)
|
24
|
-
|
25
|
-
# Create new template
|
26
|
-
p " * Creating template #{template_name}."
|
27
|
-
g_id = zbx.add_or_get_group(group_name)
|
28
|
-
|
29
|
-
options = {
|
30
|
-
'groups' => [ g_id.to_i ],
|
31
|
-
'host' => template_name
|
32
|
-
}
|
33
|
-
|
34
|
-
t_id = zbx.add_or_get_template(options)
|
35
|
-
|
36
|
-
# Create application #{app_name}
|
37
|
-
app_name = "Memory"
|
38
|
-
p " ** Create application #{app_name}."
|
39
|
-
application = {
|
40
|
-
'hostid' => t_id.to_i,
|
41
|
-
'name' => app_name
|
42
|
-
}
|
43
|
-
a_id = zbx.add_or_get_application(t_id, application)
|
44
|
-
|
45
|
-
# 'Buffers memory'
|
46
|
-
options = {
|
47
|
-
'description' => "Buffers memory",
|
48
|
-
'key_' => "vm.memory.size[buffers]",
|
49
|
-
'hostid' => t_id.to_i,
|
50
|
-
'applications' => [ a_id.to_i ],
|
51
|
-
'units' => 'B',
|
52
|
-
'history' => 7,
|
53
|
-
'trends' => 30,
|
54
|
-
'value_type' => 0
|
55
|
-
}
|
56
|
-
p " ** Add 'Buffers memory' to #{template_name}."
|
57
|
-
|
58
|
-
buffers_in_b_item_id = zbx.add_or_get_item(t_id, options)
|
59
|
-
|
60
|
-
# 'Cached memory'
|
61
|
-
options = {
|
62
|
-
'description' => "Cached memory",
|
63
|
-
'key_' => "vm.memory.size[cached]",
|
64
|
-
'hostid' => t_id.to_i,
|
65
|
-
'applications' => [ a_id.to_i ],
|
66
|
-
'units' => 'B',
|
67
|
-
'history' => 7,
|
68
|
-
'trends' => 30,
|
69
|
-
'value_type' => 0
|
70
|
-
}
|
71
|
-
p " ** Add 'Cached memory' to #{template_name}."
|
72
|
-
|
73
|
-
cached_in_b_item_id = zbx.add_or_get_item(t_id, options)
|
74
|
-
|
75
|
-
# 'Total memory'
|
76
|
-
options = {
|
77
|
-
'description' => "Total memory",
|
78
|
-
'key_' => "vm.memory.size[total]",
|
79
|
-
'hostid' => t_id.to_i,
|
80
|
-
'applications' => [ a_id.to_i ],
|
81
|
-
'delay' => '300',
|
82
|
-
'units' => 'B',
|
83
|
-
'history' => 7,
|
84
|
-
'trends' => 30,
|
85
|
-
'value_type' => 0
|
86
|
-
}
|
87
|
-
p " ** Add 'Total memory' to #{template_name}."
|
88
|
-
|
89
|
-
total_in_b_item_id = zbx.add_or_get_item(t_id, options)
|
90
|
-
|
91
|
-
# 'Used memory with buffers and cache'
|
92
|
-
options = {
|
93
|
-
'description' => "Used memory (without cache and buffers)",
|
94
|
-
'key_' => "vm.memory.size[used]",
|
95
|
-
'params' => "last(\"vm.memory.size[total]\") - last(\"vm.memory.size[free]\") - last(\"vm.memory.size[cached]\") - last(\"vm.memory.size[buffers]\")",
|
96
|
-
'hostid' => t_id.to_i,
|
97
|
-
'type' => '15', # calculated
|
98
|
-
'applications' => [ a_id.to_i ],
|
99
|
-
'units' => 'B',
|
100
|
-
'history' => 7,
|
101
|
-
'trends' => 30,
|
102
|
-
'value_type' => 0
|
103
|
-
}
|
104
|
-
p " ** Add 'Used memory' to #{template_name}."
|
105
|
-
|
106
|
-
used_in_b_item_id = zbx.add_or_get_item(t_id, options)
|
107
|
-
|
108
|
-
# 'Free memory'
|
109
|
-
options = {
|
110
|
-
'description' => "Free memory",
|
111
|
-
'key_' => "vm.memory.size[free]",
|
112
|
-
'hostid' => t_id.to_i,
|
113
|
-
'applications' => [ a_id.to_i ],
|
114
|
-
'units' => 'B',
|
115
|
-
'history' => 7,
|
116
|
-
'trends' => 30,
|
117
|
-
'value_type' => 0
|
118
|
-
}
|
119
|
-
p " ** Add 'Free memory' to #{template_name}."
|
120
|
-
i_id = zbx.add_or_get_item(t_id, options)
|
121
|
-
|
122
|
-
# 'Free memory in %'
|
123
|
-
options = {
|
124
|
-
'description' => "Free memory in %",
|
125
|
-
'key_' => "vm.memory.size[pfree]",
|
126
|
-
'hostid' => t_id.to_i,
|
127
|
-
'applications' => [ a_id.to_i ],
|
128
|
-
'units' => '%',
|
129
|
-
'history' => 7,
|
130
|
-
'trends' => 30,
|
131
|
-
'value_type' => 0
|
132
|
-
}
|
133
|
-
p " ** Add 'Free memory in %' to #{template_name}."
|
134
|
-
i_id = zbx.add_or_get_item(t_id, options)
|
135
|
-
|
136
|
-
# 'Free memory with buffers and cache'
|
137
|
-
options = {
|
138
|
-
'description' => "Free memory with buffers and cache",
|
139
|
-
'key_' => "vm.memory.size[free_with_buffer_cache]",
|
140
|
-
'params' => "last(\"vm.memory.size[free]\") + last(\"vm.memory.size[cached]\") + last(\"vm.memory.size[buffers]\")",
|
141
|
-
'hostid' => t_id.to_i,
|
142
|
-
'type' => '15', #calculated
|
143
|
-
'applications' => [ a_id.to_i ],
|
144
|
-
'units' => 'B',
|
145
|
-
'history' => 7,
|
146
|
-
'trends' => 30,
|
147
|
-
'value_type' => 0
|
148
|
-
}
|
149
|
-
p " ** Add 'Free memory with buffers and cache' to #{template_name}."
|
150
|
-
|
151
|
-
i_id = zbx.add_or_get_item(t_id, options)
|
152
|
-
|
153
|
-
# 'Swap in all'
|
154
|
-
options = {
|
155
|
-
'description' => "Swap in all",
|
156
|
-
'key_' => "system.swap.in[]",
|
157
|
-
'hostid' => t_id.to_i,
|
158
|
-
'applications' => [ a_id.to_i ],
|
159
|
-
'multiplier' => 1,
|
160
|
-
'formula' => 512,
|
161
|
-
'units' => 'B',
|
162
|
-
'history' => 7,
|
163
|
-
'trends' => 30,
|
164
|
-
'value_type' => 0
|
165
|
-
}
|
166
|
-
p " ** Add 'Swap in all' to #{template_name}."
|
167
|
-
|
168
|
-
i_id = zbx.add_or_get_item(t_id, options)
|
169
|
-
|
170
|
-
# 'Swap out all'
|
171
|
-
options = {
|
172
|
-
'description' => "Swap out all",
|
173
|
-
'key_' => "system.swap.out[]",
|
174
|
-
'hostid' => t_id.to_i,
|
175
|
-
'applications' => [ a_id.to_i ],
|
176
|
-
'multiplier' => 1,
|
177
|
-
'formula' => 512,
|
178
|
-
'units' => 'B',
|
179
|
-
'history' => 7,
|
180
|
-
'trends' => 30,
|
181
|
-
'value_type' => 0
|
182
|
-
}
|
183
|
-
p " ** Add 'Swap out all' to #{template_name}."
|
184
|
-
|
185
|
-
i_id = zbx.add_or_get_item(t_id, options)
|
186
|
-
|
187
|
-
# TRIGGERS
|
188
|
-
options = {
|
189
|
-
'description' => "Free memory without cache, %",
|
190
|
-
'expression' => "{#{template_name}:vm.memory.size[pfree].last(0)}<15",
|
191
|
-
'priority' => 2, # warning
|
192
|
-
'templateid' => 0,
|
193
|
-
'comments' => "Free memory without cache, % warning trigger",
|
194
|
-
'type' => 0,
|
195
|
-
'status' => '0'
|
196
|
-
}
|
197
|
-
|
198
|
-
p " ** Add 'Free memory without cache, %'"
|
199
|
-
tr_id = zbx.add_or_get_trigger(t_id, options)
|
200
|
-
|
201
|
-
options = {
|
202
|
-
'description' => "Free memory without cache, %",
|
203
|
-
'expression' => "{#{template_name}:vm.memory.size[pfree].last(0)}<10",
|
204
|
-
'priority' => 5, # disaster
|
205
|
-
'templateid' => 0,
|
206
|
-
'commenty' => "Free memory without cache, %",
|
207
|
-
'type' => 0,
|
208
|
-
'status' => '0'
|
209
|
-
}
|
210
|
-
|
211
|
-
p " ** Add 'Free memory without cache, % disaster trigger'"
|
212
|
-
tr_id = zbx.add_or_get_trigger(t_id, options)
|
213
|
-
|
214
|
-
options = {
|
215
|
-
'description' => "Swap usage in, B",
|
216
|
-
'expression' => "{#{template_name}:system.swap.in[].last(0)}#0",
|
217
|
-
'priority' => 2, # warning
|
218
|
-
'templateid' => 0,
|
219
|
-
'comments' => "Swap usage in, B",
|
220
|
-
'type' => 0,
|
221
|
-
'status' => '0'
|
222
|
-
}
|
223
|
-
|
224
|
-
p " ** Add 'Swap usage in, B warning trigger'"
|
225
|
-
tr_id = zbx.add_or_get_trigger(t_id, options)
|
226
|
-
|
227
|
-
options = {
|
228
|
-
'description' => "Swap usage out, B",
|
229
|
-
'expression' => "{#{template_name}:system.swap.out[].last(0)}#0",
|
230
|
-
'priority' => 2, # warning
|
231
|
-
'templateid' => 0,
|
232
|
-
'comments' => "Swap usage out, B",
|
233
|
-
'type' => 0,
|
234
|
-
'status' => '0'
|
235
|
-
}
|
236
|
-
|
237
|
-
p " ** Add 'Swap usage out, B warning trigger'"
|
238
|
-
tr_id = zbx.add_or_get_trigger(t_id, options)
|
239
|
-
|
240
|
-
options = {
|
241
|
-
'gitems' => [
|
242
|
-
{
|
243
|
-
"itemid" => total_in_b_item_id,
|
244
|
-
"drawtype" => "0",
|
245
|
-
"sortorder" => "0",
|
246
|
-
"color" => "AA0000",
|
247
|
-
"yaxisside" => "0",
|
248
|
-
"calc_fnc" => "2",
|
249
|
-
"type" => "0",
|
250
|
-
"periods_cnt" => "5"
|
251
|
-
},
|
252
|
-
{
|
253
|
-
"itemid" => used_in_b_item_id,
|
254
|
-
"drawtype" => "0",
|
255
|
-
"sortorder" => "0",
|
256
|
-
"color" => "009900",
|
257
|
-
"yaxisside" => "0",
|
258
|
-
"calc_fnc" => "2",
|
259
|
-
"type" => "0",
|
260
|
-
"periods_cnt" => "5"
|
261
|
-
},
|
262
|
-
{
|
263
|
-
"itemid" => cached_in_b_item_id,
|
264
|
-
"drawtype" => "0",
|
265
|
-
"sortorder" => "0",
|
266
|
-
"color" => "0000AA",
|
267
|
-
"yaxisside" => "0",
|
268
|
-
"calc_fnc" => "2",
|
269
|
-
"type" => "0",
|
270
|
-
"periods_cnt" => "5"
|
271
|
-
},
|
272
|
-
{
|
273
|
-
"itemid" => buffers_in_b_item_id,
|
274
|
-
"drawtype" => "0",
|
275
|
-
"sortorder" => "0",
|
276
|
-
"color" => "AA00AA",
|
277
|
-
"yaxisside" => "0",
|
278
|
-
"calc_fnc" => "2",
|
279
|
-
"type" => "0",
|
280
|
-
"periods_cnt" => "5"
|
281
|
-
}
|
282
|
-
],
|
283
|
-
"show_triggers" => "1",
|
284
|
-
"name" => "Memory usage",
|
285
|
-
"width" => "900",
|
286
|
-
"height" => "200",
|
287
|
-
"templateid" => "0"
|
288
|
-
}
|
289
|
-
|
290
|
-
g_id = zbx.add_or_get_graph(t_id, options)
|
data/examples/zabbix_named
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'getopt/std'
|
5
|
-
require 'yaml'
|
6
|
-
require 'zabbixapi'
|
7
|
-
|
8
|
-
opt = Getopt::Std.getopts("g:i:E:")
|
9
|
-
|
10
|
-
group_name = opt["g"]
|
11
|
-
zabbix_env = opt["E"]
|
12
|
-
|
13
|
-
template_name = "TMPL_named"
|
14
|
-
app_name = "named"
|
15
|
-
|
16
|
-
# read config
|
17
|
-
config = YAML::load(open('./config.yml'))
|
18
|
-
|
19
|
-
api_url = config[zabbix_env]["api_url"]
|
20
|
-
api_login = config[zabbix_env]["api_login"]
|
21
|
-
api_password = config[zabbix_env]["api_password"]
|
22
|
-
|
23
|
-
# Esablish new connection
|
24
|
-
zbx = Zabbix::ZabbixApi.new(api_url, api_login, api_password)
|
25
|
-
|
26
|
-
# Create new template
|
27
|
-
p " * Creating template #{template_name}."
|
28
|
-
g_id = zbx.add_or_get_group(group_name)
|
29
|
-
|
30
|
-
options = {
|
31
|
-
'groups' => [ g_id.to_i ],
|
32
|
-
'host' => template_name
|
33
|
-
}
|
34
|
-
|
35
|
-
t_id = zbx.add_or_get_template(options)
|
36
|
-
|
37
|
-
# Create application #{app_name}
|
38
|
-
p " ** Create application #{app_name}."
|
39
|
-
application = {
|
40
|
-
'hostid' => t_id.to_i,
|
41
|
-
'name' => app_name
|
42
|
-
}
|
43
|
-
a_id = zbx.add_or_get_application(t_id, application)
|
44
|
-
|
45
|
-
# 'named process exists'
|
46
|
-
options = {
|
47
|
-
'description' => "named process exists",
|
48
|
-
'key_' => "proc.num[named]",
|
49
|
-
'hostid' => t_id.to_i,
|
50
|
-
'applications' => [ a_id.to_i ],
|
51
|
-
'history' => 7,
|
52
|
-
'trends' => 30,
|
53
|
-
'delay' => 120,
|
54
|
-
'value_type' => 0
|
55
|
-
}
|
56
|
-
p " ** Add 'named process exists' to #{template_name}."
|
57
|
-
item_id = zbx.add_or_get_item(t_id, options)
|
58
|
-
|
59
|
-
# TRIGGERS
|
60
|
-
options = {
|
61
|
-
'description' => "named process exists",
|
62
|
-
'expression' => "{#{template_name}:proc.num[named].last(0)}<1",
|
63
|
-
'priority' => 5, # disaster
|
64
|
-
'templateid' => 0,
|
65
|
-
'comments' => "named process exists (disaster)",
|
66
|
-
'type' => 0,
|
67
|
-
'status' => '0'
|
68
|
-
}
|
69
|
-
|
70
|
-
p " ** Add 'named process exists' trigger"
|
71
|
-
tr_id = zbx.add_or_get_trigger(t_id, options)
|
data/examples/zabbix_net
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'getopt/std'
|
5
|
-
require 'yaml'
|
6
|
-
require 'zabbixapi'
|
7
|
-
|
8
|
-
opt = Getopt::Std.getopts("g:i:E:")
|
9
|
-
|
10
|
-
group_name = opt["g"]
|
11
|
-
interface_name = opt["i"]
|
12
|
-
zabbix_env = opt["E"]
|
13
|
-
|
14
|
-
template_name = "TMPL_Net_#{interface_name}"
|
15
|
-
app_name = "Net_#{interface_name}"
|
16
|
-
|
17
|
-
|
18
|
-
# read config
|
19
|
-
config = YAML::load(open('./config.yml'))
|
20
|
-
|
21
|
-
api_url = config[zabbix_env]["api_url"]
|
22
|
-
api_login = config[zabbix_env]["api_login"]
|
23
|
-
api_password = config[zabbix_env]["api_password"]
|
24
|
-
|
25
|
-
# Esablish new connection
|
26
|
-
zbx = Zabbix::ZabbixApi.new(api_url, api_login, api_password)
|
27
|
-
|
28
|
-
# Create new template
|
29
|
-
p " * Creating template #{template_name}."
|
30
|
-
g_id = zbx.add_or_get_group(group_name)
|
31
|
-
|
32
|
-
options = {
|
33
|
-
'groups' => [ g_id.to_i ],
|
34
|
-
'host' => template_name
|
35
|
-
}
|
36
|
-
|
37
|
-
t_id = zbx.add_or_get_template(options)
|
38
|
-
|
39
|
-
# Create application #{app_name}
|
40
|
-
p " ** Create application #{app_name}."
|
41
|
-
application = {
|
42
|
-
'hostid' => t_id.to_i,
|
43
|
-
'name' => app_name
|
44
|
-
}
|
45
|
-
a_id = zbx.add_or_get_application(t_id, application)
|
46
|
-
|
47
|
-
# 'Net #{interface_name} incoming traffic'
|
48
|
-
options = {
|
49
|
-
'description' => "Net #{interface_name} incoming, B",
|
50
|
-
'key_' => "net.if.in[#{interface_name}, bytes]",
|
51
|
-
'hostid' => t_id.to_i,
|
52
|
-
'applications' => [ a_id.to_i ],
|
53
|
-
'history' => 7,
|
54
|
-
'trends' => 30,
|
55
|
-
'delay' => 60,
|
56
|
-
'value_type' => 3,
|
57
|
-
'units' => 'Bps',
|
58
|
-
'value_type' => '3', # Numeric (unsigned)
|
59
|
-
'delta' => 1 # Store as delta (Speed per second)
|
60
|
-
}
|
61
|
-
p " ** Add 'Net #{interface_name} incoming, B' to #{template_name}."
|
62
|
-
net_in_item_id = zbx.add_or_get_item(t_id, options)
|
63
|
-
|
64
|
-
# 'Net #{interface_name} outgoing traffic'
|
65
|
-
options = {
|
66
|
-
'description' => "Net #{interface_name} outgoing, B",
|
67
|
-
'key_' => "net.if.out[#{interface_name}, bytes]",
|
68
|
-
'hostid' => t_id.to_i,
|
69
|
-
'applications' => [ a_id.to_i ],
|
70
|
-
'history' => 7,
|
71
|
-
'trends' => 30,
|
72
|
-
'delay' => 60,
|
73
|
-
'value_type' => 3,
|
74
|
-
'units' => 'Bps',
|
75
|
-
'value_type' => '3', # Numeric (unsigned)
|
76
|
-
'delta' => 1 # Store as delta (Speed per second)
|
77
|
-
|
78
|
-
}
|
79
|
-
p " ** Add 'Net #{interface_name} outgoing, B' to #{template_name}."
|
80
|
-
net_out_item_id = zbx.add_or_get_item(t_id, options)
|
81
|
-
|
82
|
-
# 'Net #{interface_name} incoming errors'
|
83
|
-
options = {
|
84
|
-
'description' => "Net #{interface_name} incoming errors, pkts",
|
85
|
-
'key_' => "net.if.in[#{interface_name}, errors]",
|
86
|
-
'hostid' => t_id.to_i,
|
87
|
-
'applications' => [ a_id.to_i ],
|
88
|
-
'history' => 7,
|
89
|
-
'trends' => 30,
|
90
|
-
'delay' => 60,
|
91
|
-
'value_type' => 0,
|
92
|
-
'units' => 'pkts',
|
93
|
-
'value_type' => '3'
|
94
|
-
}
|
95
|
-
p " ** Add 'Net #{interface_name} incoming errors, pkts' to #{template_name}."
|
96
|
-
net_in_errs_item_id = zbx.add_or_get_item(t_id, options)
|
97
|
-
|
98
|
-
# 'Net #{interface_name} incoming errors'
|
99
|
-
options = {
|
100
|
-
'description' => "Net #{interface_name} outgoing errors, pkts",
|
101
|
-
'key_' => "net.if.out[#{interface_name}, errors]",
|
102
|
-
'hostid' => t_id.to_i,
|
103
|
-
'applications' => [ a_id.to_i ],
|
104
|
-
'history' => 7,
|
105
|
-
'trends' => 30,
|
106
|
-
'delay' => 60,
|
107
|
-
'value_type' => 0,
|
108
|
-
'units' => 'pkts',
|
109
|
-
'value_type' => '3'
|
110
|
-
}
|
111
|
-
p " ** Add 'Net #{interface_name} outgoing errors, pkts' to #{template_name}."
|
112
|
-
net_out_errs_item_id = zbx.add_or_get_item(t_id, options)
|
113
|
-
|
114
|
-
# 'Net #{interface_name} incoming dropped pkts'
|
115
|
-
options = {
|
116
|
-
'description' => "Net #{interface_name} incoming dropped, pkts",
|
117
|
-
'key_' => "net.if.in[#{interface_name}, dropped]",
|
118
|
-
'hostid' => t_id.to_i,
|
119
|
-
'applications' => [ a_id.to_i ],
|
120
|
-
'history' => 7,
|
121
|
-
'trends' => 30,
|
122
|
-
'delay' => 60,
|
123
|
-
'value_type' => 0,
|
124
|
-
'units' => 'pkts',
|
125
|
-
'value_type' => '3'
|
126
|
-
}
|
127
|
-
p " ** Add 'Net #{interface_name} incoming dropped, pkts' to #{template_name}."
|
128
|
-
net_in_drop_item_id = zbx.add_or_get_item(t_id, options)
|
129
|
-
|
130
|
-
# 'Net #{interface_name} outgoing dropped pkts'
|
131
|
-
options = {
|
132
|
-
'description' => "Net #{interface_name} outgoing dropped, pkts",
|
133
|
-
'key_' => "net.if.out[#{interface_name}, dropped]",
|
134
|
-
'hostid' => t_id.to_i,
|
135
|
-
'applications' => [ a_id.to_i ],
|
136
|
-
'history' => 7,
|
137
|
-
'trends' => 30,
|
138
|
-
'delay' => 60,
|
139
|
-
'value_type' => 0,
|
140
|
-
'units' => 'pkts',
|
141
|
-
'value_type' => '3'
|
142
|
-
}
|
143
|
-
p " ** Add 'Net #{interface_name} outgoing dropped, pkts' to #{template_name}."
|
144
|
-
net_out_drop_item_id = zbx.add_or_get_item(t_id, options)
|
145
|
-
|
146
|
-
## GRAPHS
|
147
|
-
options = {
|
148
|
-
"gitems" => [
|
149
|
-
{
|
150
|
-
"itemid" => net_in_item_id,
|
151
|
-
"drawtype" => "0",
|
152
|
-
"sortorder" => "0",
|
153
|
-
"color" => "AA0000",
|
154
|
-
"yaxisside" => "0",
|
155
|
-
"calc_fnc" => "2",
|
156
|
-
"type" => "0",
|
157
|
-
"periods_cnt" => "5"
|
158
|
-
},
|
159
|
-
{
|
160
|
-
"itemid" => net_out_item_id,
|
161
|
-
"drawtype" => "0",
|
162
|
-
"sortorder" => "0",
|
163
|
-
"color" => "009900",
|
164
|
-
"yaxisside" => "0",
|
165
|
-
"calc_fnc" => "2",
|
166
|
-
"type" => "0",
|
167
|
-
"periods_cnt" => "5"
|
168
|
-
},
|
169
|
-
{
|
170
|
-
"itemid" => net_in_errs_item_id,
|
171
|
-
"drawtype" => "0",
|
172
|
-
"sortorder" => "0",
|
173
|
-
"color" => "0000BB",
|
174
|
-
"yaxisside" => "0",
|
175
|
-
"calc_fnc" => "2",
|
176
|
-
"type" => "0",
|
177
|
-
"periods_cnt" => "5"
|
178
|
-
},
|
179
|
-
{
|
180
|
-
"itemid" => net_out_errs_item_id,
|
181
|
-
"drawtype" => "0",
|
182
|
-
"sortorder" => "0",
|
183
|
-
"color" => "888888",
|
184
|
-
"yaxisside" => "0",
|
185
|
-
"calc_fnc" => "2",
|
186
|
-
"type" => "0",
|
187
|
-
"periods_cnt" => "5"
|
188
|
-
},
|
189
|
-
{
|
190
|
-
"itemid" => net_in_drop_item_id,
|
191
|
-
"drawtype" => "0",
|
192
|
-
"sortorder" => "0",
|
193
|
-
"color" => "00BBBB",
|
194
|
-
"yaxisside" => "0",
|
195
|
-
"calc_fnc" => "2",
|
196
|
-
"type" => "0",
|
197
|
-
"periods_cnt" => "5"
|
198
|
-
},
|
199
|
-
{
|
200
|
-
"itemid" => net_out_drop_item_id,
|
201
|
-
"drawtype" => "0",
|
202
|
-
"sortorder" => "0",
|
203
|
-
"color" => "BB00BB",
|
204
|
-
"yaxisside" => "0",
|
205
|
-
"calc_fnc" => "2",
|
206
|
-
"type" => "0",
|
207
|
-
"periods_cnt" => "5"
|
208
|
-
}
|
209
|
-
],
|
210
|
-
"show_triggers" => "0",
|
211
|
-
"name" => "Network on #{interface_name}",
|
212
|
-
"width" => "900",
|
213
|
-
"height" => "200",
|
214
|
-
"templateid" => "0"
|
215
|
-
}
|
216
|
-
|
217
|
-
p " ** Add 'Network on #{interface_name} graph'"
|
218
|
-
g_id = zbx.add_or_get_graph(t_id, options)
|