amiok 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/amiok +10 -0
- data/lib/amiok.rb +78 -0
- metadata +68 -0
data/bin/amiok
ADDED
data/lib/amiok.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
class Amiok
|
2
|
+
POSSIBLE_LOCATIONS = %w(
|
3
|
+
/etc/apache2
|
4
|
+
/etc/httpd
|
5
|
+
)
|
6
|
+
GOOD_RESPONSES = %w(200 301 302 401 403)
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :output
|
10
|
+
end
|
11
|
+
self.output = $stdout
|
12
|
+
|
13
|
+
def apache_directory
|
14
|
+
POSSIBLE_LOCATIONS.find do |path|
|
15
|
+
File.exist?(path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def grep
|
20
|
+
`grep -r -i -e 'server\\(name\\|alias\\)' #{apache_directory} 2> /dev/null`
|
21
|
+
end
|
22
|
+
|
23
|
+
def domains
|
24
|
+
grep.split("\n").inject([]) do |domains, line|
|
25
|
+
config = line.split(':', 2)[-1].strip
|
26
|
+
domain = config.split(' ')[-1]
|
27
|
+
unless config.start_with?('#') or domain.start_with?('_') or domain.include?('example.com')
|
28
|
+
domains << domain
|
29
|
+
end
|
30
|
+
domains
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def curl(domain)
|
35
|
+
`curl -s -I http://#{domain}`
|
36
|
+
end
|
37
|
+
|
38
|
+
def status(domain)
|
39
|
+
if status_line = curl(domain).split("\n")[0]
|
40
|
+
status = status_line.split(' ', 2)[-1]
|
41
|
+
status.split(' ', 2)
|
42
|
+
else
|
43
|
+
['', "Can't find server"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def _failed
|
48
|
+
domains.inject([]) do |failed, domain|
|
49
|
+
status_code, status_message = status(domain)
|
50
|
+
write('.')
|
51
|
+
unless GOOD_RESPONSES.include?(status_code)
|
52
|
+
failed << { 'domain' => domain, 'status_code' => status_code, 'status_message' => status_message }
|
53
|
+
end
|
54
|
+
failed
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def failed
|
59
|
+
@failed ||= _failed
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
just = failed.map { |f| f['domain'].length }.max
|
64
|
+
write("\n")
|
65
|
+
failed.each do |f|
|
66
|
+
write("#{f['domain'].ljust(just + 5)}#{f['status_message']}\n")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def write(str)
|
71
|
+
self.class.output.write(str)
|
72
|
+
self.class.output.flush
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.run(argv)
|
76
|
+
new.run
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amiok
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Manfred Stienstra
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-09-09 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email:
|
23
|
+
- manfred@fngtps.com
|
24
|
+
executables:
|
25
|
+
- amiok
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- bin/amiok
|
32
|
+
- lib/amiok.rb
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: https://github.com/Manfred/amiok
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
version: "0"
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.6.2
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: A small tool to check the status of your Apache vhosts
|
67
|
+
test_files: []
|
68
|
+
|