59 lines
1.5 KiB
Markdown
59 lines
1.5 KiB
Markdown
|
# 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:
|
||
|
|
||
|
```go
|
||
|
transmissionbt, err := transmissionrpc.New("<your Transmission server ip>", "username", "password", nil)
|
||
|
```
|
||
|
|
||
|
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. The systemd service looks like this:
|
||
|
|
||
|
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
|
||
|
ExecStart=/usr/local/bin/go-transmission-stats
|
||
|
User=<your user>
|
||
|
Group=<your user's group>
|
||
|
WorkingDirectory=/home/<your user>/public/html
|
||
|
```
|
||
|
|
||
|
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
|
||
|
```
|