zabbixapi 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/.travis.yml +9 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +20 -0
  4. data/README.md +123 -0
  5. data/Rakefile +1 -0
  6. data/lib/zabbixapi/applications.rb +37 -0
  7. data/lib/zabbixapi/client.rb +65 -0
  8. data/lib/zabbixapi/errors.rb +12 -0
  9. data/lib/zabbixapi/graphs.rb +47 -0
  10. data/lib/zabbixapi/hostgroups.rb +42 -0
  11. data/lib/zabbixapi/hosts.rb +80 -0
  12. data/lib/zabbixapi/items.rb +81 -0
  13. data/lib/zabbixapi/server.rb +12 -0
  14. data/lib/zabbixapi/templates.rb +78 -0
  15. data/lib/zabbixapi/triggers.rb +42 -0
  16. data/lib/zabbixapi/users.rb +59 -0
  17. data/lib/zabbixapi/version.rb +3 -0
  18. data/lib/zabbixapi.rb +51 -12
  19. data/spec/localhost.rb +227 -75
  20. data/spec/run.rb +265 -0
  21. data/zabbixapi.gemspec +15 -15
  22. metadata +35 -57
  23. data/README.rdoc +0 -65
  24. data/examples/basic_auth.rb +0 -30
  25. data/examples/config.yml +0 -4
  26. data/examples/maintenance-example.rb +0 -55
  27. data/examples/populate_new_zabbix.sh +0 -84
  28. data/examples/zabbix_availability +0 -73
  29. data/examples/zabbix_clear_default +0 -36
  30. data/examples/zabbix_cpufan-sersor +0 -114
  31. data/examples/zabbix_cputemp-sersor +0 -112
  32. data/examples/zabbix_disk_io +0 -152
  33. data/examples/zabbix_filesystem +0 -249
  34. data/examples/zabbix_group +0 -25
  35. data/examples/zabbix_hlsp +0 -100
  36. data/examples/zabbix_host +0 -37
  37. data/examples/zabbix_iops +0 -131
  38. data/examples/zabbix_ipmi-cpufan-sersor +0 -101
  39. data/examples/zabbix_ipmi_systemp +0 -110
  40. data/examples/zabbix_la +0 -136
  41. data/examples/zabbix_mailer +0 -125
  42. data/examples/zabbix_mdadm +0 -72
  43. data/examples/zabbix_megaraid +0 -71
  44. data/examples/zabbix_memory +0 -290
  45. data/examples/zabbix_named +0 -71
  46. data/examples/zabbix_net +0 -218
  47. data/examples/zabbix_nginx +0 -167
  48. data/examples/zabbix_nginx_500 +0 -112
  49. data/examples/zabbix_ntp +0 -71
  50. data/examples/zabbix_nv-gputemp +0 -111
  51. data/examples/zabbix_pgsql +0 -125
  52. data/examples/zabbix_server_process +0 -71
  53. data/examples/zabbix_smart_blade +0 -94
  54. data/examples/zabbix_ssh +0 -71
  55. data/examples/zabbix_varnish +0 -71
  56. data/lib/zabbixapi/application.rb +0 -40
  57. data/lib/zabbixapi/base.rb +0 -158
  58. data/lib/zabbixapi/graph.rb +0 -59
  59. data/lib/zabbixapi/group.rb +0 -66
  60. data/lib/zabbixapi/host.rb +0 -70
  61. data/lib/zabbixapi/item.rb +0 -130
  62. data/lib/zabbixapi/maintenance.rb +0 -78
  63. data/lib/zabbixapi/mediatype.rb +0 -53
  64. data/lib/zabbixapi/screen.rb +0 -119
  65. data/lib/zabbixapi/template.rb +0 -128
  66. data/lib/zabbixapi/trigger.rb +0 -71
  67. data/lib/zabbixapi/user.rb +0 -0
  68. data/lib/zabbixapi/usermacro.rb +0 -46
