Skip to content

Commit 74271ef

Browse files
mattmixmattmix
andauthored
Add RPM spec file and systemd service unit. (#26)
* 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]>
1 parent a0e27e4 commit 74271ef

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[Unit]
2+
Description=cgroup exporter
3+
After=network.target network-online.target
4+
5+
[Service]
6+
Type=simple
7+
EnvironmentFile=-/etc/sysconfig/cgroup_exporter
8+
ExecStart=/usr/sbin/cgroup_exporter --config.paths $CONFIG_PATHS $OPTIONS
9+
Restart=always
10+
User=cgroup_exporter
11+
Group=cgroup_exporter
12+
NoNewPrivileges=yes
13+
PrivateTmp=yes
14+
PrivateDevices=yes
15+
DevicePolicy=closed
16+
ProtectSystem=strict
17+
ProtectHome=yes
18+
ProtectControlGroups=yes
19+
ProtectKernelModules=yes
20+
ProtectKernelTunables=yes
21+
RestrictAddressFamilies=AF_INET AF_INET6
22+
RestrictNamespaces=yes
23+
RestrictRealtime=yes
24+
RestrictSUIDSGID=yes
25+
MemoryDenyWriteExecute=yes
26+
LockPersonality=yes
27+
RemoveIPC=yes
28+
CapabilityBoundingSet=
29+
SystemCallFilter=@system-service
30+
31+
[Install]
32+
WantedBy=multi-user.target

packaging/rpm/cgroup_exporter.spec

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Name: cgroup_exporter
2+
Version: 0.9.1
3+
Release: 1%{?dist}
4+
Summary: The cgroup_exporter produces metrics from cgroups.
5+
6+
License: Apache License
7+
Source0: %{name}-%{version}.tar.gz
8+
URL: https://github.com/treydock/cgroup_exporter
9+
10+
BuildRequires: go-toolset
11+
Requires: systemd
12+
13+
%description
14+
15+
The cgroup_exporter produces metrics from cgroups.
16+
17+
This exporter by default listens on port 9306 and all metrics are exposed via the /metrics endpoint.
18+
19+
%global debug_package %{nil}
20+
21+
%prep
22+
%autosetup
23+
24+
%build
25+
go build -v -o %{name}
26+
27+
%install
28+
install -Dpm 0755 %{name} %{buildroot}%{_sbindir}/%{name}
29+
install -Dpm 0644 packaging/rpm/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
30+
install -Dpm 0644 packaging/rpm/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
31+
32+
%clean
33+
rm -rf %{buildroot}
34+
35+
%pre
36+
%{_sbindir}/useradd -c "cgroup exporter user" -s /bin/false -r -d / cgroup_exporter 2>/dev/null || :
37+
38+
%files
39+
%{_sbindir}/%{name}
40+
%{_unitdir}/%{name}.service
41+
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
42+
43+
%changelog
44+
* Fri Nov 10 2023 Initial RPM
45+
-
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# cgroup subsystem paths to look at, comma separated
2+
CONFIG_PATHS=/user.slice
3+
# Additional options
4+
OPTIONS=

0 commit comments

Comments
 (0)