7 # - 0 to enable the chart
8 # - 1 to disable the chart
10 # try to find the postqueue executable
11 if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
13 postfix_postqueue="`which postqueue 2>/dev/null`"
14 if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
17 for d in /sbin /usr/sbin /usr/local/sbin
19 if [ -x "$d/postqueue" ]
21 postfix_postqueue="$d/postqueue"
28 if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
30 echo >&2 "postfix: cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf"
39 CHART postfix.qemails '' "Postfix Queue Emails" "emails" postfix postfix line 5000 $update_every
40 DIMENSION emails '' absolute-no-interpolation 1 1
41 CHART postfix.qsize '' "Postfix Queue Emails Size" "emails size in KB" postfix postfix area 5001 $update_every
42 DIMENSION size '' absolute 1 1
49 # the first argument to this function is the microseconds since last update
50 # pass this parameter to the BEGIN statement (see bellow).
52 # do all the work to collect / calculate the values
54 # remember: KEEP IT SIMPLE AND SHORT
56 # 1. execute postqueue -p
57 # 2. get the line that begins with --
58 # 3. match the 2 numbers on the line and output 2 lines like these:
59 # local postfix_q_size=NUMBER
60 # local postfix_q_emails=NUMBER
61 # 4. then execute this a script with the eval
63 # be very carefull with eval:
64 # prepare the script and always egrep at the end the lines that are usefull, so that
65 # even if something goes wrong, no other code can be executed
66 eval "`$postfix_postqueue -p |\
68 sed -e "s/-- \([0-9]\+\) Kbytes in \([0-9]\+\) Requests.$/local postfix_q_size=\1\nlocal postfix_q_emails=\2/g" |\
69 egrep "^local postfix_q_(emails|size)=[0-9]+$"`"
71 # write the result of the work.
73 BEGIN postfix.qemails $1
74 SET emails = $postfix_q_emails
76 BEGIN postfix.qsize $1
77 SET size = $postfix_q_size