File nagios-business-process-addon.spec of Package nagios-business-process-addon

#
# spec file for package nagios-business-process-addon
#
# Copyright (c) 2012-2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2015-2016 SUSE LINUX 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/
#

Name:           nagios-business-process-addon
Version:        0.9.6
Release:        1
License:        GPL-2.0+
Summary:        The Nagios Business Process Addon for Icinga
Url:            http://bp-addon.monitoringexchange.org
Group:          System/Monitoring
Source:         %{name}-%{version}.tar.gz
Source1:        nagios-business-process-addon-rpmlintrc
Patch1:         nagios-business-process-addon-0.9.6-fix_apache2.4.patch
BuildRequires:  nagios-rpm-macros
PreReq:         apache2
PreReq:         icinga
Requires:       cron
Requires:       perl-CGI-Simple
Requires:       perl-JSON-XS
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1210
BuildRequires:  systemd
Requires:       perl-LWP-Protocol-https
Requires:       systemd
%else
Requires:       perl-libwww-perl
%endif

%define	shortname nagiosbp
%define apacheuser wwwrun
%define apachegroup www

%description
The AddOn Business Process View takes results of the single nagios checks out
of NDO (Nagios' database) and builds up aggregated states.  How they are
associated is described in one or more config files.  There is the possibility
to make "and" conjuctions, "or" conjunction and other...

A business process (as defined by such a formula) can be used as a part of
another business process.  So You can build up a hirachical structure to
describe the state of Your Application.

%prep
%setup -q
%patch1 -p1

%build
%configure \
	--exec-pref=%{_defaultdocdir}/%{shortname} \
	--libexecdir=%{_bindir} \
	--sysconfdir=%{icinga_sysconfdir}/%{shortname} \
	--with-nagetc=%{icinga_sysconfdir} \
	--with-httpd-conf=%{_sysconfdir}/apache2/conf.d/ \
    --with-cron-d-dir=%{_sysconfdir}/cron.d \
	--with-nagcgiurl=/icinga/cgi-bin \
	--with-naghtmurl=/icinga \
	--datadir=%{_datadir}/%{shortname} \
	--libdir=%{_libdir}/%{shortname} \
	--sbindir=%{_datadir}/%{shortname}/cgi \
	--with-apache-authname="Icinga Access" \
	--localstatedir=%{_localstatedir}/cache/%{shortname}
make %{?_smp_mflags}

%install
mkdir -p %{buildroot}/%{_defaultdocdir}/%{shortname}
make install \
	DESTDIR=%{buildroot} \
	DATADIR=%{buildroot}/%{_datadir}/%{shortname} \
	LIBEXECDIR=%{buildroot}/%{_bindir} \
	LOGDIR=%{buildroot}/%{_localstatedir}/cache/%{shortname} \
	BINDIR=%{buildroot}/%{_bindir} \
	INSTALL_OPTS=
mkdir -p -m 775 %{buildroot}%{_localstatedir}/cache/nagios_bp.sessions
mkdir -p -m 775 %{buildroot}%{_localstatedir}/cache/%{shortname}/cache
# Create sample user.css
cat > %{buildroot}/%{_datadir}/%{shortname}/stylesheets/user.css << EOF
/* For Nagios and Icinga classic use: #nbp_foot_version, #nbp_foot_language, .nbp_text_small, .nbp_text_tiny { font-size:100%; } */
EOF

# Modifications for Icinga
sed -e 's|^ndodb_database=nagios|#ndodb_database=nagios|' \
	-e 's|^#ndodb_database=icinga|ndodb_database=icinga|' \
    -e 's|^ndodb_username=.*|ndodb_username=icinga|' \
    -e 's|^ndodb_password=.*|ndodb_password=icinga|' \
    -e 's|^ndodb_prefix=nagios_|#ndodb_prefix=nagios_|' \
    -e 's|^ndofs_basedir=.*|ndofs_basedir=%{_localstatedir}/cache/%{shortname}|' \
    -e 's|^ndo_livestatus_socket=.*|ndo_livestatus_socket=%{livestatus_socket_file}|' \
    -e 's|^cache_file=.*|cache_file=%{_localstatedir}/cache/%{shortname}/cache/ndo_backend_cache|' \
    -e 's|^#ndodb_prefix=icinga_|ndodb_prefix=icinga_|' \
    %{buildroot}/%{icinga_sysconfdir}/%{shortname}/ndo.cfg-sample \
    > %{buildroot}/%{icinga_sysconfdir}/%{shortname}/ndo.cfg

# dos2unix
sed -i 's/\r$//' %{buildroot}/%{_defaultdocdir}/%{shortname}/INSTALL
rm %{buildroot}/%{_localstatedir}/cache/%{shortname}/cache/ndo_backend_cache

%if 0%{?suse_version} >= 1210
mkdir -p -m 775 %{buildroot}/%{_prefix}/lib/tmpfiles.d/
cat > %{buildroot}/%{_prefix}/lib/tmpfiles.d/nagios-business-process-addon.conf << EOF
d /var/cache/%{shortname} 0775 wwwrun www -
d /var/cache/%{shortname}/cache 0775 wwwrun www -
d /var/cache/%{shortname}/nagios_bp.sessions 0775 wwwrun www -
EOF
%endif

%post
%restart_on_update apache2
%if 0%{?suse_version} >= 1210
systemd-tmpfiles --create nagios-business-process-addon.conf
%endif

%files
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{shortname}
%config(noreplace) /%{_sysconfdir}/cron.d/%{shortname}
%config(noreplace) /%{_sysconfdir}/apache2/conf.d/nagiosbp.conf
%dir %{icinga_sysconfdir}/%{shortname}
%dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}
%config %attr(644,root,root) %{icinga_sysconfdir}/%{shortname}/nagios-bp.conf-sample
%config(noreplace) %attr(644,root,root) %{icinga_sysconfdir}/%{shortname}/settings.cfg
%config(noreplace) %attr(440,%{apacheuser},%{apachegroup})  %{icinga_sysconfdir}/%{shortname}/ndo.cfg*
%{_datadir}/%{shortname}
%{_libdir}/%{shortname}
%{_bindir}/*
%if 0%{?suse_version} >= 1210
%{_prefix}/lib/tmpfiles.d/nagios-business-process-addon.conf
%ghost %dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}
%ghost %dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}/cache
%ghost %dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}/nagios_bp.sessions
%else
%dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}
%dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}/cache
%dir %attr(775,%{apacheuser},%{apachegroup}) %{_localstatedir}/cache/%{shortname}/nagios_bp.sessions
%endif

%changelog
openSUSE Build Service is sponsored by