Guest User

Untitled

a guest
Oct 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class PostfixQeueuePlugin < Scout::Plugin
  2. def build_report
  3. queue_status = `/usr/sbin/postqueue -p`
  4. lines=queue_status.split("\n")
  5.  
  6. reasons=Hash.new(0)
  7. lines.each do |line|
  8. if line =~ /\s(.*)/
  9. if line.match(/:25: (.*)\)/)
  10. reason=$1.downcase.gsub(" ","_")
  11. reasons[reason]+=1
  12. end
  13. end
  14. end
  15.  
  16. summary=lines.last
  17. if queue_status =~ /queue is empty/
  18. outgoing = 0
  19. else
  20. outgoing = summary.match(/in (\d*) request[s]?/i)[1].to_i
  21. end
  22. hash={:queued_total => outgoing}
  23. hash.merge!(reasons)
  24. report(hash)
  25. end
  26. end
Add Comment
Please, Sign In to add comment