diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2014-05-20 23:43:32 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2014-05-20 23:43:32 +0300 |
commit | cd2ccf2523630be775ed264fcc6c57a7ad35b64e (patch) | |
tree | 7e50b031baa0d24053a40d5c2613fb803fed5536 /charts.d/postfix.chart.sh | |
parent | 6a80b38554884a2fc49444806cb2492377d126af (diff) |
postqueue charts
Diffstat (limited to 'charts.d/postfix.chart.sh')
-rwxr-xr-x | charts.d/postfix.chart.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh new file mode 100755 index 0000000000..fff7c31539 --- /dev/null +++ b/charts.d/postfix.chart.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +postfix_postqueue= + +postfix_check() { + # this should return: + # - 0 to enable the chart + # - 1 to disable the chart + + # try to find the postqueue executable + if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ] + then + postfix_postqueue="`which postqueue 2>/dev/null`" + if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ] + then + local d= + for d in /sbin /usr/sbin /usr/local/sbin + do + if [ -x "$d/postqueue" ] + then + postfix_postqueue="$d/postqueue" + break + fi + done + fi + fi + + if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ] + then + echo >&2 "Cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf" + return 1 + fi + + return 0 +} + +postfix_create() { +cat <<EOF +CHART postfix.qemails '' "Postfix Queue Emails" "emails" postfix postfix line 5000 $update_every +DIMENSION emails '' absolute-no-interpolation 1 1 +CHART postfix.qsize '' "Postfix Queue Emails Size" "emails size in KB" postfix postfix area 5001 $update_every +DIMENSION size '' absolute 1 1 +EOF + + return 0 +} + +postfix_update() { + # do all the work to collect / calculate the values + # for each dimension + # remember: KEEP IT SIMPLE AND SHORT + + eval `$postfix_postqueue -p | grep "^--" | sed -e "s/-- \([0-9]\+\) Kbytes in \([0-9]\+\) Requests.$/local postfix_q_size=\1\nlocal postfix_q_emails=\2/g" | grep "^local postfix_q_"` + test -z "$postfix_q_emails" && local postfix_q_emails=0 + test -z "$postfix_q_size" && local postfix_q_size=0 + + # write the result of the work. + cat <<VALUESEOF +BEGIN postfix.qemails $1 +SET emails = $postfix_q_emails +END +BEGIN postfix.qsize $1 +SET size = $postfix_q_size +END +VALUESEOF + + return 0 +} |