Skip to content

Commit d33ed4b

Browse files
committed
fix: can execute only with root
1 parent add20cb commit d33ed4b

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
FROM ubuntu:24.04
22

3+
RUN apt-get update
4+
&& apt-get install -y nvme-cli
5+
&& rm -rf /var/lib/apt/lists/*
6+
37
COPY nvme_exporter /usr/bin/nvme_exporter
48

59
EXPOSE 9998

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ Supported [NVMe CLI](https://github.com/linux-nvme/nvme-cli) versions:
2525
* Grafana: In [resources](resources/grafana/) for dashboards.
2626
* [smart-log dashboard](https://grafana.com/grafana/dashboards/14706)
2727
* Prometheus: In [resources](resources/prom/) for recording and alert rules.
28+
* Systemd: In [resources](resources/systemd/) for executing the exporter as unit.
29+
* Scripts: In [resources](resources/scripts/) for package installation hooks.
2830

2931
## Running
3032

31-
Running the exporter requires the nvme-cli package to be installed on the host.
33+
Running the exporter requires the nvme-cli package to be installed on the host and be `root` account.
3234

3335
``` bash
34-
./nvme_exporter -h
36+
nvme_exporter -h
3537
```
3638

3739
### Flags
@@ -41,9 +43,3 @@ Running the exporter requires the nvme-cli package to be installed on the host.
4143
|port | Listen port number. Type: String. | `9998` |
4244
|ocp | Enable OCP smart log metrics. Type: Bool. | `false` |
4345
|endpoint | The endpoint to query for metrics. Type: String. | `/metrics` |
44-
45-
## Build
46-
47-
``` bash
48-
go build .
49-
```

cmd/nvme_exporter/nvme_exporter

-11.9 MB
Binary file not shown.

resources/scripts/post-install.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ fi
1010

1111
echo "Detected systemd as init system, proceeding"
1212

13-
useradd -r nvme_exporter -s /bin/false || true
14-
1513
systemctl daemon-reload
1614

1715
systemctl enable nvme_exporter.service

resources/scripts/post-remove.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/sh
22
set -e
33

4-
userdel -f nvme_exporter || true
5-
64
systemctl daemon-reload

resources/systemd/nvme_exporter.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ After=network-online.target
55
[Service]
66
Type=simple
77

8-
User=nvme_exporter
9-
Group=nvme_exporter
8+
User=root
9+
Group=root
1010

1111
ExecStart=/usr/bin/nvme_exporter
1212

0 commit comments

Comments
 (0)