# 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.32.9 Source0: https://github.com/imker25/samba_exporter/archive/refs/tags/1.32.9.tar.gz %global tag 1.32.9 %gometa %global debug_package %{nil} Release: 1.fc38 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 * Wed Mar 13 2024 Tobias Zellner - 1.32.9 - Ensure 'runningOnUbuntuFocal' works on older golang versions - Ignore some tests on ubuntu focal - Fix creating of test log file directory - Work on package build errors - Work on problems during package build - feat: Add option to write logs into a file #130 (MR #131) Add the new parameter -log-file-path string to the command line interface. Write logs into the given file instead of stdout/stderr when this parameter is given. - Tell if '-not-expose-share-details' parameter is set in verbose mode - feat: Add logger abstraction and fix issue #128 (MR #129) - feat: not export share data (fix for #126) (MR #127) - add a not-expose-share-details flag, so that users can decide whether details of the available shares will be exported or not (see request #126) - add the flag to all required documentation - add tests for this functionality * Sun Jan 21 2024 Tobias Zellner - 1.31.8 - fix: Ensure numeric formating is the same for all services - fix: Ensure time stamp parsing will work in most cases (MR #125) - fix: Add a fix for shares that contain white spaces in the name #123 (MR #124) - Fix for issue #123 - Update documentation with known issues - Switch to golang version 1.21 for development and ubuntu 23.10 release - part 2 - Remove container images during publish builds, so agents will not run out of diskspace - Disable installation tests since they are not testable on dev machines - 2. part - Disable installation tests since they are not testable on dev machines - Switch to golang version 1.21 for development and ubuntu 23.10 release * Thu Oct 26 2023 Tobias Zellner - 1.30.1 - feat: Create packages for Ubuntu 23.10 and Fedora 39 (MR #122) - Fix for #120 - Create package for Ubuntu 23.10 - Fix for #121 - Create package for Fedora 39 * Wed Sep 20 2023 Tobias Zellner - 1.29.6 - Work on #118 - fix header validation - Work on #118 - Allow empty data in the protocol - Work on #118, ensure samba-exporter can handle total empty response from smbstatus - docs: Update SambaService.json (MR #119) fix typo (crated -> created) - fix: Solve problems reported with #118 #(LOCK_REQUEST response not expected or in wrong format) - add test case for new 'No locked files' response - fix: Ensure there are no multiple entries in conf/distributions * Sat Jun 17 2023 Tobias Zellner - 1.28.5 - fix: Add reprepo configuration for bookwork package - feat: Create and publish package for Debian 12 (bookworm) #105 (MR #115) - feat: Use golang 1.20 by default #113 (MR #114) - Configure 'go 1.20' in go.mod files - Use go v1.20 in CI job - Use debian bookworm for integration tests - feat: Enhance table parsing algorithm #107 (#112) - Use enhanced way to parse LockData, ShareData and ProcessData - fix: txpO in metric name (porcesses -> processes) - feature #101: Add ClusterNodeID statistics when smb is running in custer mode (MR #106) * Wed Apr 26 2023 Tobias Zellner - 1.27.5 - feat: Create Fedora 38 package #99 (#104) - Add rpm package build for fedora-38 - Remove support for fedora 36 - Fix pages repo update script - Use fedora 38 for rpm package test builds - feat: Create lobster package and disable kinetic package build #98 (#103) - fix: #100 enhance logging and add more conversion checks - fix: smb cluster version bug #100 (MR #102) - Add test data - Add tests - Update documentation with restrictions for cluster mode - Fix publish RPM script