2 Summary: Template for Cacti - HAProxy
3 Name: cacti-template-%{plugin}
4 # version from haproxy.pl
8 Group: Applications/WWW
9 # the templates were last modified Oct 25, 2010, there's no point using newer version tarball
10 Source0: http://www.haproxy.org/download/1.6/src/haproxy-1.6.3.tar.gz
11 # Source0-md5: 3362d1e268c78155c2474cb73e7f03f9
13 URL: https://github.com/haproxy/haproxy/tree/master/contrib/netsnmp-perl
14 BuildRequires: rpm-perlprov >= 4.1-13
15 BuildRequires: rpmbuild(macros) >= 1.554
16 Requires: cacti >= 0.8.7e-8
18 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
20 %define snmpdconfdir /etc/snmp
21 %define cactidir /usr/share/cacti
22 %define resourcedir %{cactidir}/resource
23 %define scriptsdir %{cactidir}/scripts
24 %define _libdir %{_prefix}/lib
27 Cacti snmp-query definition for backends.
29 %package -n net-snmp-agent-%{plugin}
30 Summary: SNMPd agent to provide HAProxy statistics
31 Group: Networking/Daemons
35 %description -n net-snmp-agent-%{plugin}
36 SNMPd agent to provide HAProxy statistics
40 mv haproxy-*/contrib/netsnmp-perl/* .
44 rm -rf $RPM_BUILD_ROOT
45 install -d $RPM_BUILD_ROOT{%{resourcedir},%{scriptsdir},%{snmpdconfdir},%{_libdir}}
46 cp -p *.xml $RPM_BUILD_ROOT%{resourcedir}
47 install -p haproxy.pl $RPM_BUILD_ROOT%{_libdir}/snmpd-agent-haproxy
50 rm -rf $RPM_BUILD_ROOT
53 %cacti_import_template %{resourcedir}/cacti_data_query_haproxy_backends.xml
54 %cacti_import_template %{resourcedir}/cacti_data_query_haproxy_frontends.xml
55 %cacti_import_template %{resourcedir}/haproxy_backend.xml
56 %cacti_import_template %{resourcedir}/haproxy_frontend.xml
57 %cacti_import_template %{resourcedir}/haproxy_socket.xml
59 %post -n net-snmp-agent-%{plugin}
60 if ! grep -q "^disablePerl" %{snmpdconfdir}/snmpd.conf %{snmpdconfdir}/snmpd.local.conf 2>/dev/null; then
61 echo "disablePerl false" >> %{snmpdconfdir}/snmpd.conf
64 if ! grep -qF '%{_libdir}/snmpd-agent-haproxy' %{snmpdconfdir}/snmpd.local.conf; then
65 echo "perl do '%{_libdir}/snmpd-agent-haproxy';" >> %{snmpdconfdir}/snmpd.local.conf
68 if [ "$reload" = 1 ]; then
69 %service -q snmpd reload
72 %preun -n net-snmp-agent-%{plugin}
74 if [ -f %{snmpdconfdir}/snmpd.local.conf ]; then
75 %{__sed} -i -e "/^perl.*%(echo %{_libdir}/snmpd-agent-haproxy | sed -e 's,/,\\/,g')/d" %{snmpdconfdir}/snmpd.local.conf
76 %service -q snmpd reload
81 %defattr(644,root,root,755)
83 %{resourcedir}/cacti_data_query_haproxy_backends.xml
84 %{resourcedir}/cacti_data_query_haproxy_frontends.xml
85 %{resourcedir}/haproxy_backend.xml
86 %{resourcedir}/haproxy_frontend.xml
87 %{resourcedir}/haproxy_socket.xml
89 %files -n net-snmp-agent-%{plugin}
90 %defattr(644,root,root,755)
91 %attr(755,root,root) %{_libdir}/snmpd-agent-haproxy