[packages/cacti-template-haproxy] configure agent

glen glen at pld-linux.org
Thu May 12 14:03:36 CEST 2016


commit b685a0c0dafb592870ae9de92a81b471e3595fff
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu May 12 15:03:32 2016 +0300

    configure agent

 cacti-template-haproxy.spec | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/cacti-template-haproxy.spec b/cacti-template-haproxy.spec
index 8e5bba2..19e5514 100644
--- a/cacti-template-haproxy.spec
+++ b/cacti-template-haproxy.spec
@@ -1,12 +1,10 @@
-# TODO
-# - enable agent in snmpd
 %define		plugin haproxy
 %include	/usr/lib/rpm/macros.perl
 Summary:	Template for Cacti - HAProxy
 Name:		cacti-template-%{plugin}
 # version from haproxy.pl
 Version:	0.30
-Release:	0.2
+Release:	0.6
 License:	GPL v2
 Group:		Applications/WWW
 # the templates were last modified Oct 25, 2010, there's no point using newer version tarball
@@ -59,6 +57,27 @@ rm -rf $RPM_BUILD_ROOT
 %cacti_import_template %{resourcedir}/haproxy_frontend.xml
 %cacti_import_template %{resourcedir}/haproxy_socket.xml
 
+%post -n net-snmp-agent-%{plugin}
+if ! grep -q "^disablePerl" %{snmpdconfdir}/snmpd.conf %{snmpdconfdir}/snmpd.local.conf 2>/dev/null; then
+	echo "disablePerl false" >> %{snmpdconfdir}/snmpd.conf
+	reload=1
+fi
+if ! grep -qF '%{_libdir}/snmpd-agent-haproxy' %{snmpdconfdir}/snmpd.local.conf; then
+	echo "perl do '%{_libdir}/snmpd-agent-haproxy';" >> %{snmpdconfdir}/snmpd.local.conf
+	reload=1
+fi
+if [ "$reload" = 1 ]; then
+	%service -q snmpd reload
+fi
+
+%preun -n net-snmp-agent-%{plugin}
+if [ "$1" = 0 ]; then
+	if [ -f %{snmpdconfdir}/snmpd.local.conf ]; then
+		%{__sed} -i -e "/^perl.*%(echo %{_libdir}/snmpd-agent-haproxy | sed -e 's,/,\\/,g')/d" %{snmpdconfdir}/snmpd.local.conf
+		%service -q snmpd reload
+	fi
+fi
+
 %files
 %defattr(644,root,root,755)
 %doc README
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/cacti-template-haproxy.git/commitdiff/b685a0c0dafb592870ae9de92a81b471e3595fff



More information about the pld-cvs-commit mailing list