Name:      	munin
Version:   	@@VERSION@@
Release:	1

Summary:	Network-wide graphing framework (grapher/gatherer)
License: 	GPL
Group:		System Environment/Daemons
URL:		http://munin.sourceforge.net
Packager:	Rune Nordbøe Skillingstad <runesk@linpro.no>
Vendor:		Linpro AS
Distribution:	Linpro AS SuSE Linux Software Archives
Source0:	%{name}_%{version}.tar.gz
Source1:	Makefile.config
Source2:	munin-node.rc
Source3:	munin.cron.d
Source4:	munin.logrotate
Source5:	munin-node.logrotate
Source6:	munin-node.cron.d
Source7:	plugins.conf
Patch0:		patch-001
Patch1:		patch-002
Requires:	perl-HTML-Template
Requires:	rrdtool
Obsoletes:	lrrd-server
BuildArch:	noarch
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

%define         confdir /etc/munin
%define         libdir  /usr/share/munin
%define         htmldir /srv/www/htdocs/munin
%define         cgidir  /srv/www/cgi-bin
%define         dbdir   /var/lib/munin
%define         logdir  /var/log/munin
%define         statedir /var/run/munin

%description
Munin is a highly flexible and powerful solution used to create graphs of
virtually everything imaginable throughout your network, while still
maintaining a rattling ease of installation and configuration.

This package contains the grapher/gatherer. You will only need one instance of
it in your network. It will periodically poll all the nodes in your network
it's aware of for data, which it in turn will use to create graphs and HTML
pages, suitable for viewing with your graphical web browser of choice.

Munin is written in Perl, and relies heavily on Tobi Oetiker's excellent
RRDtool. To see a real example of Munin in action, take a peek at
<http://demo.munin-monitoring.org>.

%package node
Group:		System Environment/Daemons
Summary:	Network-wide graphing framework (node)
BuildArch: 	noarch
Requires: 	perl-Net-Server
Requires:	ps
Requires:	sysstat
Obsoletes:	lrrd-client

%description node
Munin is a highly flexible and powerful solution used to create graphs of
virtually everything imaginable throughout your network, while still
maintaining a rattling ease of installation and configuration.

This package contains node software. You should install it on all the nodes
in your network. It will know how to extract all sorts of data from the
node it runs on, and will wait for the gatherer to request this data for
further processing.

It includes a range of plugins capable of extracting common values such as
cpu usage, network usage, load average, and so on. Creating your own plugins
which are capable of extracting other system-specific values is very easy,
and is often done in a matter of minutes. You can also create plugins which
relay information from other devices in your network that can't run Munin,
such as a switch or a server running another operating system, by using
SNMP or similar technology.

Munin is written in Perl, and relies heavily on Tobi Oetiker's excellent
RRDtool. To see a real example of Munin in action, take a peek at
<http://www.linpro.no/projects/munin/example/>.

%prep
%setup -q
%patch0
%patch1 -p1
mkdir -p %{buildroot}

%build

# htmldoc and html2text are not available for Red Hat. Quick hack with perl:
# Skip the PDFs.
perl -pi -e 's,htmldoc munin,cat munin, or s,html(2text|doc),# $&,' Makefile
perl -pi -e 's,\$\(INSTALL.+\.(pdf|txt) \$\(DOCDIR,# $&,' Makefile

make 	clean
make    CONFIG=%{SOURCE1} \
        DOCDIR=%{_docdir}/munin \
        MANDIR=%{_mandir} \
	HTMLDIR=%{htmldir} \
	CGIDIR=%{cgidir} \
	LIBDIR=%{libdir} \
	CONFDIR=%{confdir} \
        DESTDIR=%{buildroot} \
        DBDIR=%{dbdir} \
        SBINDIR=%{_sbindir} \
        LOGDIR=%{logdir} \
        STATEDIR=%{statedir} \
        build

mkdir -p %{buildroot}%{dbdir}/plugin-state
mkdir -p %{buildroot}%{logdir}
mkdir -p %{buildroot}%{statedir}
mkdir -p %{buildroot}/etc/init.d
mkdir -p %{buildroot}/etc/cron.d
mkdir -p %{buildroot}/etc/logrotate.d
mkdir -p %{buildroot}%{htmldir}

%install
make    CONFIG=%{SOURCE1} \
        DOCDIR=%{buildroot}%{_docdir}/munin \
        MANDIR=%{buildroot}%{_mandir} \
	HTMLDIR=%{buildroot}%{htmldir} \
	LIBDIR=%{buildroot}%{libdir} \
	CGIDIR=%{buildroot}%{cgidir} \
	CONFDIR=%{buildroot}%{confdir} \
        DESTDIR=%{buildroot} \
        DBDIR=%{buildroot}%{dbdir} \
        SBINDIR=%{buildroot}%{_sbindir} \
        LOGDIR=%{buildroot}%{logdir} \
        STATEDIR=%{buildroot}%{statedir} \
        install-main install-node install-node-plugins install-doc install-man 
								
install -m0755 %{SOURCE2} %{buildroot}/etc/init.d/munin-node
install -m0644 %{SOURCE3} %{buildroot}/etc/cron.d/munin
install -m0644 %{SOURCE4} %{buildroot}/etc/logrotate.d/munin
install -m0644 %{SOURCE5} %{buildroot}/etc/logrotate.d/munin-node
install -m0644 %{SOURCE6} %{buildroot}/etc/cron.d/munin-node
install -m0644 %{SOURCE7} %{buildroot}%{confdir}/plugin-conf.d/munin-node
install -m0644 ChangeLog %{buildroot}%{_docdir}/munin/ChangeLog

%clean
[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}


## Server

%pre

