rubix 0.5.4 → 0.5.5
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/VERSION +1 -1
- data/lib/rubix.rb +2 -0
- data/lib/rubix/connection.rb +7 -2
- data/lib/rubix/log.rb +2 -2
- data/lib/rubix/models/host.rb +66 -16
- data/spec/requests/application_request_spec.rb +1 -1
- data/spec/requests/host_request_spec.rb +3 -2
- data/spec/requests/item_request_spec.rb +2 -2
- data/spec/requests/time_series_request_spec.rb +1 -1
- data/spec/requests/trigger_request_spec.rb +2 -2
- data/spec/requests/user_macro_request_spec.rb +1 -1
- data/spec/support/integration_helper.rb +1 -1
- metadata +12 -12
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.5
|
data/lib/rubix.rb
CHANGED
data/lib/rubix/connection.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'cgi'
|
3
3
|
require 'net/http'
|
4
|
+
require 'net/https'
|
4
5
|
require 'json'
|
5
6
|
|
6
7
|
require 'rubix/log'
|
@@ -127,6 +128,10 @@ module Rubix
|
|
127
128
|
@uri = URI.parse(string)
|
128
129
|
end
|
129
130
|
@server = Net::HTTP.new(uri.host, uri.port)
|
131
|
+
if @uri.scheme == 'https'
|
132
|
+
@server.use_ssl = true
|
133
|
+
end
|
134
|
+
return @server
|
130
135
|
end
|
131
136
|
|
132
137
|
protected
|
@@ -180,7 +185,7 @@ module Rubix
|
|
180
185
|
@request_id += 1
|
181
186
|
begin
|
182
187
|
raw_response = server.request(raw_api_request(raw_params))
|
183
|
-
rescue NoMethodError, SocketError => e
|
188
|
+
rescue NoMethodError, Errno::ECONNREFUSED, SocketError => e
|
184
189
|
raise RequestError.new("Could not connect to Zabbix server at #{host_with_port}")
|
185
190
|
end
|
186
191
|
raw_response
|
@@ -202,7 +207,7 @@ module Rubix
|
|
202
207
|
# @request_id += 1
|
203
208
|
begin
|
204
209
|
raw_response = server.request(raw_web_request(verb, path, data))
|
205
|
-
rescue NoMethodError, SocketError => e
|
210
|
+
rescue NoMethodError, Errno::ECONNREFUSED, SocketError => e
|
206
211
|
raise RequestError.new("Could not connect to the Zabbix server at #{host_with_port}")
|
207
212
|
end
|
208
213
|
end
|
data/lib/rubix/log.rb
CHANGED
@@ -30,7 +30,7 @@ module Rubix
|
|
30
30
|
#
|
31
31
|
# Will attempt to read from
|
32
32
|
#
|
33
|
-
# - <tt>Settings[:log_level]</tt> if <tt>Settings</tt> is defined (see Configliere[
|
33
|
+
# - <tt>Settings[:log_level]</tt> if <tt>Settings</tt> is defined (see Configliere[https://github.com/infochimps-labs/configliere])
|
34
34
|
# - the <tt>RUBIX_LOG_LEVEL</tt> environment variable if defined
|
35
35
|
#
|
36
36
|
# The default is 'info'.
|
@@ -57,7 +57,7 @@ module Rubix
|
|
57
57
|
#
|
58
58
|
# Will attempt to read from
|
59
59
|
#
|
60
|
-
# - <tt>Settings[:log]</tt> if <tt>Settings</tt> is defined (see Configliere[
|
60
|
+
# - <tt>Settings[:log]</tt> if <tt>Settings</tt> is defined (see Configliere[https://github.com/infochimps-labs/configliere])
|
61
61
|
# - the <tt>RUBIX_LOG_PATH</tt> environment variable if defined
|
62
62
|
#
|
63
63
|
# Defaults to writing <tt>stdout</tt>.
|
data/lib/rubix/models/host.rb
CHANGED
@@ -10,7 +10,7 @@ module Rubix
|
|
10
10
|
# server.
|
11
11
|
BLANK_IP = '0.0.0.0'
|
12
12
|
|
13
|
-
# The default port.
|
13
|
+
# The default port on the Host at which Zabbix agent is listening.
|
14
14
|
DEFAULT_PORT = 10050
|
15
15
|
|
16
16
|
# The numeric codes for the various status types.
|
@@ -23,7 +23,27 @@ module Rubix
|
|
23
23
|
:proxy_active => 5,
|
24
24
|
:proxy_passive => 6
|
25
25
|
}
|
26
|
+
|
27
|
+
# The numeric codes for IPMI authentication algorithms.
|
28
|
+
zabbix_define :IPMI_AUTH, {
|
29
|
+
:default => -1,
|
30
|
+
:none => 0,
|
31
|
+
:md2 => 1,
|
32
|
+
:md5 => 2,
|
33
|
+
:straight => 4,
|
34
|
+
:oem => 5,
|
35
|
+
:rmcp_plus => 6
|
36
|
+
}
|
26
37
|
|
38
|
+
# The numeric codes for IPMI priviledge levels.
|
39
|
+
zabbix_define :IPMI_PRIVILEGE, {
|
40
|
+
:callback => 1,
|
41
|
+
:user => 2,
|
42
|
+
:operator => 3,
|
43
|
+
:admin => 4,
|
44
|
+
:oem => 5
|
45
|
+
}
|
46
|
+
|
27
47
|
zabbix_attr :name
|
28
48
|
zabbix_attr :ip
|
29
49
|
zabbix_attr :port
|
@@ -32,6 +52,13 @@ module Rubix
|
|
32
52
|
zabbix_attr :status
|
33
53
|
zabbix_attr :use_ip, :default => true
|
34
54
|
zabbix_attr :monitored, :default => true
|
55
|
+
zabbix_attr :use_ipmi, :default => false
|
56
|
+
zabbix_attr :ipmi_port, :default => 623
|
57
|
+
zabbix_attr :ipmi_username
|
58
|
+
zabbix_attr :ipmi_password
|
59
|
+
zabbix_attr :ipmi_ip
|
60
|
+
zabbix_attr :ipmi_authtype
|
61
|
+
zabbix_attr :ipmi_privilege, :default => :user
|
35
62
|
|
36
63
|
def initialize properties={}
|
37
64
|
super(properties)
|
@@ -56,6 +83,11 @@ module Rubix
|
|
56
83
|
@monitored = true
|
57
84
|
end
|
58
85
|
|
86
|
+
def use_ipmi
|
87
|
+
return @use_ipmi if (!@use_ipmi.nil?)
|
88
|
+
@use_ipmi = false
|
89
|
+
end
|
90
|
+
|
59
91
|
#
|
60
92
|
# == Associations ==
|
61
93
|
#
|
@@ -70,6 +102,11 @@ module Rubix
|
|
70
102
|
|
71
103
|
def validate
|
72
104
|
raise ValidationError.new("A host must have at least one host group.") if host_group_ids.nil? || host_group_ids.empty?
|
105
|
+
raise ValidationError.new("A host must have a valid ip address if use_ip is set.") if use_ip && ip == self.class::BLANK_IP
|
106
|
+
raise ValidationError.new("A host must have an ip address if use_ip is set.") if use_ip && (ip.nil? || ip.empty?)
|
107
|
+
raise ValidationError.new("A host must have a dns name if use_ip is false.") if !use_ip && dns.nil?
|
108
|
+
raise ValidationError.new("A host must have a ipmi_privilege defined as one of: " + self.class::IPMI_PRIVILEGE_CODES.keys.to_s) if use_ipmi && self.class::IPMI_PRIVILEGE_CODES[ipmi_privilege].nil?
|
109
|
+
raise ValidationError.new("A host must have a ipmi_authtype defined as one of: " + self.class::IPMI_AUTH_CODES.keys.to_s) if use_ipmi && self.class::IPMI_AUTH_CODES[ipmi_authtype].nil?
|
73
110
|
true
|
74
111
|
end
|
75
112
|
|
@@ -85,21 +122,26 @@ module Rubix
|
|
85
122
|
:macros => user_macro_params
|
86
123
|
}.tap do |hp|
|
87
124
|
hp[:profile] = profile if profile
|
125
|
+
hp[:profile].delete("hostid") if hp[:profile] && hp[:profile]["hostid"]
|
88
126
|
hp[:status] = (monitored ? 0 : 1) unless monitored.nil?
|
89
127
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
128
|
+
# Check to see if use_ip is set, otherwise we will use dns
|
129
|
+
hp[:useip] = (use_ip == true ? 1 : 0)
|
130
|
+
|
131
|
+
# if we have an IP then use it, otherwise use 0.0.0.0, same goes for the port
|
132
|
+
hp[:ip] = ip || self.class::BLANK_IP
|
133
|
+
hp[:port] = port || self.class::DEFAULT_PORT
|
134
|
+
|
135
|
+
# Always allow for a DNS record to exist even if we dont use it to monitor.
|
136
|
+
hp[:dns] = dns if dns
|
137
|
+
|
138
|
+
hp[:useipmi] = (use_ipmi == true ? 1 : 0)
|
139
|
+
hp[:ipmi_port] = ipmi_port if ipmi_port
|
140
|
+
hp[:ipmi_username] = ipmi_username if ipmi_username
|
141
|
+
hp[:ipmi_password] = ipmi_password if ipmi_password
|
142
|
+
hp[:ipmi_ip] = ipmi_ip if ipmi_ip
|
143
|
+
hp[:ipmi_authtype] = self.class::IPMI_AUTH_CODES[ipmi_authtype] if ipmi_authtype
|
144
|
+
hp[:ipmi_privilege] = self.class::IPMI_PRIVILEGE_CODES[ipmi_privilege] if ipmi_privilege
|
103
145
|
end
|
104
146
|
end
|
105
147
|
|
@@ -132,6 +174,7 @@ module Rubix
|
|
132
174
|
end
|
133
175
|
|
134
176
|
def self.build host
|
177
|
+
host['profile'].delete('hostid') if host.is_a?(Hash) && host['profile'].is_a?(Hash) && host['profile']['hostid']
|
135
178
|
new({
|
136
179
|
:id => host[id_field].to_i,
|
137
180
|
:name => host['host'],
|
@@ -142,13 +185,20 @@ module Rubix
|
|
142
185
|
:port => host['port'],
|
143
186
|
:ip => host['ip'],
|
144
187
|
:dns => host['dns'],
|
145
|
-
:use_ip => (host['useip'].to_i ==
|
188
|
+
:use_ip => (host['useip'].to_i == 1),
|
146
189
|
|
147
190
|
# If the status is '1' then this is an unmonitored host.
|
148
191
|
# Otherwise it's either '0' for monitored and ok or
|
149
192
|
# something else for monitored and *not* ok.
|
150
193
|
:monitored => (host['status'].to_i == 1 ? false : true),
|
151
|
-
:status => self::STATUS_NAMES[host['status'].to_i]
|
194
|
+
:status => self::STATUS_NAMES[host['status'].to_i],
|
195
|
+
:use_ipmi => (host['useipmi'].to_i == 1),
|
196
|
+
:ipmi_port => host['ipmi_port'].to_i,
|
197
|
+
:ipmi_username => host['ipmi_username'],
|
198
|
+
:ipmi_password => host['ipmi_password'],
|
199
|
+
:ipmi_ip => host['ipmi_ip'],
|
200
|
+
:ipmi_authtype => self::IPMI_AUTH_NAMES[host['ipmi_authtype'].to_i],
|
201
|
+
:ipmi_privilege => self::IPMI_PRIVILEGE_NAMES[host['ipmi_privilege'].to_i]
|
152
202
|
})
|
153
203
|
end
|
154
204
|
|
@@ -5,7 +5,7 @@ describe "Applications" do
|
|
5
5
|
before do
|
6
6
|
integration_test
|
7
7
|
@host_group = ensure_save(Rubix::HostGroup.new(:name => 'rubix_spec_host_group_1'))
|
8
|
-
@host = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group]))
|
8
|
+
@host = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group], :ip => '123.123.123.123'))
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
@@ -4,7 +4,7 @@ describe "Hosts" do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
integration_test
|
7
|
-
@host_group_1 = ensure_save(Rubix::HostGroup.new(:name => 'rubix_spec_host_group_1'))
|
7
|
+
@host_group_1 = ensure_save(Rubix::HostGroup.new(:name => 'rubix_spec_host_group_1', :ip => '123.123.123.123'))
|
8
8
|
end
|
9
9
|
|
10
10
|
after do
|
@@ -26,10 +26,11 @@ describe "Hosts" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "can be created" do
|
29
|
-
host = Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group_1])
|
29
|
+
host = Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group_1], :ip => '123.123.123.123')
|
30
30
|
host.save.should be_true
|
31
31
|
host.monitored.should be_true
|
32
32
|
host.use_ip.should be_true
|
33
|
+
host.ip.should == '123.123.123.123'
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -5,8 +5,8 @@ describe "Items" do
|
|
5
5
|
before do
|
6
6
|
integration_test
|
7
7
|
@host_group = ensure_save(Rubix::HostGroup.new(:name => 'rubix_spec_host_group_1'))
|
8
|
-
@host_1 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group]))
|
9
|
-
@host_2 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_2', :host_groups => [@host_group]))
|
8
|
+
@host_1 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group], :ip => '123.123.123.123'))
|
9
|
+
@host_2 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_2', :host_groups => [@host_group], :ip => '123.123.123.124'))
|
10
10
|
@app_1 = ensure_save(Rubix::Application.new(:name => 'rubix_spec_app_1', :host_id => @host_1.id))
|
11
11
|
@app_2 = ensure_save(Rubix::Application.new(:name => 'rubix_spec_app_1', :host_id => @host_2.id))
|
12
12
|
end
|
@@ -5,7 +5,7 @@ describe "TimeSeries" do
|
|
5
5
|
before do
|
6
6
|
integration_test
|
7
7
|
@host_group = ensure_save(Rubix::HostGroup.new(:name => 'rubix_spec_host_group_1'))
|
8
|
-
@host = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group]))
|
8
|
+
@host = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group], :ip => '123.123.123.123'))
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
@@ -11,8 +11,8 @@ describe "Triggers" do
|
|
11
11
|
@template_item_1 = ensure_save(Rubix::Item.new(:key => 'rubix.spec1', :description => 'rubix template item description 1', :host_id => @template_1.id, :value_type => :character))
|
12
12
|
@template_item_2 = ensure_save(Rubix::Item.new(:key => 'rubix.spec2', :description => 'rubix template item description 2', :host_id => @template_2.id, :value_type => :character))
|
13
13
|
|
14
|
-
@host_1 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group]))
|
15
|
-
@host_2 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_2', :host_groups => [@host_group]))
|
14
|
+
@host_1 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group], :ip => '123.123.123.123'))
|
15
|
+
@host_2 = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_2', :host_groups => [@host_group], :ip => '123.123.123.124'))
|
16
16
|
@host_item_1 = ensure_save(Rubix::Item.new(:key => 'rubix.spec1', :description => 'rubix host item description 1', :host_id => @host_1.id, :value_type => :character))
|
17
17
|
@host_item_2 = ensure_save(Rubix::Item.new(:key => 'rubix.spec2', :description => 'rubix host item description 2', :host_id => @host_2.id, :value_type => :character))
|
18
18
|
end
|
@@ -5,7 +5,7 @@ describe "User Macros" do
|
|
5
5
|
before do
|
6
6
|
integration_test
|
7
7
|
@host_group = ensure_save(Rubix::HostGroup.new(:name => 'rubix_spec_host_group_1'))
|
8
|
-
@host = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group]))
|
8
|
+
@host = ensure_save(Rubix::Host.new(:name => 'rubix_spec_host_1', :host_groups => [@host_group], :ip => '123.123.123.123'))
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &17590460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17590460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mysql2
|
27
|
-
requirement: &
|
27
|
+
requirement: &17589800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17589800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &17589040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - <=
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17589040
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: configliere
|
49
|
-
requirement: &
|
49
|
+
requirement: &17588500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.4.8
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *17588500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: multipart-post
|
60
|
-
requirement: &
|
60
|
+
requirement: &17588120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *17588120
|
69
69
|
description: Rubix provides abstractions for connecting to Zabbix's API, an ORM for
|
70
70
|
wrapping Zabbix resources, a set of scripts for writing data to Zabbix, and a collection
|
71
71
|
of Monitor classes for building periodic monitors.
|