rubicante 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/README.txt +5 -0
- data/lib/rubicante.rb +1 -1
- data/lib/rubicante/cli.rb +7 -0
- data/lib/rubicante/environment.rb +10 -0
- data/lib/rubicante/host.rb +43 -0
- data/lib/rubicante/host_error.rb +2 -1
- data/spec/host_error_spec.rb +13 -3
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -16,6 +16,7 @@ and receive answers.
|
|
16
16
|
* Describe a network of computer systems
|
17
17
|
* Hosts
|
18
18
|
* Ports it should be listening on
|
19
|
+
* Win32 services provided
|
19
20
|
* Critical web sites hosted
|
20
21
|
* Query the network
|
21
22
|
* What is wrong: returns items (hosts, websites) that are not functioning
|
@@ -81,6 +82,10 @@ Use the '-d' flag when executing Rubicante to obtain debug output.
|
|
81
82
|
* Defines host <hostname> (if not previously defined) and registers the website a <fqdn> with it
|
82
83
|
* Example:
|
83
84
|
host www provides website www.example.com
|
85
|
+
* Host <hostname> [provides] service <win32 service name>
|
86
|
+
* Defined host <hostname> (if not previously defined) and registers the Win32 service name with it
|
87
|
+
* Example:
|
88
|
+
host sql provides service MSSQLSERVER
|
84
89
|
* Host <hostname> [listens] [on] port <port #>
|
85
90
|
* Defined host <hostname> (if not previously defined) and registers the port <port #> to it
|
86
91
|
* Example:
|
data/README.txt
CHANGED
@@ -16,6 +16,7 @@ and receive answers.
|
|
16
16
|
* Describe a network of computer systems
|
17
17
|
* Hosts
|
18
18
|
* Ports it should be listening on
|
19
|
+
* Win32 services provided
|
19
20
|
* Critical web sites hosted
|
20
21
|
* Query the network
|
21
22
|
* What is wrong: returns items (hosts, websites) that are not functioning
|
@@ -81,6 +82,10 @@ Use the '-d' flag when executing Rubicante to obtain debug output.
|
|
81
82
|
* Defines host <hostname> (if not previously defined) and registers the website a <fqdn> with it
|
82
83
|
* Example:
|
83
84
|
host www provides website www.example.com
|
85
|
+
* Host <hostname> [provides] service <win32 service name>
|
86
|
+
* Defined host <hostname> (if not previously defined) and registers the Win32 service name with it
|
87
|
+
* Example:
|
88
|
+
host sql provides service MSSQLSERVER
|
84
89
|
* Host <hostname> [listens] [on] port <port #>
|
85
90
|
* Defined host <hostname> (if not previously defined) and registers the port <port #> to it
|
86
91
|
* Example:
|
data/lib/rubicante.rb
CHANGED
data/lib/rubicante/cli.rb
CHANGED
@@ -31,6 +31,7 @@ module Rubicante
|
|
31
31
|
puts_error(resp.hostname, "is unreachable.")
|
32
32
|
else
|
33
33
|
process_port_errors(resp)
|
34
|
+
process_service_errors(resp)
|
34
35
|
process_website_errors(resp)
|
35
36
|
end
|
36
37
|
end
|
@@ -41,6 +42,12 @@ module Rubicante
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
def process_service_errors(resp)
|
46
|
+
resp.bad_services.each do |bad_service|
|
47
|
+
puts_error(resp.hostname, "service #{bad_service} is stopped.")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
def process_website_errors(resp)
|
45
52
|
resp.website_errors.each do |website_error|
|
46
53
|
puts_error(resp.hostname, "is returning code #{website_error.code} for website #{website_error.url}.")
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'rubicante/host_group'
|
2
|
+
require 'os_functions'
|
2
3
|
|
3
4
|
require 'logging'
|
4
5
|
|
5
6
|
module Rubicante
|
6
7
|
class Environment
|
8
|
+
include OsFunctions
|
9
|
+
|
7
10
|
attr_accessor :host
|
8
11
|
|
9
12
|
def initialize
|
@@ -11,6 +14,12 @@ module Rubicante
|
|
11
14
|
|
12
15
|
@log = Logging::Logger[self]
|
13
16
|
|
17
|
+
if is_windows?
|
18
|
+
@log.debug "Detected base operating platform is Windows-based"
|
19
|
+
else
|
20
|
+
@log.debug "Detected base operating platform is NON Windows-based"
|
21
|
+
end
|
22
|
+
|
14
23
|
# Prepare Host logger
|
15
24
|
@appender = Logging::Appender['rubicante']
|
16
25
|
Logging::Logger['Rubicante::Host'].add_appenders(Logging::Appender['rubicante']) if not @appender.nil?
|
@@ -39,6 +48,7 @@ module Rubicante
|
|
39
48
|
cmd.gsub!(/^[Hh]ost\s([\S]+)\s/, 'host["\1"]')
|
40
49
|
cmd.gsub!(/website\s([^,]+)/, '.website("\1")')
|
41
50
|
cmd.gsub!(/port\s([^,]+)/, '.port(\1)')
|
51
|
+
cmd.gsub!(/service\s([^,]+)/, '.service("\1")')
|
42
52
|
|
43
53
|
# Clean up some bubble words
|
44
54
|
cmd.gsub!(/listens\son\s/, '')
|
data/lib/rubicante/host.rb
CHANGED
@@ -5,8 +5,14 @@ require 'logging'
|
|
5
5
|
require 'ping'
|
6
6
|
require 'socket'
|
7
7
|
|
8
|
+
require 'os_functions'
|
9
|
+
include OsFunctions
|
10
|
+
require 'win32ole' if is_windows?
|
11
|
+
|
8
12
|
module Rubicante
|
9
13
|
class Host
|
14
|
+
include OsFunctions
|
15
|
+
|
10
16
|
attr_reader :name
|
11
17
|
attr_accessor :ports, :services, :types, :websites
|
12
18
|
|
@@ -132,9 +138,46 @@ module Rubicante
|
|
132
138
|
check_websites do |website_error|
|
133
139
|
result.add(website_error)
|
134
140
|
end
|
141
|
+
|
142
|
+
if is_windows?
|
143
|
+
check_services do |service, response|
|
144
|
+
result.bad_services << service if not response
|
145
|
+
end
|
146
|
+
end
|
135
147
|
end
|
136
148
|
|
137
149
|
return result
|
138
150
|
end
|
151
|
+
|
152
|
+
###
|
153
|
+
# Windows-specific functions
|
154
|
+
###
|
155
|
+
if is_windows?
|
156
|
+
def get_wmi
|
157
|
+
WIN32OLE.connect("winmgmts://#{@name}")
|
158
|
+
end
|
159
|
+
|
160
|
+
# Checks the host to see if the specified service is running
|
161
|
+
def is_running?(service)
|
162
|
+
query = "SELECT Name, State FROM Win32_Service WHERE Name='#{service}'"
|
163
|
+
|
164
|
+
result = false
|
165
|
+
service_label = "#{@name}->#{service}"
|
166
|
+
|
167
|
+
@log.debug "Checking services #{service_label}..."
|
168
|
+
get_wmi.ExecQuery(query).each do |result|
|
169
|
+
@log.debug "#{service_label}.State == #{result.State}"
|
170
|
+
result = true if result.State = 'Running'
|
171
|
+
end
|
172
|
+
|
173
|
+
return result
|
174
|
+
end
|
175
|
+
|
176
|
+
def check_services
|
177
|
+
@services.each do |service|
|
178
|
+
yield service, is_running?(service)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
139
182
|
end
|
140
183
|
end
|
data/lib/rubicante/host_error.rb
CHANGED
@@ -3,12 +3,13 @@ require 'rubicante/website_error'
|
|
3
3
|
module Rubicante
|
4
4
|
class HostError
|
5
5
|
attr_reader :hostname, :website_errors
|
6
|
-
attr_accessor :bad_ports, :ping
|
6
|
+
attr_accessor :bad_ports, :bad_services, :ping
|
7
7
|
|
8
8
|
def initialize(hostname)
|
9
9
|
@hostname = hostname
|
10
10
|
@ping = false
|
11
11
|
@bad_ports = []
|
12
|
+
@bad_services = []
|
12
13
|
@website_errors = []
|
13
14
|
end
|
14
15
|
|
data/spec/host_error_spec.rb
CHANGED
@@ -54,8 +54,18 @@ describe "An error with a host" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should allow appending to bad_ports" do
|
57
|
-
|
58
|
-
@host_error.bad_ports <<
|
59
|
-
@host_error.bad_ports.include?(
|
57
|
+
new_bad_port = 80
|
58
|
+
@host_error.bad_ports << new_bad_port
|
59
|
+
@host_error.bad_ports.include?(new_bad_port).should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should have an empty array of bad_services by default" do
|
63
|
+
@host_error.bad_services.should == []
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow appending to bad_services" do
|
67
|
+
new_bad_service = 'W32Time'
|
68
|
+
@host_error.bad_services << new_bad_service
|
69
|
+
@host_error.bad_services.include?(new_bad_service).should == true
|
60
70
|
end
|
61
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubicante
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam VanderHook
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-10 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|