Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'rubygems'
- require 'json'
- require 'date'
- system 'curl https://xxx/yyy/zzz --cacert xxx.pem --cert xxx.pem --key xxx.pem >> hosts.txt'
- document = JSON.load File.new("hosts.txt")
- file = JSON.load File.new("admins.txt")
- new_file = File.open("newfile.txt", "w")
- personal_data = file['admins'].group_by { |e| e.delete('name') }
- dupa = []
- document['results'].map do |h|
- dupa << h.merge(personal_data[h['name']].first) if personal_data[h['name']]
- end
- #puts dupa
- dupa.each do |a|
- if a["global_status_label"] != "OK"
- last_report = a["last_report"].to_s
- last_report = last_report[0..9]
- date_last_report = Date.parse last_report
- current_Date = Date.today
- difference_dates = (current_Date - date_last_report).to_i
- if difference_dates > 5
- new_file.puts "#{a['name']}t #{difference_dates}"
- end
- end
- end
- new_file.close
- system 'echo "Your server a['name'] is not responding since difference_dates, fix it!" |mailx -s "Warning" anything@anything.com'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement