File icinga.spec of Package icinga
#
# spec file for package icinga
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define apacheconfdir %{_sysconfdir}/apache2/conf.d
# overload eventhandlerdir with the original value for now to not break backward
# compatibility, this will be changed with the next upstream version integration
# to /usr/lib/icinga/eventhandler
%define icinga_eventhandlerdir %{_prefix}/lib/nagios/plugins/eventhandlers/
Name: icinga
Version: 1.6.1
Release: 0
# Macro that print mesages to syslog at package (un)install time
%define nnmmsg logger -t %{name}/rpm
Summary: Host/service/network monitoring program
License: GPL-2.0
Group: System/Monitoring
Url: http://www.icinga.org/
Source0: %{name}-%{version}.tar.gz
Source1: rc%{name}
Source2: rcido2db
Source3: %{name}.sysconfig
Source4: suse.de-%{name}
Source5: icinga-rpmlintrc
Source6: icinga.8
Source7: icingastats.8
Source8: ido2db.8
Source9: mini_epn_icinga.8
Source12: htpasswd.users
# PATCH-FIX-OPENSUSE icinga-add-ifdefine-to-apache.patch
Patch0: icinga-add-ifdefine-to-apache.patch
# PATCH-FIX-OPENSUSE icinga-fix-create_mysqldb.patch
Patch1: icinga-fix-create_mysqldb.patch
BuildRequires: apache2-devel
BuildRequires: nagios-rpm-macros
%if 0%{?suse_version} >= 1110
BuildRequires: fdupes
%endif
BuildRequires: freetype2-devel
BuildRequires: gd-devel > 1.8
BuildRequires: iputils
BuildRequires: krb5-devel
BuildRequires: libdbi-devel
BuildRequires: libjpeg-devel
BuildRequires: libopenssl-devel
BuildRequires: libpng-devel
BuildRequires: mailx
BuildRequires: net-snmp-devel
BuildRequires: net-tools
BuildRequires: openssl
BuildRequires: pcre-devel
BuildRequires: zlib-devel
Requires: net-tools
Requires(pre): %fillup_prereq
Requires(pre): %insserv_prereq
Requires(pre): /bin/logger
Requires(pre): fileutils
Requires(pre): gawk
Requires(pre): grep
Requires(pre): pwdutils
Requires(pre): sed
%if 0%{?suse_version} >= 1110
Requires: perl >= 5.10.0
%else
Recommends: perl >= 5.10.0
%endif
Requires: mailx
Recommends: %{name}-plugins-eventhandlers
Recommends: %{name}-www
Recommends: cron
Recommends: nagios-plugins
Recommends: net-snmp
Recommends: openssl
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Icinga is a program that will monitor hosts and services on your
network. It has the ability to email or page you when a problem arises
and when a problem is resolved. Icinga 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 Icinga. The plugins are
available at http://sourceforge.net/projects/icingaplug
This package provide core programs for icinga. The web interface,
documentation, and development files are built as separate packages
%package www
Summary: Provides the HTML and CGI files for the Icinga web interface
Group: System/Monitoring
Requires: %{name} = %{version}
Recommends: %{name}-doc = %{version}
Requires(pre): apache2
%description www
Icinga is a program that will monitor hosts and services on your
network. It has the ability to email or page you when a problem arises
and when a problem is resolved. Icinga 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.
Several CGI programs are included with Icinga in order to allow you
to view the current service status, problem history, notification
history, and log file via the web. This package provides the HTML and
CGI files for the Icinga web interface. In addition, HTML
documentation is included in this package
%package devel
Summary: Provides include files that Icinga-related applications may compile against
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}
%description devel
Icinga is a program that will monitor hosts and services on your
network. It has the ability to email or page you when a problem arises
and when a problem is resolved. Icinga 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.
This package provides include files that Icinga-related applications
may compile against.
%package idoutils
Summary: Provides the IDOUtils functionality for Icinga
Group: System/Monitoring
Requires: %{name}-idoutils-drivers-dbd >= %{version}
Requires(pre): %{name} = %{version}
%description idoutils
Icinga is a program that will monitor hosts and services on your
network. It has the ability to email or page you when a problem arises
and when a problem is resolved. Icinga 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.
This package provides the IDOUtils extensions for Icinga
%package idoutils-mysql
Summary: IDOUtils drivers for MySQL
Group: System/Monitoring
Requires: %{name}-idoutils = %{version}
Requires: libdbi-drivers-dbd-mysql
Requires: perl(DBD::mysql)
Recommends: mysql
Recommends: mysql-client
Provides: %{name}-idoutils-drivers-dbd = %{version}
%description idoutils-mysql
This package requires all needed packages for using IDOUtils with MySQL.
%package idoutils-oracle
Summary: IDOUtils drivers for Oracle
Group: System/Monitoring
Requires: %{name}-idoutils = %{version}
Recommends: oracle-client
Provides: %{name}-idoutils-drivers-dbd = %{version}
%description idoutils-oracle
This package requires all needed packages for using IDOUtils with OracleDB.
%package idoutils-pgsql
Summary: IDOUtils drivers for PostgreSQL
Group: System/Monitoring
Requires: %{name}-idoutils = %{version}
Requires: libdbi-drivers-dbd-pgsql
Recommends: postgresql
Recommends: postgresql-libs
Provides: %{name}-idoutils-drivers-dbd = %{version}
%description idoutils-pgsql
This package requires all needed packages for using IDOUtils with PostgreSQL.
%package doc
Summary: Online documentation for %{name}
Group: System/Monitoring
Recommends: %{name}-web = %{version}
%description doc
This package provides the online documentation for %{name}.
%package plugins-eventhandlers
Summary: Eventhandlers for %{name}
Group: System/Monitoring
Recommends: %{name} = %{version}
%description plugins-eventhandlers
Eventhandlers for %{name}. Providing different scripts for distributed
monitoring, redundancy and disabling and enabling service checks and
notifications.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
# replace default ido2db lock and socket file settings
sed -ie "s|@localstatedir@/ido2db.lock|%{icinga_ido2db_lockfile}|g; \
s|@localstatedir@/ido.sock|%{icinga_ido2db_socketfile}|g;" \
"module/idoutils/config/ido2db.cfg-sample.in" \
"module/idoutils/config/idomod.cfg-sample.in";
# remove GPLv3+ source files which are not needed for this package
rm t-tap/*.c
%build
export PATH_TO_TRACEROUTE="%{_sbindir}/traceroute"
%configure \
--exec-prefix="%{_sbindir}" \
--bindir="%{_sbindir}" \
--sbindir="%{icinga_cgidir}" \
--libexecdir="%{icinga_plugindir}" \
--datarootdir="%{icinga_datadir}" \
--sysconfdir="%{icinga_sysconfdir}" \
--with-p1-file-dir="%{icinga_datadir}" \
--with-init-dir="%{_sysconfdir}/init.d" \
--localstatedir="%{icinga_localstatedir}" \
--with-checkresult-dir="%{icinga_localstatedir}/checkresults" \
--with-cgiurl="/%{name}/cgi-bin" \
--with-htmurl="/%{name}" \
--with-httpd-conf="%{apacheconfdir}" \
--with-lockfile="%{icinga_lockfile}" \
--with-ext-cmd-file-dir="%{icinga_spooldir}" \
--with-log-dir="%{icinga_logdir}" \
--with-cgi-log-dir="%{icinga_logdir}/www" \
--with-icinga-user="%{icinga_user}" \
--with-icinga-group="%{icinga_group}" \
--with-command-user="%{icinga_command_user}" \
--with-command-group="%{icinga_command_group}" \
--with-gd-lib="%{_libdir}" \
--with-gd-inc="%{_includedir}" \
--with-perlcache \
--enable-event-broker \
--enable-embedded-perl \
--enable-idoutils \
--enable-ssl
#
# make daemonchk.cgi and event handlers
#
make %{?_smp_mflags} all
make %{?_smp_mflags} -C contrib
pushd contrib/eventhandlers 1>/dev/null
for f in `find . -type f` ; do
sed -i "s=/usr/local/nagios/var/rw/=/var/spool/%{name}/=; \
s=/usr/local/%{name}/var/rw/=/var/spool/%{name}/=; \
s=NscaBin\=\"/usr/local/nagios/libexec/send_nsca\"=NscaBin\=/usr/bin/send_nsca=; \
s=/usr/local/nagios/libexec/eventhandlers/=%{icinga_eventhandlerdir}/=; \
s=/usr/local/%{name}/libexec/eventhandlers/=%{icinga_eventhandlerdir}/=; \
s=/usr/local/nagios/libexec/=%{icinga_plugindir}/=; \
s=/usr/local/nagios/etc/=%{icinga_sysconfdir}/=; \
s=/usr/local/nagios/test/var=/var/log/%{name}=" ${f}
done
popd 1>/dev/null
# make daemonchk.cgi and event handlers
cd contrib
make
%install
install -d -m0775 "%{buildroot}%{_localstatedir}/log/%{name}/archives"
install -d -m0775 "%{buildroot}%{_localstatedir}/spool/%{name}"
install -d -m0775 "%{buildroot}%{_sbindir}"
install -d -m0755 "%{buildroot}%{_includedir}/%{name}"
install -d -m0755 "%{buildroot}%{_sysconfdir}/init.d"
install -d -m0755 "%{buildroot}%{_sysconfdir}/logrotate.d"
install -d -m0755 "%{buildroot}%{apacheconfdir}"
install -d -m0755 "%{buildroot}%{icinga_sysconfdir}/objects"
install -d -m0755 "%{buildroot}%{icinga_localstatedir}"
install -d -m0755 "%{buildroot}%{icinga_eventhandlerdir}"
make install install-commandmode install-idoutils install-config install-webconf install-cgis install-init \
DESTDIR=%{buildroot} \
INSTALL_OPTS="" \
COMMAND_OPTS="" \
INSTALL_OPTS_WEB="" \
CGIDIR="%{icinga_libdir}/cgi" \
CGICFGDIR="%{icinga_sysconfdir}" \
INIT_OPTS=""
make install -C contrib \
DESTDIR=%{buildroot} \
CGIDIR="%{icinga_libdir}/cgi" \
CGICFGDIR="%{icinga_sysconfdir}" \
INSTALL_OPTS=""
### move idoutils sample configs to final name
mv "%{buildroot}%{icinga_sysconfdir}/ido2db.cfg-sample" "%{buildroot}%{icinga_sysconfdir}/ido2db.cfg"
mv "%{buildroot}%{icinga_sysconfdir}/idomod.cfg-sample" "%{buildroot}%{icinga_sysconfdir}/idomod.cfg"
mv "%{buildroot}%{icinga_sysconfdir}/modules/idoutils.cfg-sample" "%{buildroot}%{icinga_sysconfdir}/modules/idoutils.cfg"
# install directory for event brokers like ndoutils
install -d -m0755 "%{buildroot}%{_prefix}/lib/nagios/brokers"
# install eventhandlers
cp -r contrib/eventhandlers/* "%{buildroot}%{icinga_eventhandlerdir}"
# install headers for development package
install -d -m0755 "%{buildroot}%{_includedir}/%{name}/"
install -m0644 include/{config,snprintf,cgiutils,locations}.h "%{buildroot}%{_includedir}/%{name}"
# remove unnecessary files from www log directory
rm "%{buildroot}/%{icinga_logdir}/www/"{.htaccess,index.htm}
# REST of special SUSE stuff here, if needed....
# init-scripts
# remove the default init script as SUSE uses an adapted one
test -f "%{buildroot}%{_sysconfdir}/init.d/%{name}" && rm -v "%{buildroot}%{_sysconfdir}/init.d/%{name}"
install -D -m0755 %{SOURCE1} "%{buildroot}%{_sysconfdir}/init.d/%{name}"
ln -sf ../../%{_sysconfdir}/init.d/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
install -D -m0755 %{SOURCE2} "%{buildroot}%{_sysconfdir}/init.d/ido2db"
ln -sf ../../%{_sysconfdir}/init.d/ido2db "%{buildroot}%{_sbindir}/rcido2db"
# sysconfig script
install -D -m 0644 %{SOURCE3} "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
# install cronjob (gzip' the logfiles)
install -D -m 0640 %{SOURCE4} "%{buildroot}%{_sysconfdir}/cron.weekly/%{name}"
%if 0%{?suse_version} >= 1110
%fdupes -s %{buildroot}
%endif
# fix documentation
rm -f sample-config/*.in
rm -f sample-config/template-object/*.in
# install manpages from Debian
mkdir -p %{buildroot}%{_mandir}/man8/
install -m644 %{SOURCE6} "%{buildroot}%{_mandir}/man8/"
install -m644 %{SOURCE7} "%{buildroot}%{_mandir}/man8/"
install -m644 %{SOURCE8} "%{buildroot}%{_mandir}/man8/"
install -m644 %{SOURCE9} "%{buildroot}%{_mandir}/man8/"
# install default www interface user
install -m644 %{SOURCE12} "%{buildroot}%{icinga_sysconfdir}/"
# install ido2utils scripts
pushd module/idoutils/db/scripts >/dev/null
test -d "%{buildroot}/%{_bindir}" || mkdir -p "%{buildroot}/%{_bindir}"
for file in *; do
outfile=$(basename $file .in)
sed -e "s|@ido2db_perl@|%{_bindir}/perl|g; \
s|../mysql|%{_defaultdocdir}/%{name}-idoutils-mysql/mysql|g" \
$file > "%{buildroot}/%{_bindir}/%{name}-$outfile"
chmod +x "%{buildroot}/%{_bindir}/%{name}-$outfile"
done
popd >/dev/null
%pre
groupadd -r %{icinga_group} 2>/dev/null || :
groupadd -r %{icinga_command_group} 2>/dev/null || :
/usr/sbin/useradd -c %{icinga_user} -s /sbin/nologin -r -d %{icinga_localstatedir} -G %{icinga_command_group} -g %{icinga_group} %{icinga_user} 2> /dev/null || :
%post
%{fillup_and_insserv %{name}}
# New installation?
if [ ${1:-0} -eq 0 ]; then
# First installation: create an alias for the default nagiosadmin user
if [ -r etc/aliases ]; then
if ! grep -q "^%{name}:" etc/aliases; then
echo -e "%{name}:\troot" >> etc/aliases
%{nnmmsg} "Added alias for user %{name} to /etc/aliases"
if [ -x usr/bin/newaliases ]; then
usr/bin/newaliases &>/dev/null || true
else
%{nnmmsg} "Cannot execute newaliases. Please run it manually."
fi
fi
fi
fi
%preun
%stop_on_removal %{name}
%postun
%restart_on_update %{name}
%{insserv_cleanup}
%post www
# If apache is installed, and we can find the apache user, set a shell var
if [ -f etc/apache2/uid.conf ]; then
wwwusr=$(awk '/^[ \t]*User[ \t]+[a-zA-Z0-9]+/ {print $2}' etc/apache2/uid.conf)
else
wwwusr=$(awk '/^[ \t]*User[ \t]+[a-zA-Z0-9]+/ {print $2}' etc/apache2/*.conf)
fi
if [ "z" == "z$wwwusr" ]; then # otherwise, use the default
wwwusr=%{icinga_command_user}
fi
# if apache user is not in cmdgrp, add it
if /usr/bin/id -Gn $wwwusr 2>/dev/null | /bin/grep -q %{icinga_command_group} > /dev/null 2>&1 ; then
: # $wwwusr (default: %{icinga_command_user}) is already in %{icinga_command_group} group
else
# modify apache user, adding it to cmdgrp
groupmod -A $wwwusr %{icinga_command_group} 2>/dev/null
%nnmmsg "User $wwwusr added to group %{icinga_command_group} so sending commands to Icinga from the command CGI is possible."
fi
if [ "$1" = "1" ]; then
# this is the initial installation: enable icinga
test -x %{_sbindir}/a2enflag && %{_sbindir}/a2enflag ICINGA >/dev/null
fi
%restart_on_update apache2
%preun www
%restart_on_update apache2
%postun www
if [ "$1" = "0" ]; then
# deinstallation of the package - remove the apache flag
test -x %{_sbindir}/a2disflag && %{_sbindir}/a2disflag ICINGA >/dev/null
%restart_on_update apache2
fi
%post idoutils
#post a db update notification in case of major updates
if [ "$1" == "2" ] &&
[ "`rpm -q %{name}-idoutils | head -n1 | cut -d- -f3 | cut -d. -f-2`" != "`echo %{version} | cut -d. -f-2`" ]; then
echo "########################################################################################"
echo "Don't forget to update your database. Check /usr/share/doc/packages/icinga-idoutils-<db>"
echo "########################################################################################"
fi
%{fillup_and_insserv ido2db}
%preun idoutils
%stop_on_removal ido2db
%postun idoutils
%restart_on_update ido2db
%insserv_cleanup
%files
%defattr(-,root,root)
%doc Changelog LEGAL LICENSE README UPGRADING sample-config/
%{_mandir}/man8/icinga*.8*
%{_mandir}/man8/mini_epn_icinga.8*
%{_sysconfdir}/init.d/%{name}
%{_sbindir}/%{name}
%{_sbindir}/icingastats
%{_sbindir}/mini_epn
%{_sbindir}/new_mini_epn
%{_sbindir}/rc%{name}
%{icinga_datadir}/p1.pl
%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
%attr(0755,root,root) %config %{_sysconfdir}/cron.weekly/*
%dir %{icinga_libdir}
%dir %{_prefix}/lib/nagios
%dir %{_prefix}/lib/nagios/brokers
%dir %{_prefix}/lib/nagios/plugins
%exclude %{icinga_libdir}/cgi
%{_sbindir}/convertcfg
%dir %{icinga_sysconfdir}
%dir %{icinga_sysconfdir}/modules
%config(noreplace) %{icinga_sysconfdir}/icinga.cfg
%dir %{icinga_sysconfdir}/objects
%config(noreplace) %{icinga_sysconfdir}/objects/commands.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/contacts.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/notifications.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/localhost.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/printer.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/switch.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/templates.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/timeperiods.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/windows.cfg
%config(noreplace) %{icinga_sysconfdir}/resource.cfg
%defattr(-,%{icinga_user},%{icinga_group})
%dir %{icinga_localstatedir}
%dir %{icinga_localstatedir}/checkresults
%dir %{icinga_logdir}
%dir %{icinga_logdir}/archives
%attr(0755,%{icinga_user},%{icinga_command_group}) %dir %{icinga_spooldir}
%files www
%defattr(-,root,root)
%config(noreplace) %attr(-,root,root) %{apacheconfdir}/%{name}.conf
%config(noreplace) %{icinga_sysconfdir}/htpasswd.users
%config(noreplace) %{icinga_sysconfdir}/cgi.cfg
%config(noreplace) %{icinga_sysconfdir}/cgiauth.cfg
%{icinga_libdir}/cgi
%dir %{icinga_datadir}
%{icinga_datadir}/contexthelp
%{icinga_datadir}/images
%{icinga_datadir}/index.html
%{icinga_datadir}/js
%{icinga_datadir}/main.html
%{icinga_datadir}/media
%{icinga_datadir}/menu.html
%{icinga_datadir}/robots.txt
%{icinga_datadir}/sidebar.html
%{icinga_datadir}/ssi
%{icinga_datadir}/stylesheets
%attr(0775,%{icinga_command_user},%{icinga_command_group}) %dir %{icinga_logdir}/www
%files idoutils
%defattr(-,root,root)
%doc module/idoutils/db/queries module/idoutils/db/README module/idoutils/config
%{_mandir}/man8/ido2db.8*
%{_sysconfdir}/init.d/ido2db
%config(noreplace) %{icinga_sysconfdir}/ido2db.cfg
%config(noreplace) %{icinga_sysconfdir}/idomod.cfg
%config(noreplace) %{icinga_sysconfdir}/modules/idoutils.cfg
%config(noreplace) %{icinga_sysconfdir}/objects/ido2db_check_proc.cfg
%{_sbindir}/rcido2db
%{_sbindir}/ido2db
%{_sbindir}/log2ido
%{_sbindir}/idomod.o
%files idoutils-mysql
%defattr(-,root,root)
%doc module/idoutils/db/mysql
%{_bindir}/%{name}-create_mysqldb.sh
%{_bindir}/%{name}-installdb
%{_bindir}/%{name}-prepsql
%{_bindir}/%{name}-upgradedb
%files idoutils-oracle
%defattr(-,root,root)
%doc module/idoutils/db/oracle
%{_bindir}/%{name}-create_oracledb.sh
%files idoutils-pgsql
%defattr(-,root,root)
%doc module/idoutils/db/pgsql
%{_bindir}/%{name}-create_pgsqldb.sh
%files devel
%defattr(-,root,root)
%{_includedir}/%{name}/
%files doc
%defattr(-,root,root)
%doc %{icinga_datadir}/docs
%files plugins-eventhandlers
%defattr(0755,root,root)
%{icinga_eventhandlerdir}
%changelog