awsbix 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/bin/config.yaml +0 -6
- data/lib/awsbix/api.rb +26 -0
- data/lib/awsbix/aws.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9329db0807749656a85796aa07a9892348d77f04
|
4
|
+
data.tar.gz: 6a66f81a1c030c9655552671e9727e050fbed1d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07c7a612078e52b396bcabd44417fdbc69f71c4356bae12464aab104781d4342ed8bdbe3301ba55175d94572f6dffecf769499fd98cd727205d5acab2e07c162
|
7
|
+
data.tar.gz: 4f005004cdb1bae93332c620df18cfbc75d2559378c1a85757f06f66c6fb393873cdbedb88f1a60827a0b03b806c548809cbebd3c3ff2d9b37d2d1999a311fb4
|
data/bin/config.yaml
CHANGED
@@ -3,12 +3,6 @@ log_level: 'debug'
|
|
3
3
|
zbx_url: 'http://localhost/zabbix/api_jsonrpc.php'
|
4
4
|
zbx_username: 'Admin'
|
5
5
|
zbx_password: 'zabbix'
|
6
|
-
# zbx_filter_model either include or exclude host based on the security group
|
7
|
-
zbx_filter_model: 'include'
|
8
|
-
zbx_include_security_group:
|
9
|
-
- 'only-this-security-group'
|
10
|
-
zbx_exclude_security_group:
|
11
|
-
- 'do-not-use-this-security-group'
|
12
6
|
zbx_default_templates:
|
13
7
|
- 'Template OS Linux'
|
14
8
|
|
data/lib/awsbix/api.rb
CHANGED
@@ -115,6 +115,32 @@ class Awsbix
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def zbx_enable_host(hostname)
|
119
|
+
# append hostname suffix if one is configured
|
120
|
+
if self.get_conf('aws_dns_suffix') then
|
121
|
+
self.debug_print("debug: appending #{self.get_conf('aws_dns_suffix')} to #{options[:hostname]}")
|
122
|
+
hostname = hostname + self.get_conf('aws_dns_suffix')
|
123
|
+
end
|
124
|
+
|
125
|
+
@zbx.hosts.update(
|
126
|
+
:hostid => @zbx.hosts.get_id(:host => hostname),
|
127
|
+
:status => 0
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
def zbx_disable_host(hostname)
|
132
|
+
# append hostname suffix if one is configured
|
133
|
+
if self.get_conf('aws_dns_suffix') then
|
134
|
+
self.debug_print("debug: appending #{self.get_conf('aws_dns_suffix')} to #{options[:hostname]}")
|
135
|
+
hostname = hostname + self.get_conf('aws_dns_suffix')
|
136
|
+
end
|
137
|
+
|
138
|
+
@zbx.hosts.update(
|
139
|
+
:hostid => @zbx.hosts.get_id(:host => hostname),
|
140
|
+
:status => 1
|
141
|
+
)
|
142
|
+
end
|
143
|
+
|
118
144
|
def zbx_process_host(options = {})
|
119
145
|
unless options[:hostname] and options[:group] and options[:port] and options[:ip] and options[:dns] and options[:useip] then
|
120
146
|
puts "error: not enough parameters"
|
data/lib/awsbix/aws.rb
CHANGED
@@ -50,6 +50,8 @@ class Awsbix
|
|
50
50
|
options[:filter] ||= 'include'
|
51
51
|
# if no regex is provided default to '.*'
|
52
52
|
options[:regex] ||= %r{.*}
|
53
|
+
# instance_status defaults to 'running'
|
54
|
+
options[:instance_status] ||= 'running'
|
53
55
|
@ec2_hosts = Array.new
|
54
56
|
|
55
57
|
self.ec2_connect()
|
@@ -58,7 +60,7 @@ class Awsbix
|
|
58
60
|
self.debug_print("info: processing #{region}")
|
59
61
|
AWS.memoize do
|
60
62
|
@ec2.regions[region].instances.each do | inst |
|
61
|
-
if inst.status.match(/
|
63
|
+
if inst.status.match(/options[:instance_status]/) then
|
62
64
|
inst.security_groups.each do | sg |
|
63
65
|
if options[:regex].is_a?(Regexp) then
|
64
66
|
case options[:filter]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awsbix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Llewellyn-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.5.2
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: add/remove hosts to Zabbix
|