diff --git a/dist/package/openSUSE-release-tools.spec b/dist/package/openSUSE-release-tools.spec index 9d98fcde..4bc74990 100644 --- a/dist/package/openSUSE-release-tools.spec +++ b/dist/package/openSUSE-release-tools.spec @@ -148,6 +148,7 @@ Group: Development/Tools/Other BuildArch: noarch # TODO Update requirements. Requires: osclib = %{version} +Requires(pre): shadow # TODO Requires: python-influxdb, but package does not exist in Factory, but # present in Cloud:OpenStack:Master/python-influxdb. Recommends: python-influxdb @@ -342,8 +343,13 @@ exit 0 %postun maintenance %service_del_postun osrt-maintenance-incidents.service -# TODO Provide metrics service once #1006 is resolved. +%pre metrics +getent passwd osrt-metrics > /dev/null || \ + useradd -r -m -s /sbin/nologin -c "user for openSUSE-release-tools-metrics" osrt-metrics +exit 0 + %postun metrics +%systemd_postun # If grafana-server.service is enabled then restart it to load new dashboards. if [ -x /usr/bin/systemctl ] && systemctl is-enabled grafana-server ; then /usr/bin/systemctl try-restart --no-block grafana-server @@ -502,6 +508,12 @@ exit 0 %{_bindir}/osrt-metrics %{_datadir}/%{source_dir}/metrics %{_datadir}/%{source_dir}/metrics.py +# To avoid adding grafana as BuildRequires since it does not live in same repo. +%dir %{_localstatedir}/lib/grafana +%dir %{_localstatedir}/lib/grafana/dashboards +%{_localstatedir}/lib/grafana/dashboards/%{name} +%{_unitdir}/osrt-metrics@.service +%{_unitdir}/osrt-metrics@.timer %files repo-checker %defattr(-,root,root,-) diff --git a/systemd/osrt-metrics@.service b/systemd/osrt-metrics@.service new file mode 100644 index 00000000..e76d88dc --- /dev/null +++ b/systemd/osrt-metrics@.service @@ -0,0 +1,12 @@ +[Unit] +Description=openSUSE Release Tools: metrics for %i + +[Service] +Type=oneshot +User=osrt-metrics +SyslogIdentifier=osrt-metrics +ExecStart=/usr/bin/osrt-metrics --debug -p "%i" +TimeoutStartSec=8 hour + +[Install] +WantedBy=multi-user.target diff --git a/systemd/osrt-metrics@.timer b/systemd/osrt-metrics@.timer new file mode 100644 index 00000000..039f2cdf --- /dev/null +++ b/systemd/osrt-metrics@.timer @@ -0,0 +1,10 @@ +[Unit] +Description=openSUSE Release Tools: metrics for %i + +[Timer] +OnBootSec=120 +OnCalendar=daily +Unit=osrt-metrics@%i.service + +[Install] +WantedBy=timers.target