Summary: Open Source host, service and network monitoring program
Summary(ja): オープンソースホスト・サービス・ネットワーク監視プログラム
Name: nagios
Version: 3.2.3
Release: 1%{_dist_release}
License: GPL
Group: Applications/System
URL: http://www.nagios.org/
Vendor: Project Vine
Distribution: Vine Linux

Source: http://dl.sf.net/nagios/nagios-%{version}.tar.gz
Source1: http://dl.sf.net/nagios/imagepak-base.tar.gz
Patch0: nagios-3.2.3-ja-utf8.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: gd-devel > 1.8, zlib-devel, libpng-devel, libjpeg-devel
Requires: php5

%description
Nagios is an application, system and network monitoring application.
It can escalate problems by email, pager or any other medium. It is
also useful for incident or SLA reporting.

Nagios is written in C and is designed 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
located in the nagios-plugins package.

%package devel
Summary: Header files, libraries and development documentation for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
This package contains the header files, static libraries and development
documentation for %{name}. If you like to develop programs using %{name},
you will need to install %{name}-devel.

%prep
%setup
%patch0 -p1

%build
%configure \
	--datadir="%{_datadir}/nagios" \
	--datarootdir="%{_datadir}/nagios" \
	--libexecdir="%{_libdir}/nagios/plugins" \
	--localstatedir="%{_localstatedir}/log/nagios" \
	--sbindir="%{_libdir}/nagios/cgi" \
	--sysconfdir="%{_sysconfdir}/nagios" \
	--with-cgiurl="/nagios/cgi-bin" \
	--with-command-user="apache" \
	--with-command-group="apache" \
	--with-gd-lib="%{_libdir}" \
	--with-gd-inc="%{_includedir}" \
	--with-htmurl="/nagios" \
	--with-init-dir="%{_initrddir}" \
	--with-lockfile="%{_localstatedir}/run/nagios.pid" \
	--with-mail="/bin/mail" \
	--with-nagios-user="nagios" \
	--with-nagios-group="nagios" \
	--enable-embedded-perl \
	--with-perlcache \
	--with-template-objects \
	--with-template-extinfo \
	--enable-event-broker
%{__make} %{?_smp_mflags} all
%{__make} %{?_smp_mflags} -C contrib

%install
%{__rm} -rf %{buildroot}
%{__make} install install-init install-commandmode install-config \
        DESTDIR="%{buildroot}" \
        INSTALL_OPTS="" \
        COMMAND_OPTS="" \
        INIT_OPTS=""

%{__make} install -C contrib \
	DESTDIR="%{buildroot}" \
	INSTALL_OPTS=""

mkdir -p %{buildroot}%{_localstatedir}/log/nagios/spool/checkresults

