45 lines
1009 B
Ruby
45 lines
1009 B
Ruby
#!/usr/bin/env ruby
|
|
|
|
require "yaml"
|
|
require "colorize"
|
|
|
|
class Educatic
|
|
attr_reader :settings
|
|
|
|
def initialize(filename)
|
|
@settings = YAML.load(File.read(filename))
|
|
@services = settings["services"]
|
|
end
|
|
|
|
def check
|
|
@services.each_pair do |key, value|
|
|
output = []
|
|
|
|
cmd = "host #{value['ip']}| grep #{value['hostname']}| wc -l"
|
|
counter = %x[#{cmd}].to_i
|
|
if counter.zero?
|
|
output << " Check this:"
|
|
output << " * hostname = #{value['hostname']}"
|
|
output << " * ip = #{value['ip']}"
|
|
end
|
|
unless value['todo'].nil?
|
|
output << " TODO:"
|
|
value['todo'].each_with_index do |line, index|
|
|
output << " #{index + 1}. #{line}"
|
|
end
|
|
end
|
|
|
|
unless output.size.zero?
|
|
puts "==> #{key} [#{value['hetzner']}]"
|
|
puts output.join("\n")
|
|
end
|
|
end
|
|
end
|
|
|
|
def urls
|
|
@services.each_pair do |key, value|
|
|
puts "#{key.rjust(16)} : #{value['hostname']}"
|
|
end
|
|
end
|
|
end
|