zabbapi 2.4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/wda +23 -0
- data/lib/zabbapi.rb +302 -0
- data/lib/zabbapi/version.rb +3 -0
- data/zabbapi.gemspec +35 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 203f967100c1bf3abb427e95601090d99739d0ab
|
4
|
+
data.tar.gz: 6c7a8dfd3e43355c71c3c50a7b931832a358b394
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f7208193f2529e4392ce8ba0bb497d752445e85bdc50b7b78599ccd2ebb2f61c764a5aa1f55e43d57fa2e4c29d024b528e88424d6a093b9d940259fe40deb11d
|
7
|
+
data.tar.gz: 70fa6e6e6a03fc2f759a5409799578261a5d2498d01d8bb8dea8cd68e661ad970df0bf3bcfce72d9bac7bf8789292c430207fb86bef6177724f0e5bd0aa5a6a8
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at maxn@amhost.net. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 maxn maxn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Zabbapi
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/zabbapi`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'zabbapi'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install zabbapi
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/zabbapi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "zabbapi"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/wda
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'zabbapi'
|
3
|
+
$type = ARGV[0]
|
4
|
+
$host = ARGV[1]
|
5
|
+
$name = ARGV[2]
|
6
|
+
$email = ARGV[3]
|
7
|
+
$activeif = ARGV[4]
|
8
|
+
$ip = ARGV[5]
|
9
|
+
if $type == "del"
|
10
|
+
Zabbapi::WatchDog.new.wddel($host)
|
11
|
+
elsif $type == "add"
|
12
|
+
Zabbapi::WatchDog.new.wdadd($host, $name , $email , $activeif , $ip)
|
13
|
+
elsif $type == "update"
|
14
|
+
Zabbapi::WatchDog.new.update($host)
|
15
|
+
else
|
16
|
+
puts "error input. please use:"
|
17
|
+
puts " for add:"
|
18
|
+
puts "wda add <hostname> <name> <email> <activeif> <ip>"
|
19
|
+
puts " for del:"
|
20
|
+
puts "wda del <hostname>"
|
21
|
+
puts " for update:"
|
22
|
+
puts "wda update <hostname>"
|
23
|
+
end
|
data/lib/zabbapi.rb
ADDED
@@ -0,0 +1,302 @@
|
|
1
|
+
require "zabbapi/version"
|
2
|
+
require 'zabbixapi'
|
3
|
+
require 'json'
|
4
|
+
require 'mechanize'
|
5
|
+
require 'hpricot'
|
6
|
+
#require 'openssl'
|
7
|
+
module Zabbapi
|
8
|
+
if not File.exist?('/etc/config.json')
|
9
|
+
abort("please create config file with credentials /etc/config.json")
|
10
|
+
end
|
11
|
+
file = File.read('/etc/config.json')
|
12
|
+
credentials = JSON.parse(file)
|
13
|
+
$wd_host = credentials['host']
|
14
|
+
$wd_admin_login = credentials['login']
|
15
|
+
$wd_admin_pass = credentials['pass']
|
16
|
+
|
17
|
+
class WatchDog
|
18
|
+
|
19
|
+
def wddel(hostname)
|
20
|
+
@hostname = hostname
|
21
|
+
zbx = ZabbixApi.connect(
|
22
|
+
:url => 'https://' + $wd_host + '/api_jsonrpc.php',
|
23
|
+
:user => $wd_admin_login ,
|
24
|
+
:password => $wd_admin_pass
|
25
|
+
)
|
26
|
+
begin
|
27
|
+
zbx.hosts.delete zbx.hosts.get_id(:host => @hostname )
|
28
|
+
rescue
|
29
|
+
puts "unknown host with hostname " + @hostname
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
$idscreenfordel = zbx.screens.get(
|
33
|
+
:name => @hostname
|
34
|
+
)
|
35
|
+
$idscreenfordel = Hash[*$idscreenfordel]
|
36
|
+
zbx.screens.delete(
|
37
|
+
$idscreenfordel["screenid"]
|
38
|
+
)
|
39
|
+
rescue
|
40
|
+
puts "host with hostname " + @hostname + " deleted"
|
41
|
+
else
|
42
|
+
puts "host with hostname " + @hostname + " deleted"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def wdadd(hostname , name , email , activeif , ip)
|
48
|
+
@hostname = hostname
|
49
|
+
@name = name
|
50
|
+
@email = email
|
51
|
+
@activeif = activeif
|
52
|
+
@ip = ip
|
53
|
+
passwd = [*('a'..'z'),*('0'..'9')].sample(12).join
|
54
|
+
|
55
|
+
puts "Add host to zabbix..."
|
56
|
+
zbx = ZabbixApi.connect(
|
57
|
+
:url => 'https://' + $wd_host + '/api_jsonrpc.php',
|
58
|
+
:user => $wd_admin_login ,
|
59
|
+
:password => $wd_admin_pass
|
60
|
+
)
|
61
|
+
begin
|
62
|
+
zbx.hostgroups.create(:name => @name)
|
63
|
+
rescue
|
64
|
+
puts "HostGroup exist!"
|
65
|
+
else
|
66
|
+
puts "HostGroup created!"
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
zbx.usergroups.get_or_create(:name => @name)
|
71
|
+
rescue
|
72
|
+
puts "UserGroup exist!"
|
73
|
+
else
|
74
|
+
zbx.query(
|
75
|
+
:method => "usergroup.massadd",
|
76
|
+
:params => {
|
77
|
+
:usrgrpids => [zbx.usergroups.get_id(:name => @name)],
|
78
|
+
:rights => [{
|
79
|
+
:groupid => [zbx.usergroups.get_id(:name => @name)],
|
80
|
+
:id => zbx.hostgroups.get_id(:name => $name) ,
|
81
|
+
:permission => 2
|
82
|
+
}]
|
83
|
+
}
|
84
|
+
)
|
85
|
+
puts "UserGroup #{@name} added.."
|
86
|
+
end
|
87
|
+
|
88
|
+
begin
|
89
|
+
zbx.users.create(
|
90
|
+
:alias => $name,
|
91
|
+
:type => 1,
|
92
|
+
:passwd => passwd,
|
93
|
+
:usrgrps => [zbx.usergroups.get_id(:name => @name)],
|
94
|
+
:url => '/screens.php'
|
95
|
+
)
|
96
|
+
rescue
|
97
|
+
puts "User exist!"
|
98
|
+
else
|
99
|
+
puts "User created!"
|
100
|
+
puts " "
|
101
|
+
puts "#WDAmhost"
|
102
|
+
puts 'https://' + $wd_host
|
103
|
+
puts "#{@name} / #{passwd}"
|
104
|
+
puts " "
|
105
|
+
|
106
|
+
begin
|
107
|
+
getuserid = zbx.query(
|
108
|
+
:method => "user.get",
|
109
|
+
:params => {
|
110
|
+
:filter => { :alias => ["#{@name}"] },
|
111
|
+
:output => {
|
112
|
+
:filter => "userid"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
)
|
117
|
+
|
118
|
+
getuserid = Hash[*getuserid]
|
119
|
+
|
120
|
+
zbx.query(:method => "user.addmedia",
|
121
|
+
:params => {
|
122
|
+
:users => { :userid => getuserid["userid"]},
|
123
|
+
:medias => [
|
124
|
+
{
|
125
|
+
:mediatypeid => "100100000000001" ,
|
126
|
+
:sendto => @email,
|
127
|
+
:active => 0,
|
128
|
+
:severity => 48,
|
129
|
+
:period => "1-7,00:00-24:00"
|
130
|
+
}
|
131
|
+
]
|
132
|
+
}
|
133
|
+
)
|
134
|
+
rescue
|
135
|
+
puts "UserMedia exist!"
|
136
|
+
else
|
137
|
+
puts "UserMedia added to #{@name}"
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
if $host.chars.first == 'l'
|
144
|
+
$tplid = '100100000010001'
|
145
|
+
elsif $host.chars.first == 'f'
|
146
|
+
$tplid = '100100000010008'
|
147
|
+
else
|
148
|
+
$tplid = '100100000010001'
|
149
|
+
end
|
150
|
+
|
151
|
+
begin
|
152
|
+
zbx.query(:method => "host.create" ,
|
153
|
+
:params => {
|
154
|
+
:host => @hostname ,
|
155
|
+
:interfaces => {
|
156
|
+
:type => 1,
|
157
|
+
:main => 1,
|
158
|
+
:ip => $ip ,
|
159
|
+
:dns => "",
|
160
|
+
:useip => 1,
|
161
|
+
:port => 10050
|
162
|
+
},
|
163
|
+
:groups => [{ :groupid => zbx.hostgroups.get_id(:name => @name) }],
|
164
|
+
:templates => { :templateid => $tplid }
|
165
|
+
}
|
166
|
+
)
|
167
|
+
rescue
|
168
|
+
puts "Host exist or got error!"
|
169
|
+
abort "please del #{@hostname} first."
|
170
|
+
else
|
171
|
+
puts "Added host #{@hostname} to #{@name} !"
|
172
|
+
end
|
173
|
+
|
174
|
+
begin
|
175
|
+
zbx.query(
|
176
|
+
:method => "action.create" ,
|
177
|
+
:params => [ {
|
178
|
+
:name => "all #{@name} triggs",
|
179
|
+
:eventsource => 0 ,
|
180
|
+
:status => 0 ,
|
181
|
+
:evaltype => 0 ,
|
182
|
+
:esc_period => 3600 ,
|
183
|
+
:def_shortdata => '{TRIGGER.NAME}: {STATUS}' ,
|
184
|
+
:def_longdata => '{TRIGGER.NAME}: {STATUS}',
|
185
|
+
:usrgrpid => zbx.usergroups.get_id(:name => @name),
|
186
|
+
:conditions => [
|
187
|
+
{
|
188
|
+
:conditiontype => 0 ,
|
189
|
+
:operator => 0 ,
|
190
|
+
:value => zbx.hostgroups.get_id(:name => $name)
|
191
|
+
}
|
192
|
+
],
|
193
|
+
:operations => [
|
194
|
+
{
|
195
|
+
:operationtype => 0 ,
|
196
|
+
:opmessage_grp => [
|
197
|
+
{
|
198
|
+
:usrgrpid => zbx.usergroups.get_id(:name => @name)
|
199
|
+
}],
|
200
|
+
:opmessage => {:default_msg => 1 }
|
201
|
+
}
|
202
|
+
]
|
203
|
+
}]
|
204
|
+
)
|
205
|
+
rescue
|
206
|
+
puts "Action exist!"
|
207
|
+
end
|
208
|
+
|
209
|
+
puts "Update host templates..."
|
210
|
+
|
211
|
+
zbx.templates.mass_add(
|
212
|
+
:hosts_id => [zbx.hosts.get_id(:host => @hostname)],
|
213
|
+
:templates_id => [100100000010962 , 100100000010003 , 100100000010099 , 100100000011805]
|
214
|
+
)
|
215
|
+
|
216
|
+
puts "Add host to group..."
|
217
|
+
|
218
|
+
zbx.query(:method => "hostgroup.massadd" , :params => {:groups => {:groupid => "100100000000614"} , :hosts => {:hostid => zbx.hosts.get_id(:host => @hostname)}} )
|
219
|
+
begin
|
220
|
+
puts "Update screen graphs..."
|
221
|
+
ifaceknow = [ "eth0" , "eth1" , "em1" , "bond0" , "bond1" , "eth2" , "eth3" , "eth4" , "p4p1" ]
|
222
|
+
puts "discovery active interface graph"
|
223
|
+
sleep(66) unless ifaceknow.include? @activeif
|
224
|
+
rescue
|
225
|
+
abort "Its not error!!!! please wait 5 min , and update host , because new iface not discovered."
|
226
|
+
end
|
227
|
+
begin
|
228
|
+
|
229
|
+
iface = "Traffic " + @activeif
|
230
|
+
iface = "Traffic on " + @activeif unless ifaceknow.include? @activeif
|
231
|
+
$graphtoscreen1 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => iface )
|
232
|
+
$graphtoscreen2 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "CPU\ Utilization")
|
233
|
+
$graphtoscreen3 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "Load\ Average")
|
234
|
+
$graphtoscreen4 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "MySQL\ queries")
|
235
|
+
$graphtoscreen5 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "Processes")
|
236
|
+
$graphtoscreen6 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "Memory")
|
237
|
+
$graphtoscreen1 = $graphtoscreen1.map(&:to_i)
|
238
|
+
$graphtoscreen2 = $graphtoscreen2.map(&:to_i)
|
239
|
+
$graphtoscreen3 = $graphtoscreen3.map(&:to_i)
|
240
|
+
$graphtoscreen4 = $graphtoscreen4.map(&:to_i)
|
241
|
+
$graphtoscreen5 = $graphtoscreen5.map(&:to_i)
|
242
|
+
$graphtoscreen6 = $graphtoscreen6.map(&:to_i)
|
243
|
+
|
244
|
+
zbx.screens.get_or_create_for_host(
|
245
|
+
:hosts_id => [zbx.hosts.get_id(:host => @hostname)],
|
246
|
+
:screen_name => @hostname,
|
247
|
+
:height => 180,
|
248
|
+
:width => 360,
|
249
|
+
:vsize => 3,
|
250
|
+
:hsize => 2,
|
251
|
+
:halign => 0,
|
252
|
+
:valign => 0,
|
253
|
+
:graphids => [ $graphtoscreen1[0] , $graphtoscreen2[0] , $graphtoscreen3[0] , $graphtoscreen4[0] , $graphtoscreen5[0] , $graphtoscreen6[0] ]
|
254
|
+
)
|
255
|
+
rescue
|
256
|
+
iface = "Traffic " + @activeif
|
257
|
+
$graphtoscreen1 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => iface )
|
258
|
+
$graphtoscreen2 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "CPU\ Utilization")
|
259
|
+
$graphtoscreen3 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "Load\ Average")
|
260
|
+
$graphtoscreen4 = zbx.graphs.get_ids_by_host(:host => @hostname , :filter => "MySQL\ queries")
|
261
|
+
$graphtoscreen1 = $graphtoscreen1.map(&:to_i)
|
262
|
+
$graphtoscreen2 = $graphtoscreen2.map(&:to_i)
|
263
|
+
$graphtoscreen3 = $graphtoscreen3.map(&:to_i)
|
264
|
+
$graphtoscreen4 = $graphtoscreen4.map(&:to_i)
|
265
|
+
|
266
|
+
zbx.screens.get_or_create_for_host(
|
267
|
+
:hosts_id => [zbx.hosts.get_id(:host => @hostname)],
|
268
|
+
:screen_name => @hostname,
|
269
|
+
:height => 180,
|
270
|
+
:width => 360,
|
271
|
+
:vsize => 2,
|
272
|
+
:hsize => 2,
|
273
|
+
:halign => 0,
|
274
|
+
:valign => 0,
|
275
|
+
:graphids => [ $graphtoscreen1[0] , $graphtoscreen2[0] , $graphtoscreen3[0] , $graphtoscreen4[0] ]
|
276
|
+
)
|
277
|
+
end
|
278
|
+
puts "Done!"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
#class UpdateHostTemplates
|
283
|
+
def update(hostname)
|
284
|
+
@hostname = hostname
|
285
|
+
zbx = ZabbixApi.connect(
|
286
|
+
:url => 'https://' + $wd_host + '/api_jsonrpc.php',
|
287
|
+
:user => $wd_admin_login ,
|
288
|
+
:password => $wd_admin_pass
|
289
|
+
)
|
290
|
+
zbx.templates.mass_add(
|
291
|
+
:hosts_id => [zbx.hosts.get_id(:host => @hostname)],
|
292
|
+
:templates_id => [100100000010962 , 100100000010003 , 100100000010099]
|
293
|
+
)
|
294
|
+
zbx.screens.get_or_create_for_host(
|
295
|
+
:hosts_id => [zbx.hosts.get_id(:host => @hostname)],
|
296
|
+
:screen_name => @hostname,
|
297
|
+
:graphids => zbx.graphs.get_ids_by_host(:host => @hostname )
|
298
|
+
)
|
299
|
+
end
|
300
|
+
#end
|
301
|
+
|
302
|
+
end
|
data/zabbapi.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'zabbapi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "zabbapi"
|
8
|
+
spec.version = Zabbapi::VERSION
|
9
|
+
spec.authors = ["maxn maxn"]
|
10
|
+
spec.email = ["nikolaev.makc@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{watch dog cli}
|
13
|
+
spec.description = %q{ZabbixAPI for host create / delete / update}
|
14
|
+
spec.homepage = "https://rubygems.org/gems/zabbapi"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = ""
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.executables = ["wda"]
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
spec.add_dependency "zabbixapi" , "=2.4.2"
|
31
|
+
spec.add_dependency "json" , '~> 1.8', '>= 1.8.3'
|
32
|
+
spec.add_dependency "mechanize" , '~> 2.7', '>= 2.7.4'
|
33
|
+
spec.add_dependency "hpricot" , "~>0.8.6"
|
34
|
+
#spec.add_dependency "openssl" , "~>0.2.0"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zabbapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.13
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- maxn maxn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zabbixapi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.4.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.4.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.8.3
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.8'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.8.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mechanize
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.7'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.7.4
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.7'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.7.4
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: hpricot
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.8.6
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.8.6
|
81
|
+
description: ZabbixAPI for host create / delete / update
|
82
|
+
email:
|
83
|
+
- nikolaev.makc@gmail.com
|
84
|
+
executables:
|
85
|
+
- wda
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- ".gitignore"
|
90
|
+
- CODE_OF_CONDUCT.md
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- exe/wda
|
98
|
+
- lib/zabbapi.rb
|
99
|
+
- lib/zabbapi/version.rb
|
100
|
+
- zabbapi.gemspec
|
101
|
+
homepage: https://rubygems.org/gems/zabbapi
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.4.6
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: watch dog cli
|
125
|
+
test_files: []
|
126
|
+
has_rdoc:
|