File monitoring-plugins-nagiostats.spec of Package monitoring-plugins-nagiostats

#
# spec file for package monitoring-plugins-nagiostats
#
# Copyright (c) 2012-2014 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/
#


Name:           monitoring-plugins-nagiostats
Version:        1.2
Release:        100
Summary:        Graph various performance statistics over time using pnp4nagios
License:        GPL-3.0+
Group:          System/Monitoring
Url:            https://www.monitoringexchange.org/inventory/Check-Plugins/Software/Nagios/check_nagiostats
Source0:        check_nagiostats
Source1:        run_stats
BuildRequires:  nagios-rpm-macros
BuildRequires:  pnp4nagios
Provides:       nagios-plugins-nagiostats = %{version}-%{release}
Obsoletes:      nagios-plugins-nagiostats < %{version}-%{release}
Requires:       monitoring_daemon
Requires:       cron
Recommends:     pnp4nagios
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
check_nagiostats calls the "nagiostats" or "icingastats" executable (which
comes with Nagios or Icinga itself) to read various data about the running
Nagios/Icinga instance. See the output of "nagiostats -h" or "icingastats -h"
for a detailed list of what data you can get that way.

%prep

%build

%install
mkdir -p %{buildroot}/%{nagios_plugindir}
sed -e "s|/usr/local/nagios/bin/nagiostats|%{_sbindir}/nagiostats|g" %{SOURCE0} > %{buildroot}/%{nagios_plugindir}/check_nagiostats
chmod +x %{buildroot}/%{nagios_plugindir}/check_nagiostats
# link pnp4nagios template into working folder
mkdir -p %{buildroot}%{pnp4nagios_templatedir}
pushd %{buildroot}%{pnp4nagios_templatedir} >/dev/null
ln -s ../templates.dist/nagiostats.php .
popd >/dev/null
install -Dm755 %{SOURCE1} %{buildroot}%{_bindir}/run_nagiostats
mkdir -p %{buildroot}%{_sysconfdir}/cron.d
cat >> %{buildroot}%{_sysconfdir}/cron.d/run_nagiostats << EOF
# Please adapt the two configuration variables here to your setup in 
# Icinga or Nagios (as the check will work as passive check, you need 
# to align the variables below to your service definition.
# ...and please do not forget to uncomment the cron entry afterward.
HOST=$(/bin/hostname -s)
CHECKNAME='stats'
#-*/5 * * * *   root test -x %{_bindir}/run_nagiostats && %{_bindir}/run_nagiostats -H "$HOST" -c "$CHECKNAME"
EOF

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
# avoid build dependecy of nagios - own the dirs
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%{_bindir}/run_nagiostats
%config(noreplace) %{_sysconfdir}/cron.d/run_nagiostats
%{nagios_plugindir}/check_nagiostats
%config(noreplace) %{pnp4nagios_templatedir}/nagiostats.php

%changelog