go-transmission-stats/README.md

68 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2023-03-25 05:14:51 +01:00
# go-transmission-stats
Get stats from a remote Transmission instance using the Transmission RPC API, and output the stats into a HTML document using Go's html/template library.
For other people using this, change the stylesheet in `template.html` to your preferred one. Also edit the following for your remote Transmission instance:
2023-03-26 00:24:07 +01:00
```shell
export RPC_HOST="<ip address of Transmission server>"
export RPC_USER="<rpc username>"
export RPC_PASSWORD="<rpc password>"
2023-03-26 13:35:45 +02:00
export HTML_FILE="/path/to/html/output/file.html"
export GMI_FILE="/path/to/gemini/output/file.gmi"
2023-03-25 05:14:51 +01:00
```
2023-03-25 23:33:51 +01:00
My personal use case for this involves running the Go binary `go-transmission-stats` on a systemd timer that triggers the corresponding service every 12 hours.
2023-03-25 05:14:51 +01:00
First build the binary:
``` shell
git clone https://codeberg.org/hyperreal/go-transmission-stats
cd go-transmission-stats
go build
```
Move the binary to a location in PATH:
``` shell
sudo mv go-transmission-stats /usr/local/bin/
```
Create the systemd service:
``` ini
[Unit]
Description=go-transmission-stats service
[Service]
Type=oneshot
2023-03-26 13:35:45 +02:00
ExecStart=/usr/local/bin/go-transmission-stats
2023-03-25 05:14:51 +01:00
User=<your user>
Group=<your user's group>
2023-03-25 06:04:01 +01:00
WorkingDirectory=/home/user/go-transmission-stats
2023-03-26 04:05:51 +02:00
Environment="RPC_HOST=<ip address of Transmission server>"
Environment="RPC_USER=<rpc username>"
Environment="RPC_PASSWORD=<rpc password>"
2023-03-26 13:35:45 +02:00
Environment="HTML_FILE=/path/to/html/output/file.html"
Environment="GMI_FILE=/path/to/gemini/output/file.gmi"
2023-03-25 05:14:51 +01:00
```
Create the systemd timer:
``` ini
[Unit]
Description=go-transmission-stats timer
[Timer]
OnCalendar=00/12:00
[Install]
WantedBy=default.target
```
Move the files to systemd directory and enable the systemd timer:
``` shell
sudo mv go-transmission-stats.service go-transmission-stats.timer /etc/systemd/system/
sudo systemctl enable --now go-transmission-stats.timer
```