educatic-info/bin/educatic.rb

45 lines
1009 B
Ruby
Raw Normal View History

2022-11-25 15:17:56 +01:00
#!/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
2022-11-25 15:47:56 +01:00
def check
2022-11-25 15:17:56 +01:00
@services.each_pair do |key, value|
2022-11-25 15:47:56 +01:00
output = []
2022-11-25 15:17:56 +01:00
cmd = "host #{value['ip']}| grep #{value['hostname']}| wc -l"
counter = %x[#{cmd}].to_i
if counter.zero?
2022-11-25 15:47:56 +01:00
output << " Check this:"
output << " * hostname = #{value['hostname']}"
output << " * ip = #{value['ip']}"
2022-11-25 15:17:56 +01:00
end
unless value['todo'].nil?
2022-11-25 15:47:56 +01:00
output << " TODO:"
2022-11-25 15:17:56 +01:00
value['todo'].each_with_index do |line, index|
2022-11-25 15:47:56 +01:00
output << " #{index + 1}. #{line}"
2022-11-25 15:17:56 +01:00
end
end
2022-11-25 15:47:56 +01:00
unless output.size.zero?
puts "==> #{key} [#{value['hetzner']}]"
puts output.join("\n")
end
2022-11-25 15:17:56 +01:00
end
end
def urls
@services.each_pair do |key, value|
puts "#{key.rjust(16)} : #{value['hostname']}"
end
end
end