Skip to content

Commit

Permalink
add initial support for postfix_mailgraph plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Georg Kahest committed Sep 14, 2017
1 parent 28ebc65 commit f5da571
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ obs_agent_pg_enable: false
obs_agent_apache_enable: false
obs_agent_bind_stats: "/var/cache/bind/named.stats"
obs_agent_bind_enable: false

obs_agent_postfix_enable: false



3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@

- include: tasks/bind.yml
when: obs_agent_bind_enable == true

- include: tasks/postfix.yml
when: obs_agent_postfix_enable == true
14 changes: 14 additions & 0 deletions tasks/postfix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# postfix mailgraph local agent
# TODO: consider modification of /usr/sbin/mailgraph from $rrdstep = 60 to my $rrdstep = 300; in this script,
# requires cleanup of old rrds and restart to mailgraph after
# http://docs.observium.org/apps/#postfix-mailgraph
- name: be sure rrdtool is installed
apt: pkg=rrdtool state=installed
tags: rrdtool

when: ansible_distribution == "Debian"
- name: deploy mailgraph local agent
copy: src=templates/local-agents/postfix_mailgraph dest=/usr/lib/observium_agent/local/postfix_mailgraph owner=root group=root mode=0655


34 changes: 34 additions & 0 deletions templates/local-agents/postfix_mailgraph
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

RRDPATH=/var/lib/mailgraph

RRD_FIELDS=""
RRD_VALUES=""

for FILENAME in mailgraph_greylist.rrd mailgraph.rrd mailgraph_virus.rrd
do

if [ -f $RRDPATH/$FILENAME ];
then
OUTPUT=$(rrdtool lastupdate $RRDPATH/$FILENAME 2>/dev/null)
if [ "$OUTPUT" != "" ];
then
RRD_FIELDS+=$(echo "$OUTPUT"|head -n1)
RRD_VALUES+=$(echo "$OUTPUT"|tail -n1|cut -d: -f2)
fi
fi
done

read -a FIELDS <<< "$RRD_FIELDS"
read -a VALUES <<< "$RRD_VALUES"

if [ ${#FIELDS[@]} != 0 ];
then
echo "<<<postfix_mailgraph>>>"

for i in `seq ${#FIELDS[@]}`
do
echo ${FIELDS[$i-1]}:${VALUES[$i-1]}
done
fi

0 comments on commit f5da571

Please sign in to comment.