%define nagios_uid 64320 %define nagios_gid 64320 %define nagioscmd_gid 64321 Summary: Host/service/network monitoring program Name: nagios Version: 4.0.2 Release: 1 License: GPLv2 Group: Applications/System URL: http://www.nagios.org/ Packager: Michael Perzl Vendor: Michael Perzl Source0: http://downloads.sourceforge.net/nagios/%{name}-%{version}.tar.gz Source2: %{name}.aix.init Patch0: %{name}-%{version}-aix.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: patch BuildRequires: gd-devel >= 2.0.35-5 BuildRequires: httpd-devel >= 2.2.16-1 BuildRequires: libtool-ltdl-devel >= 1.5.26-1 BuildRequires: perl >= 5.8.8 Requires: httpd >= 2.2.16-1 Requires: libtool-ltdl >= 1.5.26-1 Requires: perl >= 5.8.8 %define logdir /var/log/%{name} %define apacheconfdir %{_sysconfdir}/httpd/conf/extra %define apacheuser apache %define apachegroup apache %description Nagios is a program that will monitor hosts and services on your network. It has the ability to send email or page alerts when a problem arises and when a problem is resolved. Nagios is written in C and is designed to run under Linux (and some other *NIX variants) as a background process, intermittently running checks on various services that you specify. The actual service checks are performed by separate "plugin" programs which return the status of the checks to Nagios. The plugins are available at http://sourceforge.net/projects/nagiosplug. This package provides the core program, web interface, and documentation files for Nagios. Development files are built as a separate package. %package gui Summary: Web content for %{name} Group: Applications/System Requires: %{name} = %{version}-%{release} Requires: httpd >= 2.2.16-1 Requires: %{name}-doc Requires: gd >= 2.0.35-5 %description gui This package contains the webgui (html,css,cgi etc.) for %{name}. %package doc Summary: Documentation for %{name} Group: Applications/System %description doc This package provides the online documentation for %{name}. %prep %setup -q export PATH=/opt/freeware/bin:$PATH %patch0 %build export PATH=/opt/freeware/bin:$PATH export CC="xlc_r" export PERL="/opt/freeware/bin/perl" ./configure \ --prefix=%{_prefix} \ --sysconfdir="/etc/%{name}" \ --localstatedir="/var/%{name}" \ --datadir="%{_datadir}/%{name}" \ --libdir="%{_libdir}/%{name}" \ --libexecdir="%{_libdir}/%{name}/plugins" \ --sbindir="%{_libdir}/%{name}/cgi" \ --enable-nanosleep \ --enable-event-broker \ --enable-embedded-perl \ --enable-ssl \ --with-nagios-user="%{name}" \ --with-nagios-group="%{name}" \ --with-command-user="%{name}" \ --with-command-group="nagiscmd" \ --with-web-user="%{apacheuser}" \ --with-web-group="%{apachegroup}" \ --with-mail="/usr/bin/mail" \ --with-httpd-conf=%{apacheconfdir} \ --with-checkresult-dir="/var/%{name}/checkresults" \ --with-temp-dir="/tmp" \ --with-log-dir="%{logdir}" \ --with-init-dir=/etc/rc.d/init.d \ --with-lockfile="/var/%{name}/%{name}.pid" \ --with-gd-lib="%{_libdir}" \ --with-gd-inc="%{_includedir}" \ --with-cgiurl="/%{name}/cgi-bin" \ --with-htmurl="/%{name}" # need to patch and re-run config.status as our perl (compiled with GCC) # pulls in some GCC compile options that IBM XLC/C++ doesn't like cat config.status | \ sed 's|-pipe||g' | \ sed 's|-fno-strict-aliasing||g' | \ sed 's|-Xlinker||g' > config.tmp mv config.tmp config.status chmod 0755 config.status ./config.status gmake %{?_smp_mflags} all %install [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} mkdir -p ${RPM_BUILD_ROOT}%{apacheconfdir} gmake install \ install-init \ install-commandmode \ install-config \ install-webconf \ DESTDIR=${RPM_BUILD_ROOT} \ INSTALL_OPTS="" \ INSTALL_OPTS_WEB="" \ COMMAND_OPTS="" \ INIT_OPTS="" /usr/bin/strip ${RPM_BUILD_ROOT}%{_bindir}/* || : mkdir -p ${RPM_BUILD_ROOT}/etc/%{name}/conf.d # fix log-paths /opt/freeware/bin/perl -pi -e ' s|log_file.*|log_file=%{logdir}/%{name}.log|; s|log_archive_path=.*|log_archive_path=%{logdir}/archives|; s|debug_file=.*|debug_file=%{logdir}/%{name}.debug|; ' ${RPM_BUILD_ROOT}/etc/%{name}/%{name}.cfg # make logdirs mkdir -p ${RPM_BUILD_ROOT}%{logdir}/archives cp %{SOURCE2} ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name} chmod 0755 ${RPM_BUILD_ROOT}/etc/rc.d/init.d/%{name} mkdir -p ${RPM_BUILD_ROOT}/etc/rc.d/rc2.d/ mkdir -p ${RPM_BUILD_ROOT}/etc/rc.d/rc3.d/ ln -sf '../init.d/nagios' ${RPM_BUILD_ROOT}/etc/rc.d/rc2.d/S%{name} ln -sf '../init.d/nagios' ${RPM_BUILD_ROOT}/etc/rc.d/rc2.d/K%{name} ln -sf '../init.d/nagios' ${RPM_BUILD_ROOT}/etc/rc.d/rc3.d/S%{name} ln -sf '../init.d/nagios' ${RPM_BUILD_ROOT}/etc/rc.d/rc3.d/K%{name} %pre # add the "nagios" group only if it does not yet exist result=`/usr/sbin/lsgroup nagios | /usr/bin/awk '{ print $1 }' 2>/dev/null` if [[ "${result}" != "nagios" ]] ; then /usr/bin/mkgroup -A id=%{nagios_gid} nagios 2> /dev/null || : fi # add the "nagiscmd" group only if it does not yet exist result=`/usr/sbin/lsgroup nagiscmd | /usr/bin/awk '{ print $1 }' 2>/dev/null` if [[ "${result}" != "nagiscmd" ]] ; then /usr/bin/mkgroup -A id=%{nagioscmd_gid} nagiscmd 2> /dev/null || : fi # add the "nagios" user only if it does not yet exist result=`/usr/sbin/lsuser nagios | /usr/bin/awk '{ print $1 }' 2>/dev/null` if [[ "${result}" != "nagios" ]] ; then /usr/bin/mkuser id=%{nagios_uid} pgrp='nagios' groups='nagiscmd' \ home='/var/nagios' gecos='Nagios User' \ login='false' rlogin='false' nagios 2> /dev/null || : fi %preun if [ $1 -eq 0 ]; then /etc/rc.d/init.d/%{name} stop &>/dev/null || : fi %postun if [ "$1" = "0" ]; then # remove "nagios" user and "nagios" and "nagiscmd" groups /usr/sbin/rmuser -p nagios || : /usr/sbin/rmgroup nagios || : /usr/sbin/rmgroup nagiscmd || : fi %pre gui # add apacheuser to the nagiscmd group /usr/bin/chuser groups='nagiscmd' %{apacheuser} %preun gui if [ "$1" = 0 ]; then cat %{_sysconfdir}/httpd/conf/httpd.conf | \ grep -v "# Nagios settings" | \ grep -v "Include conf/extra/%{name}.conf" \ > %{_sysconfdir}/httpd/conf/tmp_httpd.conf mv -f %{_sysconfdir}/httpd/conf/tmp_httpd.conf %{_sysconfdir}/httpd/conf/httpd.conf echo "Please restart your web server using: '/opt/freeware/sbin/apachectl restart'" fi %post gui cat %{_sysconfdir}/httpd/conf/httpd.conf | \ grep -v "# Nagios settings" | \ grep -v "Include conf/extra/%{name}.conf" \ > %{_sysconfdir}/httpd/conf/tmp_httpd.conf mv -f %{_sysconfdir}/httpd/conf/tmp_httpd.conf %{_sysconfdir}/httpd/conf/httpd.conf echo "# Icinga settings" >> %{_sysconfdir}/httpd/conf/httpd.conf echo "Include conf/extra/nagios.conf" >> %{_sysconfdir}/httpd/conf/httpd.conf echo "Please restart your web server using: '/opt/freeware/sbin/apachectl restart'" %clean [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,nagios,nagios,-) %attr(755,root,system) /etc/rc.d/init.d/%{name} /etc/rc.d/rc2.d/S%{name} /etc/rc.d/rc2.d/K%{name} /etc/rc.d/rc3.d/S%{name} /etc/rc.d/rc3.d/K%{name} %dir /etc/%{name} %dir /etc/%{name}/conf.d %config(noreplace) /etc/%{name}/nagios.cfg %dir /etc/%{name}/objects %config(noreplace) /etc/%{name}/objects/commands.cfg %config(noreplace) /etc/%{name}/objects/contacts.cfg %config(noreplace) /etc/%{name}/objects/localhost.cfg %config(noreplace) /etc/%{name}/objects/printer.cfg %config(noreplace) /etc/%{name}/objects/switch.cfg %config(noreplace) /etc/%{name}/objects/templates.cfg %config(noreplace) /etc/%{name}/objects/timeperiods.cfg %config(noreplace) /etc/%{name}/objects/windows.cfg %config(noreplace) /etc/%{name}/resource.cfg %{_bindir}/nagios %{_bindir}/nagiostats %dir %{_libdir}/%{name} %dir %{_libdir}/%{name}/plugins %dir /var/%{name} %attr(2755,nagios,nagiscmd) %dir /var/%{name}/checkresults %attr(2755,nagios,nagiscmd) /var/%{name}/rw %dir %{logdir} %dir %{logdir}/archives %files doc %defattr(-,nagios,nagios,-) %{_datadir}/%{name}/docs %files gui %defattr(-,nagios,nagios,-) %config(noreplace) %attr(-,root,system) %{apacheconfdir}/%{name}.conf %config(noreplace) /etc/%{name}/cgi.cfg %dir %{_libdir}/%{name}/cgi %{_libdir}/%{name}/cgi/* %dir %{_datadir}/%{name} %{_datadir}/%{name}/config.inc.php %{_datadir}/%{name}/contexthelp %{_datadir}/%{name}/images %{_datadir}/%{name}/includes %{_datadir}/%{name}/index.php %{_datadir}/%{name}/js* %{_datadir}/%{name}/main.php %{_datadir}/%{name}/media %{_datadir}/%{name}/robots.txt %{_datadir}/%{name}/rss-* %{_datadir}/%{name}/side.php %{_datadir}/%{name}/ssi %{_datadir}/%{name}/stylesheets %changelog * Thu Feb 13 2014 Michael Perzl - 4.0.2-1 - updated to version 4.0.2 * Thu Feb 13 2014 Michael Perzl - 3.5.1-1 - updated to version 3.5.1 * Thu Feb 13 2014 Michael Perzl - 3.4.4-1 - updated to version 3.4.4 * Thu Feb 13 2014 Michael Perzl - 3.3.1-1 - updated to version 3.3.1 * Thu Feb 13 2014 Michael Perzl - 3.2.3-1 - first version for AIX V5.1 and higher