1 %define template postfix
2 %include /usr/lib/rpm/macros.perl
3 Summary: Postifix monitoring with Cacti
4 Name: cacti-template-%{template}
8 Group: Applications/WWW
9 Source0: http://forums.cacti.net/download/file.php?id=4091#/postfix_mailserver.tar.gz
10 # Source0-md5: 3cd539df3669c72b0679f18cbf74f164
11 URL: http://forums.cacti.net/about6657.html
12 BuildRequires: rpm-perlprov >= 4.1-13
13 BuildRequires: rpmbuild(macros) >= 1.554
16 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
18 %define cactidir /usr/share/cacti
19 %define resourcedir %{cactidir}/resource
20 %define scriptsdir %{cactidir}/scripts
21 %define snmpdconfdir /etc/snmp
22 %define _libdir %{_prefix}/lib
23 %define dbfile /var/spool/postfix/mailstats.db
24 %define agentscript %{_libdir}/snmpd-agent-cacti_postfix
25 # This is officially registered: http://www.oid-info.com/get/1.3.6.1.4.1.16606
26 %define snmpoid .1.3.6.1.4.1.16606.2
29 Postifix monitoring with Cacti.
31 %package -n net-snmp-agent-cacti_postfix
32 Summary: SNMPd agent to provide Postfix stats
33 Group: Networking/Daemons
36 %description -n net-snmp-agent-cacti_postfix
37 SNMPd agent to provide Postfix stats for cacti.
43 rm -rf $RPM_BUILD_ROOT
44 install -d $RPM_BUILD_ROOT{%{resourcedir},%{scriptsdir},%{snmpdconfdir},%{_libdir}}
45 cp -a *.xml $RPM_BUILD_ROOT%{resourcedir}
46 install -p fetch_mail_statistics.pl $RPM_BUILD_ROOT%{agentscript}
48 install -d $RPM_BUILD_ROOT$(dirname %{dbfile})
49 touch $RPM_BUILD_ROOT%{dbfile}
52 rm -rf $RPM_BUILD_ROOT
55 %cacti_import_template %{resourcedir}/cacti_host_template_postfix_mailserver.xml
57 %post -n net-snmp-agent-cacti_postfix
58 if ! grep -qF %{snmpoid} %{snmpdconfdir}/snmpd.local.conf; then
59 echo "extend %{snmpoid} cacti_postfix %{agentscript} /var/log/maillog %{dbfile} %{snmpoid}" >> %{snmpdconfdir}/snmpd.local.conf
60 %service -q snmpd reload
63 %preun -n net-snmp-agent-cacti_postfix
65 if [ -f %{snmpdconfdir}/snmpd.local.conf ]; then
66 %{__sed} -i -e "/extend %(echo %{snmpoid} | sed -e 's,\.,\\.,g')/d" %{snmpdconfdir}/snmpd.local.conf
67 %service -q snmpd reload
72 %defattr(644,root,root,755)
75 %files -n net-snmp-agent-cacti_postfix
76 %defattr(644,root,root,755)
77 %attr(755,root,root) %{agentscript}
78 %ghost %attr(700,root,root) %{dbfile}