getent group munin >/dev/null || groupadd -r munin
getent passwd munin > /dev/null || useradd -r -d %{dbdir} -g munin munin

%post
mkdir -p %{htmldir}
mkdir -p %{logdir}
mkdir -p %{dbdir}
chown -R munin:munin %{htmldir}
chown -R munin:munin %{logdir}
chown -R munin:munin %{statedir}
chown -R munin:munin %{dbdir}

## Node
%pre node
getent group munin >/dev/null || groupadd -r munin
getent passwd munin > /dev/null || useradd -r -d %{dbdir} -g munin munin

%post node
if [ $1 = 1 ]
then
        /sbin/chkconfig --add munin-node
	/usr/sbin/munin-node-configure --shell | sh
fi
%{fillup_and_insserv -n -s -y munin munin-node START_MUNIN_NODE}
mkdir -p %{logdir}
mkdir -p %{dbdir}/plugin-state
chown -R munin:munin %{logdir}
chown -R munin:munin %{dbdir}
chmod g+w %{dbdir}/plugin-state
/etc/init.d/munin-node status >/dev/null 2>&1 || /etc/init.d/munin-node start

%preun node
if [ $1 = 0 ]
then
        /sbin/service munin-node stop > /dev/null 2>&1
        /sbin/chkconfig --del munin-node
        rmdir %{logdir} 2>/dev/null || true
fi
%stop_on_removal munin-node

%postun node
%restart_on_update munin-node
%{insserv_cleanup}


%files
%defattr(-, root, root)
%doc %{_docdir}/munin/README.api
%doc %{_docdir}/munin/README.plugins
%doc %{_docdir}/munin/COPYING
%doc %{_docdir}/munin/ChangeLog
%doc %{_mandir}/man8/munin-graph*
%doc %{_mandir}/man8/munin-update*
%doc %{_mandir}/man8/munin-html*
%doc %{_mandir}/man8/munin-cron*
%doc %{_mandir}/man5/munin.conf*
%doc %{_mandir}/man8/munin-limits.8.gz
%{_bindir}/munin-cron
%{_datadir}/munin/munin-graph
%{_datadir}/munin/munin-html
%{_datadir}/munin/munin-update
%{_libdir}/perl5/*perl/5.*/Munin.pm
%{_usr}/share/munin/munin-limits
%{cgidir}/munin-cgi-graph
%config %{confdir}/templates/*
%config /etc/cron.d/munin
%config(noreplace) %{confdir}/munin.conf
%config /etc/logrotate.d/munin
%dir %{statedir}

	    
%files node
%defattr(-, root, root)
%doc %{_docdir}/munin/COPYING
%doc %{_docdir}/munin/munin-doc.html
%doc %{_docdir}/munin/munin-faq.html
%doc %{_mandir}/man8/munin-run*
%doc %{_mandir}/man8/munin-node*
%doc %{_mandir}/man5/munin-node*
%{_sbindir}/munin-run
%{_sbindir}/munin-node
%{_sbindir}/munin-node-configure
%{_sbindir}/munin-node-configure-snmp
%{_datadir}/munin/plugins/*
%config(noreplace) %{confdir}/munin-node.conf
%config(noreplace) %{confdir}/plugin-conf.d/munin-node
%config /etc/init.d/munin-node
%config /etc/cron.d/munin-node
%config /etc/logrotate.d/munin-node
%dir %{confdir}/plugins

%changelog
* Mon Apr  3 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- 1.2.3 release
* Fri Apr  1 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- 1.2.2 release
- Fixed SF bug 1164481 (missing /srv/www/htdocs/munin)
- Fixed SF bug 1164477 (patch for Net::Domain on PPC64)
* Fri Mar 11 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- 1.2.1 release
* Wed Mar  9 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- Fixed erronumous path to web directory
- Added start of node if not running
* Thu Mar  8 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- Fixed some build path problems
* Thu Feb 24 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- New major release
* Wed Feb  9 2005 Rune Nordbøe Skillingstad <runesk@linpro.no>
- Updated to version 1.2.0rc2.
- Removed Nagios stuff
- Added noreplace for some central configuration files
* Thu Nov 18 2004 Rune Nordbøe Skillingstad <runesk@linpro.no>
- Updated to version 1.0.4
* Mon Nov 08 2004 Rune Nordbøe Skillingstad <runesk@linpro.no>
- Updated version 1.0.3 / sync with redhat-build
* Wed Aug 04 2004 Rune Nordbøe Skillingstad <runesk@linpro.no>
- Initial SuSE build
* Sun Feb 01 2004 Ingvar Hagelund <ingvar@linpro.no>
- Sync with CVS. Version 1.0.0pre2
* Sun Jan 18 2004 Ingvar Hagelund <ingvar@linpro.no>
- Sync with CVS. Change names to munin.
* Fri Oct 31 2003 Ingvar Hagelund <ingvar@linpro.no>
- Lot of small fixes. Now builds on more RPM distros
* Wed May 21 2003 Ingvar Hagelund <ingvar@linpro.no>
- Sync with CVS
- 0.9.5-1
* Tue Apr  1 2003 Ingvar Hagelund <ingvar@linpro.no>
- Sync with CVS
- Makefile-based install of core files
- Build doc (only pod2man)
* Thu Jan  9 2003 Ingvar Hagelund <ingvar@linpro.no>
- Sync with CVS, auto rpmbuild
* Thu Jan  2 2003 Ingvar Hagelund <ingvar@linpro.no>
- Fix spec file for RedHat 8.0 and new version of lrrd
* Wed Sep  4 2002 Ingvar Hagelund <ingvar@linpro.no>
- Small bugfixes in the rpm package
* Tue Jun 18 2002 Kjetil Torgrim Homme <kjetilho@linpro.no>
- new package