data/spec/run.rb ADDED
@@ -0,0 +1,265 @@
1
+ require 'zabbixapi'
2
+
3
+ # settings
4
+ @api_url = 'http://localhost/zabbix/api_jsonrpc.php'
5
+ @api_login = 'Admin'
6
+ @api_password = 'zabbix'
7
+
8
+ zbx = ZabbixApi.connect(
9
+ :url => @api_url,
10
+ :user => @api_login,
11
+ :password => @api_password,
12
+ :debug => false
13
+ )
14
+
15
+ hostgroup = "hostgroup"
16
+ template = "template"
17
+ application = "application"
18
+ item = "item"
19
+ host = "hostname"
20
+ trigger = "trigger"
21
+ user = "user"
22
+ user2 = "user2"
23
+ graph = "graph"
24
+
25
+ describe ZabbixApi, "test_api" do
26
+
27
+
28
+ it "SERVER: Get version api" do
29
+ zbx.server.version.should be_kind_of(String)
30
+ end
31
+
32
+ it "HOSTGROUP: Create" do
33
+ zbx.hostgroups.create(:name => hostgroup).should be_kind_of(Integer)
34
+ end
35
+
36
+ it "HOSTGROUP: Find" do
37
+ zbx.hostgroups.get_id(:name => hostgroup).should be_kind_of(Integer)
38
+ end
39
+
40
+ it "HOSTGROUP: Find unknown" do
41
+ zbx.hostgroups.get_id(:name => "#{hostgroup}______").should be_kind_of(NilClass)
42
+ end
43
+
44
+ it "TEMPLATE: Create" do
45
+ zbx.templates.create(
46
+ :host => template,
47
+ :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
48
+ ).should be_kind_of(Integer)
49
+ end
50
+
51
+ it "TEMPLATE: Check full data" do
52
+ zbx.templates.get_full_data(:host => template)[0]['host'].should be_kind_of(String)
53
+ end
54
+
55
+ it "TEMPLATE: Find" do
56
+ zbx.templates.get_id(:host => template).should be_kind_of(Integer)
57
+ end
58
+
59
+ it "TEMPLATE: Find unknown" do
60
+ zbx.templates.get_id(:host => "#{template}_____").should be_kind_of(NilClass)
61
+ end
62
+
63
+ it "APPLICATION: Create" do
64
+ zbx.applications.create(
65
+ :name => application,
66
+ :hostid => zbx.templates.get_id(:host => template)
67
+ )
68
+ end
69
+
70
+ it "APPLICATION: Full info check" do
71
+ zbx.applications.get_full_data(:name => application)[0]['applicationid'].should be_kind_of(String)
72
+ end
73
+
74
+ it "APPLICATION: Find" do
75
+ zbx.applications.get_id(:name => application).should be_kind_of(Integer)
76
+ end
77
+
78
+ it "APPLICATION: Find unknown" do
79
+ zbx.applications.get_id(:name => "#{application}___").should be_kind_of(NilClass)
80
+ end
81
+
82
+ it "ITEM: Create" do
83
+ zbx.items.create(
84
+ :description => item,
85
+ :key_ => "proc.num[aaa]",
86
+ :hostid => zbx.templates.get_id(:host => template),
87
+ :applications => [zbx.applications.get_id(:name => application)]
88
+ )
89
+ end
90
+
91
+ it "ITEM: Full info check" do
92
+ zbx.items.get_full_data(:description => item)[0]['itemid'].should be_kind_of(String)
93
+ end
94
+
95
+ it "ITEM: Find" do
96
+ zbx.items.get_id(:description => item).should be_kind_of(Integer)
97
+ end
98
+
99
+ it "ITEM: Update" do
100
+ zbx.items.update(
101
+ :itemid => zbx.items.get_id(:description => item),
102
+ :status => 0
103
+ ).should be_kind_of(Integer)
104
+ end
105
+
106
+ it "ITEM: Get unknown" do
107
+ zbx.items.get_id(:description => "#{item}_____")
108
+ end
109
+
110
+ it "HOST: Create" do
111
+ zbx.hosts.create(
112
+ :host => host,
113
+ :ip => "10.20.48.88",
114
+ :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
115
+ ).should be_kind_of(Integer)
116
+ end
117
+
118
+ it "HOST: Find unknown" do
119
+ zbx.hosts.get_id(:host => "#{host}___").should be_kind_of(NilClass)
120
+ end
121
+
122
+ it "HOST: Find" do
123
+ zbx.hosts.get_id(:host => host).should be_kind_of(Integer)
124
+ end
125
+
126
+ it "HOST: Update" do
127
+ zbx.hosts.update(
128
+ :hostid => zbx.hosts.get_id(:host => host),
129
+ :status => 0
130
+ )
131
+ end
132
+
133
+ it "TEMPLATE: Get all templates linked with host" do
134
+ zbx.templates.get_ids_by_host(
135
+ :hostids => [zbx.hosts.get_id(:host => host)]
136
+ ).should be_kind_of(Array)
137
+ end
138
+
139
+ it "HOSTS: Linked host with templates" do
140
+ zbx.hosts.unlink_templates(
141
+ :hosts_id => [zbx.hosts.get_id(:host => host)],
142
+ :templates_id => [zbx.templates.get_id(:host => template)]
143
+ ).should be_kind_of(TrueClass)
144
+ end
145
+
146
+ it "TEMPLATE: Unlink host from templates" do
147
+
148
+ end
149
+
150
+ it "TEMPLATE: Get all" do
151
+ zbx.templates.all.should be_kind_of(Hash)
152
+ end
153
+
154
+ it "TRIGGER: Create" do
155
+ zbx.triggers.create(
156
+ :description => trigger,
157
+ :expression => "{#{template}:proc.num[aaa].last(0)}<1",
158
+ :comments => "Bla-bla is faulty (disaster)",
159
+ :priority => 5,
160
+ :status => 0,
161
+ :templateid => 0,
162
+ :type => 0
163
+ ).should be_kind_of(Integer)
164
+ end
165
+
166
+ it "TRIGGER: Find" do
167
+ zbx.triggers.get_id(:description => trigger).should be_kind_of(Integer)
168
+ end
169
+
170
+ it "GRAPH: Create" do
171
+ gitems = {
172
+ :itemid => zbx.items.get_id(:description => item),
173
+ :calc_fnc => "2",
174
+ :type => "0",
175
+ :periods_cnt => "5"
176
+ }
177
+ zbx.graphs.create(
178
+ :gitems => [gitems],
179
+ :show_triggers => "0",
180
+ :name => graph,
181
+ :width => "900",
182
+ :height => "200"
183
+ ).should be_kind_of(Integer)
184
+ #
185
+ end
186
+
187
+ it "GRAPH: Find" do
188
+ zbx.graphs.get_id( :name => graph ).should be_kind_of(Integer)
189
+ end
190
+
191
+ it "GRAPH: Update" do
192
+ zbx.graphs.update(
193
+ :graphid => zbx.graphs.get_id(
194
+ :name => graph,
195
+ :hostid => zbx.hosts.get_id(:host => host)
196
+ ),
197
+ :ymax_type => 1
198
+ ).should be_kind_of(Integer)
199
+ end
200
+
201
+ it "GRAPH: Delete" do
202
+ zbx.graphs.delete(zbx.graphs.get_id(:name => graph)).should be_kind_of(Integer)
203
+ end
204
+
205
+ it "TRIGGER: Delete" do
206
+ zbx.triggers.delete( zbx.triggers.get_id(:description => trigger) ).should be_kind_of(Integer)
207
+ end
208
+
209
+ it "HOST: Delete" do
210
+ zbx.hosts.delete( zbx.hosts.get_id(:host => host) ).should be_kind_of(Integer)
211
+ end
212
+
213
+ it "ITEM: Delete" do
214
+ zbx.items.delete(
215
+ zbx.items.get_id(:description => item)
216
+ ).should be_kind_of(Integer)
217
+ end
218
+
219
+ it "APPLICATION: Delete" do
220
+ zbx.applications.delete( zbx.applications.get_id(:name => application) )
221
+ end
222
+
223
+ it "TEMPLATE: Delete" do
224
+ zbx.templates.delete(zbx.templates.get_id(:host => template))
225
+ end
226
+
227
+ it "HOSTGROUP: Delete" do
228
+ zbx.hostgroups.delete(
229
+ zbx.hostgroups.get_id(:name => hostgroup)
230
+ ).should be_kind_of(Integer)
231
+ end
232
+
233
+ it "USER: Create" do
234
+ zbx.users.create(
235
+ :alias => "Test #{user}",
236
+ :name => user,
237
+ :surname => user,
238
+ :passwd => user
239
+ ).should be_kind_of(Integer)
240
+ end
241
+
242
+ it "USER: Find" do
243
+ zbx.users.get_full_data(:name => user)[0]['name'].should be_kind_of(String)
244
+ end
245
+
246
+ it "USER: Update" do
247
+ zbx.users.update(:userid => zbx.users.get_id(:name => user), :name => user2).should be_kind_of(Integer)
248
+ end
249
+
250
+ it "USER: Find unknown" do
251
+ zbx.users.get_id(:name => "#{user}_____")
252
+ end
253
+
254
+ it "USER: Delete" do
255
+ zbx.users.delete(zbx.users.get_id(:name => user2)).should be_kind_of(Integer)
256
+ end
257
+
258
+ it "QUERY" do
259
+ zbx.query(
260
+ :method => "apiinfo.version",
261
+ :params => {}
262
+ ).should be_kind_of(String)
263
+ end
264
+
265
+ end
data/zabbixapi.gemspec CHANGED
@@ -1,20 +1,20 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "zabbixapi/version"
2
4
 