%{__install} -d -m0755 %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/
%{__cp} -afpv contrib/eventhandlers/* %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/

%{__install} -d -m0755 %{buildroot}%{_includedir}/nagios/
%{__install} -p -m0644 include/*.h %{buildroot}%{_includedir}/nagios/

%{__install} -Dp -m0644 sample-config/httpd.conf %{buildroot}%{_sysconfdir}/apache2/conf.d/nagios.conf

### Install logos
tar -xvz -C %{buildroot}%{_datadir}/nagios/images/logos -f %{SOURCE1}

%pre
if ! /usr/bin/id nagios &>/dev/null; then
	/usr/sbin/useradd -r -d %{_localstatedir}/log/nagios -s /bin/sh -c "nagios" nagios ||:
fi
if ! /usr/bin/getent group nagiocmd &>/dev/null; then
	/usr/sbin/groupadd nagiocmd &>/dev/null ||:
fi

%post
/sbin/chkconfig --add nagios

if /usr/bin/id apache &>/dev/null; then
	if ! /usr/bin/id -Gn apache 2>/dev/null | grep -q nagios ; then
		/usr/sbin/usermod -G nagios,nagiocmd apache &>/dev/null
	fi
fi

%preun
if [ $1 -eq 0 ]; then
	/sbin/service nagios stop &>/dev/null || :
	/sbin/chkconfig --del nagios
fi

%postun
if [ $1 -eq 0 ]; then
	/usr/sbin/userdel nagios ||:
	/usr/sbin/groupdel nagios ||:
fi
/sbin/service nagios condrestart &>/dev/null || :

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc Changelog INSTALLING LICENSE README UPGRADING
%config(noreplace) %{_sysconfdir}/apache2/conf.d/nagios.conf
%config %{_initrddir}/nagios
%{_bindir}/convertcfg
%{_bindir}/nagios
%{_bindir}/nagiostats
%{_bindir}/p1.pl
%{_bindir}/mini_epn
%{_bindir}/new_mini_epn
%{_libdir}/nagios/
%{_datadir}/nagios/

#%defattr(-, root, nagios, 0755)
#%config(noreplace) %{_sysconfdir}/nagios/private/

%defattr(-, nagios, nagios, 0755)
%dir %{_sysconfdir}/nagios/
%dir %{_sysconfdir}/nagios/objects
%config(noreplace) %{_sysconfdir}/nagios/*.cfg
%config(noreplace) %{_sysconfdir}/nagios/objects/*.cfg

%defattr(-, nagios, apache, 2755)
%dir %{_localstatedir}/log/nagios/
%dir %{_localstatedir}/log/nagios/spool/checkresults
%dir %{_localstatedir}/log/nagios/rw/
### FIXME: Start using /var/spool/nagios instead of /var/log/nagios/rw ??
#%{_localstatedir}/spool/nagios/

%files devel
%defattr(-, root, root, 0755)
%{_includedir}/nagios/

%changelog
* Thu May 26 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.3-1
- new upstream release.
- updated ja patch.
- added Vendor: and Distribution: tags.

* Fri Jul 10 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.2-1
- new upstream release.
- replaced ja patch.

* Mon Jun  8 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.1.0-1
- new upstream release.

* Wed May 21 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 2.9-2
- rebuilt with perl-5.10.0.

* Thu Apr 10 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>  2.9-1
- new upstream release.
- apply Japanese patch.

* Mon Nov 13 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.5-0vl1
- initial build for Vine Linux based on DAG package.

* Wed Jul 19 2006 Dag Wieers <dag@wieers.com> - 2.5-1 - 4484+/dag
- Updated to release 2.5.

* Fri Jun 02 2006 Dag Wieers <dag@wieers.com> - 2.4-2
- Make nagios owner of /etc/nagios. (Christop Maser)
- Updated to release 2.4.

* Mon May 29 2006 Dag Wieers <dag@wieers.com> - 2.3.1-2
- Make nagios owner of /etc/nagios. (Christop Maser)

* Wed May 17 2006 Dag Wieers <dag@wieers.com> - 2.3.1-1
- Updated to release 2.3.1.

* Wed May 03 2006 Dag Wieers <dag@wieers.com> - 2.3-1
- Updated to release 2.3.

* Sat Apr 08 2006 Dag Wieers <dag@wieers.com> - 2.2-1
- Updated to release 2.2.

* Tue Mar 28 2006 Dag Wieers <dag@wieers.com> - 2.1-1
- Updated to release 2.1.

* Wed Feb 08 2006 Dag Wieers <dag@wieers.com> - 2.0-2
- Fixed the nagiocmd group creation. (Rick Johnson)
- Added _without_perlcache macro. (Rick Johnson)

* Wed Feb 08 2006 Dag Wieers <dag@wieers.com> - 2.0-1
- Updated to release 2.0.

* Thu Jan 12 2006 Dag Wieers <dag@wieers.com> - 2.0-0.rc2
- Updated to release 2.0rc2.

* Sun Jan 01 2006 Dag Wieers <dag@wieers.com> - 2.0-0.rc1
- Updated to release 2.0rc1.

* Mon Dec 12 2005 Dag Wieers <dag@wieers.com> - 2.0-0.b6.1
- Updated to release 2.0b6.

* Fri Aug 05 2005 Dag Wieers <dag@wieers.com> - 2.0-0.b4.1
- Updated to release 2.0b4.

* Mon May 23 2005 Dag Wieers <dag@wieers.com> - 2.0-0.b3.1
- Use the actual 2.0b3 sourcecode, sigh. (Cameron Pitt-Downton)

* Wed May 18 2005 Dag Wieers <dag@wieers.com> - 2.0-0.b3
- Updated to release 2.0b3.

* Mon Feb 21 2005 Tim Verhoeven <dj@rootshell.be> - 2.0-0.b2
- Updated to release 2.0b2.

* Sun Jan 02 2005 Dag Wieers <dag@wieers.com> - 2.0-0.b1
* Updated to release 2.0b1.

* Fri Nov 26 2004 Dag Wieers <dag@wieers.com> - 1.2-1
* Fixed %%{_libdir} in httpd nagios.conf. (Thomas Zehetbauer)

* Wed Feb 11 2004 Dag Wieers <dag@wieers.com> - 1.2-0
- Added embedded perl patch for perl > 5.8. (Stanley Hopcroft)
- Updated to release 1.2.

* Wed Jan 28 2004 Dag Wieers <dag@wieers.com> - 1.1-6
- Fixed the longstanding nagios.cmd problem. (Magnus Stenman)

* Wed Oct 29 2003 Dag Wieers <dag@wieers.com> - 1.1-5
- Fixed resource.cfg location from nagios.cfg. (Ragnar Wisloff)
- Cleaned up perl one-liners.

* Wed Oct 08 2003 Dag Wieers <dag@wieers.com> - 1.1-4
- Removed --with-file-perfdata, use default. (Erik De Cock)

* Mon Aug 25 2003 Dag Wieers <dag@wieers.com> - 1.1-3
- Fixed the missing @MAIL_PROG@ problem in misccommands.cfg.

* Mon Aug 18 2003 Dag Wieers <dag@wieers.com> - 1.1-2
- Let %pre silently check for user nagios.
- Added base imagepak.

* Sat Jul 12 2003 Dag Wieers <dag@wieers.com> - 1.1-1
- Disabled embedded perl.

* Wed Jun 04 2003 Dag Wieers <dag@wieers.com> - 1.1-0
- Updated to release 1.1.

* Tue Jun 03 2003 Dag Wieers <dag@wieers.com> - 1.0-1
- Don't restart webserver.

* Sun Feb 16 2003 Dag Wieers <dag@wieers.com> - 1.0-0
- Initial package. (using DAR)
