Skip to content

Commit 5a8ae0b

Browse files
committed
add readme for the systemd service
1 parent 6accff3 commit 5a8ae0b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ diskmon -basedir <directory> -limit 65 \
6666

6767
so that the credentials are not in your shell history.
6868

69+
### Running as a service
70+
71+
Read [Running diskmon as a service](./examples/README.md).
72+
6973
## Build from source
7074

7175
You need to have [Go 1.16](https://golang.org) installed to build the binary yourself.

examples/README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Running diskmon as a service
2+
3+
[systemd](https://systemd.io/)
4+
> systemd is a suite of basic building blocks for a Linux system. It provides a
5+
> system and service manager that runs as PID 1 and starts the rest of the
6+
> system.
7+
8+
I provide a simple systemd [service file](./diskmon.service) that demonstrates
9+
how you might be able to run diskmon as a service using `systemd`. You will
10+
need to adjust paths to diskmon and mount points and flags to fit your
11+
environment and needs.
12+
13+
## Installation
14+
15+
Install the diskmon service
16+
17+
```sh
18+
sudo cp ./examples/diskmon.service /etc/systemd/system/diskmon.service
19+
sudo chmod 664 /etc/systemd/system/diskmon.service
20+
```
21+
22+
Adapt the service file to your needs!
23+
24+
Start diskmon to see if systemd can start diskmon successfully
25+
26+
```sh
27+
sudo systemctl start diskmon
28+
```
29+
30+
Check the service status
31+
32+
```sh
33+
sudo systemctl status diskmon
34+
```
35+
36+
or the diskmon logs
37+
38+
```sh
39+
sudo journalctl --follow --unit diskmon --boot
40+
```
41+
42+
If all went well, enable diskmon to start automatically at boot
43+
44+
```sh
45+
sudo systemctl enable diskmon
46+
```
47+
48+
Reboot and check the status, logs again to see if all is well.
49+
50+
## Limitations
51+
52+
* have not yet figured out how to securly pass the Slack API token. You could
53+
incorporate a subshell command that for example calls your password manager
54+
to pass the token in. This way you would not add the token in plain text into
55+
the service file which is readable by others on your system.

0 commit comments

Comments
 (0)