3
- require 'rake'
5
+ Gem::Specification.new do |s|
6
+ s.name = "zabbixapi"
7
+ s.version = ZabbixApi::VERSION
8
+ s.authors = %w("Vasiliev D.V.")
9
+ s.email = %w(vadv.mkn@gmail.com)
10
+ s.homepage = "https://github.com/vadv/zabbixapi"
11
+ s.summary = %q{Realization for Zabbix API.}
12
+ s.description = %q{Allows you to work with zabbix api from ruby.}
4
13
 
5
- Gem::Specification.new do |spec|
14
+ s.rubyforge_project = "zabbixapi"
6
15
 
7
- spec.version = '0.3.0'
8
- spec.name = 'zabbixapi'
9
- spec.summary = 'Ruby module for work with zabbix api.'
10
-
11
- spec.email = 'vadv.mkn@gmail.com'
12
- spec.author = 'Eduard Snesarev and Dmitry Vasiliev, mathiasmethner@googlemail.com'
13
- spec.homepage = 'https://github.com/vadv/zabbixapi/wiki'
14
- spec.description = 'Ruby module for work with zabbix api v1.8.'
15
-
16
- spec.has_rdoc = true
17
- spec.extra_rdoc_files = 'README.rdoc'
18
-
19
- spec.files = FileList["lib/*.rb", "lib/zabbixapi/*.rb", "bin/*", "spec/*", 'zabbixapi.gemspec', 'README.rdoc', "examples/*"].to_a
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = %w(lib)
20
20
  end
