forked from cloudkick/agent-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostfix_status.rb
executable file
·29 lines (24 loc) · 1.02 KB
/
postfix_status.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
# a) checks if postfix is running. critical if it is not
# b) warns if there are messages in postfix's queue
# c) status ok if postfix is running and b) is 0
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <[email protected]> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return
# ----------------------------------------------------------------------------
postqueue=`which postqueue`.chomp
running=`ps axf |grep postfix |grep -v grep`.chomp
if ( running =~ /^(\d+)\s+(pts|tty|\?)/ )
pid=$1
messages=`#{postqueue} -p |grep -v "Mail queue is empty" |wc -l`.chomp.to_i
if ( messages > 0 )
puts "status warn #{messages} messages in the postfix queue"
else
puts "status ok postfix running on pid #{pid} with no pending messages"
end
else
puts "status critical postfix not running!"
exit 2
end