From 940eef887f5142d980c91e95193e102c41d18808 Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Thu, 13 Mar 2014 17:01:12 +0530 Subject: all: import plugins/templates/config from github All plugins/templates/config are imported from https://github.com/gluster-rhsc/nagios-plugin.git Change-Id: Icbbf23c0595e2b36548015489341d9ff823bac50 Signed-off-by: Bala.FA Reviewed-on: https://cuckoo.blr.redhat.com:8443/6 --- nagios-server-addons.spec.in | 126 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 2 deletions(-) (limited to 'nagios-server-addons.spec.in') diff --git a/nagios-server-addons.spec.in b/nagios-server-addons.spec.in index 3450ba2..0266936 100644 --- a/nagios-server-addons.spec.in +++ b/nagios-server-addons.spec.in @@ -3,7 +3,11 @@ %global _for_fedora_koji_builds 0 %if ( 0%{?fedora} && 0%{?fedora} > 16 ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) -%global _with_systemd true +%global _with_systemd true +%endif + +%if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) +%global _with_firewalld true %endif # From https://fedoraproject.org/wiki/Packaging:Python#Macros @@ -12,6 +16,22 @@ %{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif +%if ( 0%{?_with_systemd:1} ) +%define _init_enable() /bin/systemctl enable %1.service ; +%define _init_disable() /bin/systemctl disable %1.service ; +%define _init_restart() /bin/systemctl restart %1.service ; +%define _init_try_restart() /bin/systemctl try-restart %1.service ; +%define _init_stop() /bin/systemctl stop %1.service ; +%define _init_install() install -D -p -m 0644 %1 %{buildroot}%{_unitdir}/%2.service ; +%else +%define _init_enable() /sbin/chkconfig --add %1 ; +%define _init_disable() /sbin/chkconfig --del %1 ; +%define _init_restart() /sbin/service %1 restart &>/dev/null ; +%define _init_try_restart() /sbin/service %1 condrestart &>/dev/null ; +%define _init_stop() /sbin/service %1 stop &>/dev/null ; +%define _init_install() install -D -p -m 0755 %1 %{buildroot}%{_sysconfdir}/init.d/%2 ; +%endif + Summary: Gluster node management add-ons for Nagios Name: @PACKAGE_NAME@ Version: @PACKAGE_VERSION@ @@ -24,15 +44,35 @@ Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRequires: pyflakes BuildRequires: python-pep8 +BuildRequires: python-mock BuildRequires: python-nose BuildRequires: python-devel +%if ( 0%{?_with_systemd:1} ) +BuildRequires: systemd-units +Requires(post): systemd-units +%else +Requires(post): /sbin/service +Requires(post): /sbin/chkconfig +%endif +%if ( 0%{?_with_firewalld:1} ) +Requires(post): firewalld +%else +Requires(post): iptables +%endif +Requires: check-mk-livestatus Requires: gluster-nagios-common +Requires: httpd +Requires: nagios +Requires: nagios-plugins-nrpe +Requires: php +Requires: pnp4nagios Requires: python-argparse Requires: python-ethtool Requires: python-netaddr Requires: python-pthreading Requires: python-pyinotify Requires: python-selinux +Requires: rrdtool-perl %description Nagios plugin, scripts, configuration files etc for gluster nodes. @@ -43,6 +83,7 @@ Group: Development/Tools Requires: %{name} = %{version}-%{release} Requires: pyflakes Requires: python-pep8 +Requires: python-mock Requires: python-nose Requires: python-devel @@ -66,9 +107,90 @@ make install DESTDIR=%{buildroot} %clean rm -rf %{buildroot} +%post +NagiosCFGFile="/etc/nagios/nagios.cfg" +sed -i '/etc\/nagios\/objects\/localhost.cfg/d' $NagiosCFGFile + +if grep -q "#process_performance_data=0" $NagiosCFGFile; then + sed -i -e 's/#process_performance_data=0/process_performance_data=1/g' $NagiosCFGFile +elif grep -q "process_performance_data=0" $NagiosCFGFile ; then + sed -i -e 's/process_performance_data=0/process_performance_data=1/g' $NagiosCFGFile +fi + +if grep -q "#enable_environment_macros=0" $NagiosCFGFile; then + sed -i -e 's/#enable_environment_macros=0/enable_environment_macros=1/g' $NagiosCFGFile +elif grep -q "process_performance_data=0" $NagiosCFGFile ; then + sed -i -e 's/process_performance_data=0/process_performance_data=1/g' $NagiosCFGFile +fi + +if ! grep -q "#rhs performance monitoring" $NagiosCFGFile; then +cat >> $NagiosCFGFile <> $CommandFile <> $CommandFile <