File ntpmon.spec of Package ntpmon
#
# spec file for package ntpmon
#
# Copyright (c) 2024, Martin Hauke <mardnh@gmx.de>
#
# 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 https://bugs.opensuse.org/
#
Name:           ntpmon
Version:        3.0.8
Release:        0
Summary:        Monitor/check NTP metrics
License:        AGPL-3.0-or-later
Group:          System/Monitoring
URL:            https://github.com/paulgear/ntpmon
Source:         https://github.com/paulgear/ntpmon/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        %{name}.sysusers
BuildRequires:  python3-Jinja2
BuildRequires:  python3-psutil
BuildRequires:  python3-pytest
BuildRequires:  sysuser-tools
Requires:       python3-psutil
Requires:       python3-prometheus-client
Requires(pre):  %{name}-common = %{version}
BuildArch:      noarch
%description
This application is a flexible monitor/checker for the health of an
NTP daemon, supporting chronyd and ntpd. It supports reporting metrics
to collectd, Nagios, prometheus (the default), and telegraf.
%package common
Summary:        System user 'ntpmon'
BuildArch:      noarch
%sysusers_requires
%description common
This application is a flexible monitor/checker for the health of an
NTP daemon, supporting chronyd and ntpd. It supports reporting metrics
to collectd, Nagios, prometheus (the default), and telegraf.
This subpackage sets up the system user for the rest of ntpmon.
%prep
%setup -q
sed -i 's|#!%{_bindir}/env python3|#!%{_bindir}/python3|g' \
  src/ntpmon.py \
  src/check_ntpmon.py
sed -i -e '/^#!\//, 1d' \
  src/info.py \
  src/jinja2_render.py \
  src/peers.py \
  src/process.py \
  src/readvar.py \
  src/tailer.py
%build
%make_build
%sysusers_generate_pre %{SOURCE1} %{name} %{name}.conf
%install
make install PREFIX=%{_prefix} SYSTEMD_SERVICE_DIR=%{_unitdir} DESTDIR=%{buildroot}
install -Dpm0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/%{name}.conf
%pre
%service_add_pre ntpmon.service
%pre common -f %{name}.pre
%preun
%service_del_preun ntpmon.service
%post
%service_add_post ntpmon.service
%postun
%service_del_postun ntpmon.service
%files
%license COPYING.txt
%doc CHANGELOG.md README.md SECURITY.md
%config(noreplace) %{_sysconfdir}/default/ntpmon
%{_bindir}/check_ntpmon
%{_bindir}/ntpmon
%dir %{_datadir}/ntpmon
%{_datadir}/ntpmon/*.py
%{_unitdir}/ntpmon.service
%files common
%{_sysusersdir}/%{name}.conf
%changelog