Guest User

Untitled

a guest
Jun 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. def parsenagios
  2. hosts = {}
  3. hostname = ""
  4. fh = File.new("/home/ale/Tmp/confgen/status.log")
  5. fh.each_line { |l|
  6. if l =~ /host_name=([a-zA-Z0-9\.-]+)$/
  7. hostname = $1
  8. hosts[hostname] = {}
  9. end
  10. if l =~ /current_state=(\d)/
  11. hosts[hostname]["state"] = $1
  12. end
  13. if l =~ /last_time_up=(\d+)$/
  14. up = $1.to_i
  15. time_up = Time.at(up)
  16. time_diff = Time.now - time_up
  17. metric_diff = time_diff.to_i / 86400
  18. if metric_diff > 5
  19. hosts[hostname]["nuked"] = true
  20. p hosts
  21. else
  22. hosts[hostname]["nuked"] = false
  23. end
  24. end
  25. }
  26. hosts
  27. end
Add Comment
Please, Sign In to add comment