]>
Commit | Line | Data |
---|---|---|
f05ac46b | 1 | %define template mail_statistics |
886f2a9e | 2 | %include /usr/lib/rpm/macros.perl |
f05ac46b | 3 | Summary: Mail logs Graphing with Cacti |
886f2a9e ER |
4 | Name: cacti-template-%{template} |
5 | Version: 0.1 | |
f05ac46b | 6 | Release: 0.6 |
886f2a9e ER |
7 | License: GPL v2 |
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 | |
f05ac46b ER |
12 | Patch0: cachetime.patch |
13 | Patch1: more-matches.patch | |
886f2a9e ER |
14 | BuildRequires: rpm-perlprov >= 4.1-13 |
15 | BuildRequires: rpmbuild(macros) >= 1.554 | |
16 | Requires: cacti | |
17 | BuildArch: noarch | |
18 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
19 | ||
20 | %define cactidir /usr/share/cacti | |
21 | %define resourcedir %{cactidir}/resource | |
22 | %define scriptsdir %{cactidir}/scripts | |
23 | %define snmpdconfdir /etc/snmp | |
24 | %define _libdir %{_prefix}/lib | |
b110e13e | 25 | %define dbfile /var/spool/postfix/mailstats.db |
f05ac46b | 26 | %define agentscript %{_libdir}/snmpd-agent-cacti-mail_statistics |
886f2a9e ER |
27 | # This is officially registered: http://www.oid-info.com/get/1.3.6.1.4.1.16606 |
28 | %define snmpoid .1.3.6.1.4.1.16606.2 | |
29 | ||
30 | %description | |
31 | Postifix monitoring with Cacti. | |
32 | ||
f05ac46b ER |
33 | %package -n net-snmp-agent-mail_statistics |
34 | Summary: SNMPd agent to provide mail stats | |
886f2a9e ER |
35 | Group: Networking/Daemons |
36 | Requires: net-snmp | |
37 | ||
f05ac46b ER |
38 | %description -n net-snmp-agent-mail_statistics |
39 | SNMPd agent to provide mail stats for Cacti. | |
886f2a9e ER |
40 | |
41 | %prep | |
42 | %setup -qc | |
f05ac46b ER |
43 | %patch0 -p1 |
44 | %patch1 -p1 | |
886f2a9e ER |
45 | |
46 | %install | |
47 | rm -rf $RPM_BUILD_ROOT | |
48 | install -d $RPM_BUILD_ROOT{%{resourcedir},%{scriptsdir},%{snmpdconfdir},%{_libdir}} | |
49 | cp -a *.xml $RPM_BUILD_ROOT%{resourcedir} | |
b110e13e ER |
50 | install -p fetch_mail_statistics.pl $RPM_BUILD_ROOT%{agentscript} |
51 | # ghost the dbfile | |
52 | install -d $RPM_BUILD_ROOT$(dirname %{dbfile}) | |
53 | touch $RPM_BUILD_ROOT%{dbfile} | |
886f2a9e ER |
54 | |
55 | %clean | |
56 | rm -rf $RPM_BUILD_ROOT | |
57 | ||
58 | %post | |
59 | %cacti_import_template %{resourcedir}/cacti_host_template_postfix_mailserver.xml | |
60 | ||
f05ac46b | 61 | %post -n net-snmp-agent-mail_statistics |
886f2a9e | 62 | if ! grep -qF %{snmpoid} %{snmpdconfdir}/snmpd.local.conf; then |
b110e13e | 63 | echo "extend %{snmpoid} cacti_postfix %{agentscript} /var/log/maillog %{dbfile} %{snmpoid}" >> %{snmpdconfdir}/snmpd.local.conf |
886f2a9e ER |
64 | %service -q snmpd reload |
65 | fi | |
66 | ||
f05ac46b | 67 | %preun -n net-snmp-agent-mail_statistics |
886f2a9e ER |
68 | if [ "$1" = 0 ]; then |
69 | if [ -f %{snmpdconfdir}/snmpd.local.conf ]; then | |
70 | %{__sed} -i -e "/extend %(echo %{snmpoid} | sed -e 's,\.,\\.,g')/d" %{snmpdconfdir}/snmpd.local.conf | |
71 | %service -q snmpd reload | |
72 | fi | |
73 | fi | |
74 | ||
75 | %files | |
76 | %defattr(644,root,root,755) | |
77 | %{resourcedir}/*.xml | |
78 | ||
f05ac46b | 79 | %files -n net-snmp-agent-mail_statistics |
886f2a9e | 80 | %defattr(644,root,root,755) |
b110e13e ER |
81 | %attr(755,root,root) %{agentscript} |
82 | %ghost %attr(700,root,root) %{dbfile} |