Skip to content

Commit

Permalink
Add RPM spec file and systemd service unit. (#26)
Browse files Browse the repository at this point in the history
* Add RPM spec file and systemd service unit.

* Move to packaging/rpm

---------

Co-authored-by: Matt Mix <[email protected]>
Co-authored-by: mattmix <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2023
1 parent a0e27e4 commit 74271ef
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packaging/rpm/cgroup_exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[Unit]
Description=cgroup exporter
After=network.target network-online.target

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/cgroup_exporter
ExecStart=/usr/sbin/cgroup_exporter --config.paths $CONFIG_PATHS $OPTIONS
Restart=always
User=cgroup_exporter
Group=cgroup_exporter
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
ProtectHome=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
MemoryDenyWriteExecute=yes
LockPersonality=yes
RemoveIPC=yes
CapabilityBoundingSet=
SystemCallFilter=@system-service

[Install]
WantedBy=multi-user.target
45 changes: 45 additions & 0 deletions packaging/rpm/cgroup_exporter.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Name: cgroup_exporter
Version: 0.9.1
Release: 1%{?dist}
Summary: The cgroup_exporter produces metrics from cgroups.

License: Apache License
Source0: %{name}-%{version}.tar.gz
URL: https://github.com/treydock/cgroup_exporter

BuildRequires: go-toolset
Requires: systemd

%description

The cgroup_exporter produces metrics from cgroups.

This exporter by default listens on port 9306 and all metrics are exposed via the /metrics endpoint.

%global debug_package %{nil}

%prep
%autosetup

%build
go build -v -o %{name}

%install
install -Dpm 0755 %{name} %{buildroot}%{_sbindir}/%{name}
install -Dpm 0644 packaging/rpm/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -Dpm 0644 packaging/rpm/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}

%clean
rm -rf %{buildroot}

%pre
%{_sbindir}/useradd -c "cgroup exporter user" -s /bin/false -r -d / cgroup_exporter 2>/dev/null || :

%files
%{_sbindir}/%{name}
%{_unitdir}/%{name}.service
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}

%changelog
* Fri Nov 10 2023 Initial RPM
-
4 changes: 4 additions & 0 deletions packaging/rpm/cgroup_exporter.sysconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# cgroup subsystem paths to look at, comma separated
CONFIG_PATHS=/user.slice
# Additional options
OPTIONS=

0 comments on commit 74271ef

Please sign in to comment.