# Spec file to build a samba_exporter RPM source or binary package %global goipath tobi.backfrak.de/cmd/samba_exporter Name: samba-exporter Version: 1.35.5 Source0: https://github.com/imker25/samba_exporter/archive/refs/tags/1.35.5.tar.gz %global tag 1.35.5 %gometa %global debug_package %{nil} Release: 1.fc40 Summary: Prometheus exporter to get metrics of a samba server License: ASL 2.0 URL: https://github.com/imker25/samba_exporter Distribution: Fedora Group: utils Requires: samba, systemd, filesystem, binutils, man-db, procps-ng BuildRequires: systemd-rpm-macros BuildRequires: go-rpm-macros BuildRequires: golang(github.com/go-kit/log) BuildRequires: golang(github.com/go-kit/log/level) BuildRequires: golang(github.com/prometheus/client_golang/prometheus) BuildRequires: golang(github.com/prometheus/client_golang/prometheus/collectors) BuildRequires: golang(github.com/prometheus/client_golang/prometheus/promhttp) BuildRequires: golang(github.com/prometheus/client_model/go) BuildRequires: golang(golang.org/x/sys/unix) BuildRequires: golang(gopkg.in/alecthomas/kingpin.v2) BuildRequires: golang(github.com/shirou/gopsutil) BuildRequires: golang(github.com/prometheus/procfs) BuildRequires: golang(github.com/tklauser/go-sysconf) BuildRequires: golang(github.com/tklauser/numcpus) BuildRequires: golang(golang.org/x/xerrors) BuildRequires: golang(gopkg.in/check.v1) BuildRequires: golang(gopkg.in/yaml.v3) BuildRequires: rubygem-ronn-ng BuildRequires: procps-ng %define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm %define _unpackaged_files_terminate_build 0 %gopkg %prep %goprep mkdir -p "%{gobuilddir}/src" cp -rpv "%{gobuilddir}/src/tobi.backfrak.de/cmd/samba_exporter/samba_exporter-%{tag}/"* "%{gobuilddir}/src/" echo "%{tag}-fedora" > "%{gobuilddir}/src/VersionMaster.txt" %build GOPATH="$GOPATH:%{gobuilddir}/src/" export BUILDTAGS="netgo osusergo static_build" LDFLAGS="-X main.version=%{tag}" \ %gobuild -o %{gobuilddir}/bin/samba_exporter src/tobi.backfrak.de/cmd/samba_exporter LDFLAGS="-X main.version=%{tag}-fedora" \ %gobuild -o %{gobuilddir}/bin/samba_statusd src/tobi.backfrak.de/cmd/samba_statusd "%{gobuilddir}/src/build/CreateManPage.sh" %install "%{gobuilddir}/src/build/InstallProgram.sh" "%{gobuilddir}/src" %{gobuilddir}/bin %{buildroot}/ install -m 664 "%{gobuilddir}/src/LICENSE" "%{buildroot}/usr/share/doc/samba-exporter/LICENSE" install -d -m 775 "%{buildroot}/usr/share/man/man1/" install -m 664 "%{gobuilddir}/src/src/man/samba_exporter.1.gz" "%{buildroot}/usr/share/man/man1/samba_exporter.1.gz" install -m 664 "%{gobuilddir}/src/src/man/samba_statusd.1.gz" "%{buildroot}/usr/share/man/man1/samba_statusd.1.gz" install -m 664 "%{gobuilddir}/src/src/man/start_samba_statusd.1.gz" "%{buildroot}/usr/share/man/man1/start_samba_statusd.1.gz" %check export GOPATH="$GOPATH:%{gobuilddir}/src/:/usr/share/gocode/" %gotest tobi.backfrak.de/cmd/samba_exporter %gotest tobi.backfrak.de/cmd/samba_statusd %gotest tobi.backfrak.de/internal/smbexporterbl/pipecomunication %gotest tobi.backfrak.de/internal/smbexporterbl/smbexporter %gotest tobi.backfrak.de/internal/smbexporterbl/smbstatusreader %gotest tobi.backfrak.de/internal/smbexporterbl/statisticsGenerator %gotest tobi.backfrak.de/internal/commonbl %gotest tobi.backfrak.de/internal/smbstatusdbl %pre if [ $1 == 2 ];then # Stop services before install in case of package upgrade systemctl stop samba_exporter.service systemctl stop samba_statusd.service fi %post # Add samba-exporter user if needed if ! getent group samba-exporter > /dev/null ; then groupadd -r samba-exporter fi if ! getent passwd samba-exporter > /dev/null ; then adduser --system --no-create-home --home-dir /nonexistent --gid samba-exporter --shell /bin/false --comment "samba-exporter daemon" samba-exporter || true fi # Ensure the daemons are known systemctl daemon-reload if [ $1 == 1 ];then # Ensure the daemons start automaticaly in case of package installation systemctl enable samba_statusd.service systemctl enable samba_exporter.service fi # Ensure the daemons run the latest version systemctl start samba_statusd.service systemctl start samba_exporter.service # Ensure man-db is updated mandb > /dev/null %preun if [ $1 == 0 ];then request_pipe_file="/run/samba_exporter.request.pipe" response_pipe_file="/run/samba_exporter.response.pipe" # Stop the services before removing the package systemctl stop samba_statusd.service systemctl stop samba_exporter.service if [ -p "$request_pipe_file" ]; then rm "$request_pipe_file" fi if [ -p "$response_pipe_file" ]; then rm "$response_pipe_file" fi fi %postun if [ $1 == 0 ];then # When the package got removed the service files got deleted. So systemd can now remove the services from its internal db systemctl daemon-reload if [ -d "/usr/share/doc/samba-exporter" ]; then rm -rf "/usr/share/doc/samba-exporter" fi fi %description This is a prometheus exporter to get metrics of a samba server. It uses smbstatus to collect the data and converts the result into prometheus style data. The prometheus style data can be requested manually on port 9922 using a http client. Or a prometheus database sever can be configured to collect the data by scraping port 9922 on the samba server. %files %config(noreplace) "/etc/default/samba_exporter" %config(noreplace) "/etc/default/samba_statusd" "/lib/systemd/system/samba_exporter.service" "/lib/systemd/system/samba_statusd.service" "/usr/bin/samba_exporter" "/usr/bin/samba_statusd" "/usr/bin/start_samba_statusd" %dir "/usr/share/" %docdir "/usr/share/doc/" %docdir "/usr/share/doc/samba-exporter/" %doc "/usr/share/doc/samba-exporter/README.md" %license "/usr/share/doc/samba-exporter/LICENSE" %docdir "/usr/share/doc/samba-exporter/docs/" %docdir "/usr/share/doc/samba-exporter/docs/DeveloperDocs/" %doc "/usr/share/doc/samba-exporter/docs/DeveloperDocs/ActionsAndReleases.md" %doc "/usr/share/doc/samba-exporter/docs/DeveloperDocs/Compile.md" %doc "/usr/share/doc/samba-exporter/docs/DeveloperDocs/Hints.md" %doc "/usr/share/doc/samba-exporter/docs/Index.md" %docdir "/usr/share/doc/samba-exporter/docs/Installation/" %doc "/usr/share/doc/samba-exporter/docs/Installation/InstallationGuide.md" %doc "/usr/share/doc/samba-exporter/docs/Installation/SupportedVersions.md" %docdir "/usr/share/doc/samba-exporter/docs/UserDocs/" %doc "/usr/share/doc/samba-exporter/docs/UserDocs/Concept.md" %doc "/usr/share/doc/samba-exporter/docs/UserDocs/ServiceIntegration.md" %doc "/usr/share/doc/samba-exporter/docs/UserDocs/UserGuide.md" %docdir "/usr/share/doc/samba-exporter/docs/assets/" %doc "/usr/share/doc/samba-exporter/docs/assets/Samba-Dashboard.png" %doc "/usr/share/doc/samba-exporter/docs/assets/samba-exporter.icon.png" %docdir "/usr/share/doc/samba-exporter/grafana/" %doc "/usr/share/doc/samba-exporter/grafana/SambaService.json" %doc "/usr/share/man/man1/samba_exporter.1.gz" %doc "/usr/share/man/man1/samba_statusd.1.gz" %doc "/usr/share/man/man1/start_samba_statusd.1.gz" %changelog * Sun Nov 10 2024 Tobias Zellner - 1.35.5 - doc: Update list of supported versions - feat: Create packages for 2024 autumn versions (MR #144) Add package for Ubuntu 24.10 - #141 Add package for Fedora 41 - #142 Remove package for Ubuntu 23.10 - #138 Remove package for Fedora 39 --------- Co-authored-by: Tobias Zellner - Ensure artefacts have unique name - feat: Remove Ubuntu 23.10 package build (Issue: #138) (MR #143) - fix: Update download-artifact action from v3 to v4, Issue #139 (MR #140) - Update download-artifact action from v3 to v4 Issue #139 * Tue Jul 09 2024 Tobias Zellner - 1.34.2 - fix(example): grafana legend typo Loks->Locks (#137) - Fix debian package build for not pre releases * Thu Apr 25 2024 Tobias Zellner - 1.33.5 - Fix debian package build - feat: Ubuntu 24.04 and Fedora 40 support (MR #136) - Update supported version table for #134 and #135 - Fix for #135 - Fix for #134 --------- Co-authored-by: Tobias Zellner - docs: Add an example and screenshot about grafana import dashboard with json file (MR #133) - Update doc, append default port 9922 to json example - Update document with an example to import dashboard with json file. - Upload a screenshot picture about grafana import dashboard. - Append default port 9922 into json example file. Signed-off-by: Jones Syue --------- Signed-off-by: Jones Syue Co-authored-by: imker <39692633+imker25@users.noreply.github.com> - Fix rpm package build for Fedora 28 - Update to prometheus client v1.19 * Wed Apr 24 2024 Tobias Zellner - 1.33.4 - feat: Ubuntu 24.04 and Fedora 40 support (MR #136) - Update supported version table for #134 and #135 - Fix for #135 - Fix for #134 --------- Co-authored-by: Tobias Zellner - docs: Add an example and screenshot about grafana import dashboard with json file (MR #133) - Update doc, append default port 9922 to json example - Update document with an example to import dashboard with json file. - Upload a screenshot picture about grafana import dashboard. - Append default port 9922 into json example file. Signed-off-by: Jones Syue --------- Signed-off-by: Jones Syue Co-authored-by: imker <39692633+imker25@users.noreply.github.com> - Fix rpm package build for Fedora 28 - Update to prometheus client v1.19