File monitoring-plugins-fs_frag.spec of Package monitoring-plugins-fs_frag
#
# spec file for package monitoring-plugins-fs_frag
#
# Copyright (c) 2021 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: monitoring-plugins-fs_frag
Version: 0.1
Release: 0
Summary: Fragmentation of local file systems
License: MIT
Group: System/Monitoring
URL: https://www.linux-schulserver.de/
Source0: check_fs_frag
BuildRequires: monitoring-plugins-common
BuildRequires: nagios-rpm-macros
%if 0%{?suse_version} > 1310
BuildRequires: sudo
Requires: sudo
%endif
Requires: monitoring-plugins-common
Requires: bc
Requires: coreutils
Requires: e2fsprogs
Requires: sed
Requires: xfsprogs
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%description
This monitoring plugin checks the fragementation of local file systems
(xfs, ext2, ext3, ext4).
%prep
%build
%install
install -D -m0755 %{SOURCE0} %{buildroot}%{nagios_plugindir}/check_fs_frag
mkdir -p %{buildroot}%{_sysconfdir}/sudoers.d/
cat >> %{buildroot}%{_sysconfdir}/sudoers.d/check_fs_frag << EOF
nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_fs_frag
icinga ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_fs_frag
EOF
mkdir -p %{buildroot}%{nrpe_sysconfdir}
cat >> %{buildroot}%{nrpe_sysconfdir}/check_fs_frag.cfg << EOF
command[check_fs_frag]=sudo /usr/lib/nagios/plugins/check_fs_frag
EOF
%check
%buildroot/%{nagios_plugindir}/check_fs_frag --help
if [ "$?" != "0" ]; then
echo "Test failed: check_fs_frag can not print help text" >&2
exit 1
fi
%files
%defattr(-,root,root)
# avoid build dependecy of nagios - own the dirs
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%dir %{nrpe_sysconfdir}
%{nagios_plugindir}/check_fs_frag
%if 0%{?suse_version} > 1310
%config(noreplace) %{_sysconfdir}/sudoers.d/check_fs_frag
%endif
%config(noreplace) %{nrpe_sysconfdir}/check_fs_frag.cfg
%changelog