1 %define template mail_statistics
2 Summary: Mail logs Graphing with Cacti
3 Name: cacti-template-%{template}
7 Group: Applications/WWW
8 Source0: http://forums.cacti.net/download/file.php?id=4091#/postfix_mailserver.tar.gz
9 # Source0-md5: 3cd539df3669c72b0679f18cbf74f164
10 URL: http://forums.cacti.net/about6657.html
11 Patch0: cachetime.patch
12 Patch1: more-matches.patch
13 BuildRequires: rpm-perlprov >= 4.1-13
14 BuildRequires: rpmbuild(macros) >= 1.554
17 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
19 %define cactidir /usr/share/cacti
20 %define resourcedir %{cactidir}/resource
21 %define scriptsdir %{cactidir}/scripts
22 %define snmpdconfdir /etc/snmp
23 %define _libdir %{_prefix}/lib
24 %define dbfile /var/spool/postfix/mailstats.db
25 %define agentscript %{_libdir}/snmpd-agent-cacti-mail_statistics
26 # This is officially registered: http://www.oid-info.com/get/1.3.6.1.4.1.16606
27 %define snmpoid .1.3.6.1.4.1.16606.2
30 Postifix monitoring with Cacti.
32 %package -n net-snmp-agent-mail_statistics
33 Summary: SNMPd agent to provide mail stats
34 Group: Networking/Daemons
37 %description -n net-snmp-agent-mail_statistics
38 SNMPd agent to provide mail stats for Cacti.
46 rm -rf $RPM_BUILD_ROOT
47 install -d $RPM_BUILD_ROOT{%{resourcedir},%{scriptsdir},%{snmpdconfdir},%{_libdir}}
48 cp -a *.xml $RPM_BUILD_ROOT%{resourcedir}
49 install -p fetch_mail_statistics.pl $RPM_BUILD_ROOT%{agentscript}
51 install -d $RPM_BUILD_ROOT$(dirname %{dbfile})
52 touch $RPM_BUILD_ROOT%{dbfile}
55 rm -rf $RPM_BUILD_ROOT
58 %cacti_import_template %{resourcedir}/cacti_host_template_postfix_mailserver.xml
60 %post -n net-snmp-agent-mail_statistics
61 if ! grep -qF %{snmpoid} %{snmpdconfdir}/snmpd.local.conf; then
62 echo "pass %{snmpoid} cacti_postfix %{agentscript} /var/log/maillog %{dbfile} %{snmpoid}" >> %{snmpdconfdir}/snmpd.local.conf
63 %service -q snmpd reload
66 %preun -n net-snmp-agent-mail_statistics
68 if [ -f %{snmpdconfdir}/snmpd.local.conf ]; then
69 %{__sed} -i -e "/pass %(echo %{snmpoid} | sed -e 's,\.,\\.,g')/d" %{snmpdconfdir}/snmpd.local.conf
70 %service -q snmpd reload
75 %defattr(644,root,root,755)
78 %files -n net-snmp-agent-mail_statistics
79 %defattr(644,root,root,755)
80 %attr(755,root,root) %{agentscript}
81 %ghost %attr(700,root,root) %{dbfile}