Skip to content

Instantly share code, notes, and snippets.

@andre
Created June 20, 2012 18:26
Show Gist options
  • Save andre/2961413 to your computer and use it in GitHub Desktop.
Save andre/2961413 to your computer and use it in GitHub Desktop.
Postfix plugins for Scout (untested)
class PostfixQeueuePlugin < Scout::Plugin
def build_report
queue_status = `/usr/sbin/postqueue -p`
lines=queue_status.split("\n")
reasons=Hash.new(0)
lines.each do |line|
if line =~ /\s(.*)/
if line.match(/:25: (.*)\)/)
reason=$1.downcase.gsub(" ","_")
reasons[reason]+=1
end
end
end
summary=lines.last
if queue_status =~ /queue is empty/
outgoing = 0
else
outgoing = summary.match(/in (\d*) request[s]?/i)[1].to_i
end
hash={:queued_total => outgoing}
hash.merge!(reasons)
report(hash)
end
end
class PostfixStatusPlugin < Scout::Plugin
def build_report
postfix = `sudo /etc/init.d/postfix status`
if postfix !~ /postfix is running/
report(:status => 'ERR')
alert('Postfix not running!')
else
report(:status => 'OK')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment