57 lines
1.3 KiB
Ruby
57 lines
1.3 KiB
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
|
|
puts " #{Time.now}"
|
|
@services.each_pair do |key, value|
|
|
output = []
|
|
todo = value['todo'] || []
|
|
|
|
check_hostname(value, output: output, todo: todo)
|
|
|
|
unless value['todo'].nil?
|
|
todo.each_with_index do |line, index|
|
|
output << " #{index + 1}. #{line}"
|
|
end
|
|
end
|
|
|
|
unless output.size.zero?
|
|
puts "==> [Hetzner #{value['hetzner'].upcase}] #{key}"
|
|
puts output.join("\n")
|
|
end
|
|
end
|
|
end
|
|
|
|
def show_urls
|
|
@services.each_pair do |key, value|
|
|
puts "#{key.rjust(16)} : #{value['hostname']}"
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def check_hostname(value, output:, todo:)
|
|
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
|
|
|
|
if (value['hostname'].end_with? ".info" or value['hostname'].end_with? "clients.your-server.de")
|
|
todo << "Cambiar <#{value['hostname']}> el dominio @txs.es"
|
|
end
|
|
end
|
|
end
|