educatic-info/test/services.rb

20 lines
498 B
Ruby
Raw Normal View History

2022-11-25 13:07:09 +01:00
#!/usr/bin/env ruby
require "yaml"
filename = File.join(File.dirname(__FILE__), "services.yaml")
settings = YAML.load(File.read(filename))
services = settings["services"]
services.each_pair do |key, value|
print "==> #{key} "
cmd = "host #{value['ip']}| grep #{value['hostname']}| wc -l"
counter = %x[#{cmd}].to_i
if counter.zero?
puts "(ERROR: IP <=> hostname)"
puts " hostname = #{value['hostname']}"
puts " ip = #{value['ip']}"
else
puts "(Ok)"
end
end