Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'rubygems'
  4. require 'json'
  5. require 'date'
  6.  
  7. system 'curl https://xxx/yyy/zzz --cacert xxx.pem --cert xxx.pem --key xxx.pem >> hosts.txt'
  8.  
  9. document = JSON.load File.new("hosts.txt")
  10. file = JSON.load File.new("admins.txt")
  11. new_file = File.open("newfile.txt", "w")
  12. personal_data = file['admins'].group_by { |e| e.delete('name') }
  13.  
  14. dupa = []
  15. document['results'].map do |h|
  16. dupa << h.merge(personal_data[h['name']].first) if personal_data[h['name']]
  17. end
  18.  
  19. #puts dupa
  20. dupa.each do |a|
  21. if a["global_status_label"] != "OK"
  22.  
  23. last_report = a["last_report"].to_s
  24. last_report = last_report[0..9]
  25. date_last_report = Date.parse last_report
  26. current_Date = Date.today
  27. difference_dates = (current_Date - date_last_report).to_i
  28. if difference_dates > 5
  29. new_file.puts "#{a['name']}t #{difference_dates}"
  30. end
  31. end
  32. end
  33. new_file.close
  34.  
  35. 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