Created
June 20, 2012 18:26
-
-
Save andre/2961413 to your computer and use it in GitHub Desktop.
Postfix plugins for Scout (untested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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