metadata CHANGED
@@ -1,73 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zabbixapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Eduard Snesarev and Dmitry Vasiliev, mathiasmethner@googlemail.com
8
+ - ! '"Vasiliev'
9
+ - D.V."
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-11-08 00:00:00.000000000 Z
13
+ date: 2012-11-19 00:00:00.000000000 Z
13
14
  dependencies: []
14
- description: Ruby module for work with zabbix api v1.8.
15
- email: vadv.mkn@gmail.com
15
+ description: Allows you to work with zabbix api from ruby.
16
+ email:
17
+ - vadv.mkn@gmail.com
16
18
  executables: []
17
19
  extensions: []
18
- extra_rdoc_files:
19
- - README.rdoc
20
+ extra_rdoc_files: []
20
21
  files:
22
+ - .travis.yml
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - README.md
26
+ - Rakefile
21
27
  - lib/zabbixapi.rb
22
- - lib/zabbixapi/application.rb
23
- - lib/zabbixapi/base.rb
24
- - lib/zabbixapi/graph.rb
25
- - lib/zabbixapi/group.rb
26
- - lib/zabbixapi/host.rb
27
- - lib/zabbixapi/item.rb
28
- - lib/zabbixapi/maintenance.rb
29
- - lib/zabbixapi/mediatype.rb
30
- - lib/zabbixapi/screen.rb
31
- - lib/zabbixapi/template.rb
32
- - lib/zabbixapi/trigger.rb
33
- - lib/zabbixapi/user.rb
34
- - lib/zabbixapi/usermacro.rb
28
+ - lib/zabbixapi/applications.rb
29
+ - lib/zabbixapi/client.rb
30
+ - lib/zabbixapi/errors.rb
31
+ - lib/zabbixapi/graphs.rb
32
+ - lib/zabbixapi/hostgroups.rb
33
+ - lib/zabbixapi/hosts.rb
34
+ - lib/zabbixapi/items.rb
35
+ - lib/zabbixapi/server.rb
36
+ - lib/zabbixapi/templates.rb
37
+ - lib/zabbixapi/triggers.rb
38
+ - lib/zabbixapi/users.rb
39
+ - lib/zabbixapi/version.rb
35
40
  - spec/localhost.rb
41
+ - spec/run.rb
36
42
  - zabbixapi.gemspec
37
- - README.rdoc
38
- - examples/basic_auth.rb
39
- - examples/config.yml
40
- - examples/maintenance-example.rb
41
- - examples/populate_new_zabbix.sh
42
- - examples/zabbix_availability
43
- - examples/zabbix_clear_default
44
- - examples/zabbix_cpufan-sersor
45
- - examples/zabbix_cputemp-sersor
46
- - examples/zabbix_disk_io
47
- - examples/zabbix_filesystem
48
- - examples/zabbix_group
49
- - examples/zabbix_hlsp
50
- - examples/zabbix_host
51
- - examples/zabbix_iops
52
- - examples/zabbix_ipmi-cpufan-sersor
53
- - examples/zabbix_ipmi_systemp
54
- - examples/zabbix_la
55
- - examples/zabbix_mailer
56
- - examples/zabbix_mdadm
57
- - examples/zabbix_megaraid
58
- - examples/zabbix_memory
59
- - examples/zabbix_named
60
- - examples/zabbix_net
61
- - examples/zabbix_nginx
62
- - examples/zabbix_nginx_500
63
- - examples/zabbix_ntp
64
- - examples/zabbix_nv-gputemp
65
- - examples/zabbix_pgsql
66
- - examples/zabbix_server_process
67
- - examples/zabbix_smart_blade
68
- - examples/zabbix_ssh
69
- - examples/zabbix_varnish
70
- homepage: https://github.com/vadv/zabbixapi/wiki
43
+ homepage: https://github.com/vadv/zabbixapi
71
44
  licenses: []
72
45
  post_install_message:
73
46
  rdoc_options: []
@@ -79,6 +52,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
52
  - - ! '>='
80
53
  - !ruby/object:Gem::Version
81
54
  version: '0'
55
+ segments:
56
+ - 0
57
+ hash: -2483481549934941207
82
58
  required_rubygems_version: !ruby/object:Gem::Requirement
83
59
  none: false
84
60
  requirements:
@@ -86,9 +62,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
62
  - !ruby/object:Gem::Version
87
63
  version: '0'
88
64
  requirements: []
89
- rubyforge_project:
65
+ rubyforge_project: zabbixapi
90
66
  rubygems_version: 1.8.24
91
67
  signing_key:
92
68
  specification_version: 3
93
- summary: Ruby module for work with zabbix api.
94
- test_files: []
69
+ summary: Realization for Zabbix API.
70
+ test_files:
71
+ - spec/localhost.rb
72
+ - spec/run.rb
data/README.rdoc DELETED
@@ -1,65 +0,0 @@
1
- = Ruby Zabbix Api Module.
2
-
3
- Simple and lightweight ruby module for work with zabbix api version 1.8.x
4
-
5
- {<img src="https://travis-ci.org/vadv/zabbixapi.png">}[https://travis-ci.org/vadv/zabbixapi]
6
-
7
- You can:
8
- * Create and delete host/template/application/items/triggers/maintenance and screens;
9
- * Get info about all zabbix essences;
10
-
11
- == Installation
12
-
13
- gem install zabbixapi
14
-
15
- == Get Start
16
-
17
- * Create host and get hostid from zabbix api:
18
-
19
- zbx = Zabbix::ZabbixApi.new('https://zabbix.example.com', 'login', 'password')
20
- host_options = {
21
- "ip" => '127.0.0.1',
22
- "dns" => 'my.example.com',
23
- "host" => 'my.example.com',
24
- "useip" => 1,
25
- "groups" => [zbx.get_group_id('some_group')]
26
- }
27
- if zbx.create_host(host_options)
28
- puts zbx.get_host_id('my.example.com')
29
- end
30
-
31
- * Create hostgroup and get hostgroupid from zabbix api:
32
-
33
- zbx = Zabbix::ZabbixApi.new('https://zabbix.example.com', 'login', 'password')
34
- if zbx.add_group('some_group')
35
- puts zbx.get_group_id('some_group')
36
- end
37
-
38
- * Debugging
39
-
40
- For debug information on requests set
41
-
42
- zbx.debug = true
43
-
44
- More see in spec please...
45
-
46
- == Dependencies
47
-
48
- * net/http
49
- * net/https
50
- * json
51
-
52
- == Use examples
53
-
54
- * zabbix_la - LoadAverage template
55
-
56
- cd examples
57
- ruby zabbix_la -E development -g Templates
58
-
59
- * -E - env from examples/config.yml (like RAILS_ENV)
60
- * -g - group in zabbix for templates
61
-
62
- == Zabbix documentation
63
-
64
- * Zabbix Project Homepage -> http://zabbix.com/
65
- * Zabbix Api docs -> http://www.zabbix.com/documentation/1.8/api
@@ -1,30 +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:E:")
9
-
10
- group_name = opt["g"]
11
- zabbix_env = opt["E"]
12
-
13
- maintenance_name = "Test Maintenance"
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
- zbx.debug = true
25
- #Simply uses the api_login and api_password for basic auth
26
- zbx.basic_auth = true
27
-
28
- p " * Creating hostgroup #{group_name}."
29
- g_id = zbx.add_or_get_group(group_name)
30
- puts g_id
data/examples/config.yml DELETED
@@ -1,4 +0,0 @@
1
- development:
2
- api_url: "http://zabbix.local/api_jsonrpc.php"
3
- api_login: admin
4
- api_password: zabbix
@@ -1,55 +0,0 @@
1
- #
2
- # gems
3
- #
4
- require 'zabbixapi'
5
-
6
- #
7
- # main
8
- #
9
- @yourZabbixHost = 'https://zabbix.example.com/api_jsonrpc.php'
10
- @yourZabbixLogin = 'login'
11
- @yourZabbixPassword = 'password'
12
- @yourServerHost = 'examplehost'
13
-
14
- # init
15
- zbx = Zabbix::ZabbixApi.new(@yourZabbixHost, @yourZabbixLogin, @yourZabbixPassword)
16
- zbx.debug = true
17
-
18
- # find your host
19
- host_id = zbx.get_host_id(@yourServerHost);
20
- puts host_id
21
-
22
- # create an 1hour maintenance period
23
- # => true
24
- time_now = Time.now.to_i
25
- options = {
26
- 'name' => 'maintenance example',
27
- 'description' => 'maintenance example description ',
28
- 'active_since' => time_now,
29
- 'active_till' => time_now + 60*60
30
- }
31
- maintenance_id = zbx.create_maintenance(host_id,options)
32
- puts maintenance_id
33
-
34
- # is maintenance item available?
35
- # => true
36
- puts zbx.maintenance_exists?(maintenance_id)
37
-
38
- # update name, description and extend period to 3h
39
- # => true
40
- options = {
41
- 'name' => 'maintenance example update',
42
- 'description' => 'maintenance example update description',
43
- 'hostids' => [host_id],
44
- 'active_since' => time_now,
45
- 'active_till' => time_now + 180*60
46
- }
47
- puts zbx.update_maintenance(maintenance_id,options)
48
-
49
- # delete it
50
- # => true
51
- puts zbx.delete_maintenance(maintenance_id)
52
-
53
- # is maintenance item still available?
54
- # => false
55
- puts zbx.maintenance_exists?(maintenance_id)
@@ -1,84 +0,0 @@
1
- #!/bin/bash
2
-
3
- if [ $# -ne 1 ]; then
4
- echo "usage: $(basename $0) ENVIRONMENT"
5
- exit 1
6
- fi
7
-
8
- ENVIRONMENT=$1
9
- CURRENT_DIR=$(dirname $0)
10
-
11
- # Clear default
12
- bundle exec ruby zabbix_clear_default -E $ENVIRONMENT
13
-
14
- # Availability
15
- bundle exec ruby zabbix_availability -E $ENVIRONMENT -g "Templates"
16
-
17
- # Net
18
- bundle exec ruby zabbix_net -E $ENVIRONMENT -g "Templates" -i eth0
19
- bundle exec ruby zabbix_net -E $ENVIRONMENT -g "Templates" -i eth1
20
- bundle exec ruby zabbix_net -E $ENVIRONMENT -g "Templates" -i eth2
21
- bundle exec ruby zabbix_net -E $ENVIRONMENT -g "Templates" -i eth3
22
-
23
- # LA
24
- bundle exec ruby zabbix_la -E $ENVIRONMENT -g "Templates"
25
-
26
- # Memory
27
- bundle exec ruby zabbix_memory -E $ENVIRONMENT -g "Templates"
28
-
29
- # Filesystems
30
- for i in "/storage" "/" "/boot" "/mnt" "/var" "/home" "/tmp" "/backup" \
31
- "/var/lib/postgresql"; do
32
- bundle exec ruby zabbix_filesystem -E $ENVIRONMENT -g "Templates" -m "$i"
33
- done
34
-
35
- # SSH
36
- bundle exec ruby zabbix_ssh -E $ENVIRONMENT -g Templates
37
-
38
- # NTP
39
- bundle exec ruby zabbix_ntp -E $ENVIRONMENT -g Templates
40
-
41
- # HLSP
42
- for i in {1..8}; do
43
- bundle exec ruby zabbix_hlsp -E $ENVIRONMENT -g Templates -i ${i}
44
- done
45
-
46
- # Playout
47
- bundle exec ruby zabbix_playout-t -E $ENVIRONMENT -g Templates
48
-
49
- # MegaRAID
50
- bundle exec ruby zabbix_megaraid -E $ENVIRONMENT -g Templates
51
-
52
- # PGSQL
53
- bundle exec ruby zabbix_pgsql -E $ENVIRONMENT -g Templates
54
-
55
- # MDADM
56
- for i in md0 md1 md2 md3; do
57
- bundle exec ruby zabbix_mdadm -E $ENVIRONMENT -g Templates -n ${i}
58
- done
59
-
60
- # ipmi_systemp
61
- bundle exec ruby zabbix_ipmi_systemp -E $ENVIRONMENT -g Templates
62
-
63
- # IO
64
- bundle exec ruby zabbix_iops -E $ENVIRONMENT -g Templates -n sda
65
-
66
- # varnish
67
- bundle exec ruby zabbix_varnish -E $ENVIRONMENT -g Templates
68
-
69
- # nginx
70
- bundle exec ruby zabbix_nginx -E $ENVIRONMENT -g Templates
71
-
72
- # nginx_500
73
- bundle exec ruby zabbix_nginx_500 -E $ENVIRONMENT -g Templates
74
-
75
-
76
- bundle exec ruby zabbix_cpufan-sersor -E $ENVIRONMENT -g Templates
77
- bundle exec ruby zabbix_cputemp-sersor -E $ENVIRONMENT -g Templates
78
- bundle exec ruby zabbix_ipmi-cpufan-sersor -E $ENVIRONMENT -g Templates
79
- bundle exec ruby zabbix_mailer -E $ENVIRONMENT -g Templates
80
- bundle exec ruby zabbix_megaraid -E $ENVIRONMENT -g Templates
81
- bundle exec ruby zabbix_mpeg2lander_signal -E $ENVIRONMENT -g Templates
82
- bundle exec ruby zabbix_mpeg2lander_status -E $ENVIRONMENT -g Templates
83
- bundle exec ruby zabbix_named -E $ENVIRONMENT -g Templates
84
- bundle exec ruby zabbix_nv-gputemp -E $ENVIRONMENT -g Templates