Created
July 24, 2014 04:23
-
-
Save mkhairi/b89119978384de8d7b95 to your computer and use it in GitHub Desktop.
check match record from list and dig result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
@servers =["server_ip1","server_ip2", "server_ip3"] | |
list = {} | |
host = [] | |
result = {} | |
CSV.foreach("mx_records.csv") do |row| | |
#puts row[0] | |
if host.include?row[0] | |
r = result[row[0]] | |
else | |
host << row[0] | |
result[row[0]] = [] | |
r = result[row[0]] | |
end | |
#puts r | |
r << "#{row[2]} #{row[3]}" | |
result[row[0]] = r | |
#puts "hash result #{result[row[0]]}" | |
end | |
#puts result | |
xserver = [] | |
xhost = [] | |
count = 0 | |
data ={} | |
result.map do |k,v| | |
@servers.each do |s| | |
puts "dig @#{s} #{k} MX +short" | |
d = %x{dig @#{s} #{k} MX +short} | |
puts "====result====-" | |
dig_result = d.split("\n").map!{|c| c.downcase.strip} | |
excel_value = v.map!{|c| c.downcase.strip} | |
a = dig_result - excel_value | |
puts "dig result #{dig_result}" | |
puts "excel result #{excel_value}" | |
if a.any? | |
xhost << ["server: #{s}","host: #{k}", "diff: #{a}"] | |
count +=1 | |
end | |
end | |
#puts "key #{k}" | |
#puts "value #{v}" | |
#sleep 1 | |
puts "current count mx records not match =====: #{count}" | |
end | |
puts "=======end result=-======" | |
puts xhost | |
puts "Total #{count}" | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment