3 # the postqueue command
4 # if empty, it will use the one found in the system path
7 # how frequently to collect queue size
8 postfix_update_every=15
12 # - 0 to enable the chart
13 # - 1 to disable the chart
15 # try to find the postqueue executable
16 if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
18 postfix_postqueue="`which postqueue 2>/dev/null`"
19 if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
22 for d in /sbin /usr/sbin /usr/local/sbin
24 if [ -x "$d/postqueue" ]
26 postfix_postqueue="$d/postqueue"
33 if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
35 echo >&2 "$PROGRAM_NAME: postfix: cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf"
44 CHART postfix.qemails '' "Postfix Queue Emails" "emails" postfix postfix line 5000 $postfix_update_every
45 DIMENSION emails '' absolute 1 1
46 CHART postfix.qsize '' "Postfix Queue Emails Size" "emails size in KB" postfix postfix area 5001 $postfix_update_every
47 DIMENSION size '' absolute 1 1
54 # the first argument to this function is the microseconds since last update
55 # pass this parameter to the BEGIN statement (see bellow).
57 # do all the work to collect / calculate the values
59 # remember: KEEP IT SIMPLE AND SHORT
61 # 1. execute postqueue -p
62 # 2. get the line that begins with --
63 # 3. match the 2 numbers on the line and output 2 lines like these:
64 # local postfix_q_size=NUMBER
65 # local postfix_q_emails=NUMBER
66 # 4. then execute this a script with the eval
68 # be very carefull with eval:
69 # prepare the script and always egrep at the end the lines that are usefull, so that
70 # even if something goes wrong, no other code can be executed
74 eval "`$postfix_postqueue -p |\
76 sed -e "s/-- \([0-9]\+\) Kbytes in \([0-9]\+\) Requests.$/local postfix_q_size=\1\nlocal postfix_q_emails=\2/g" |\
77 egrep "^local postfix_q_(emails|size)=[0-9]+$"`"
79 # write the result of the work.
81 BEGIN postfix.qemails $1
82 SET emails = $postfix_q_emails
84 BEGIN postfix.qsize $1
85 SET size = $postfix_q_size