CLI tool that uploads the Hetzner Storage Box usage data from the Hetzner API to influxdb on a daily basis
-
Configure
storagebox_exporter.json(see the configuration section below). -
Copy
storagebox-exporter.containerto$HOME/.config/containers/systemd/storagebox-exporter.container -
Copy
storagebox-exporter.timerto$HOME/.config/systemd/user/storagebox-exporter.timer -
Reload the user's systemd daemon
systemctl --user daemon-reload
-
Run it.
systemctl --user start storagebox-exporter.timer
-
Configure
storagebox_exporter.json(see the configuration section below). -
Run it.
docker compose up --detach
-
Build the docker image.
docker build . --tag storagebox-exporter -
Configure
storagebox_exporter.json(see the configuration section below). -
Run it.
docker run --rm --init --tty --interactive --read-only --cap-drop ALL --security-opt no-new-privileges:true --cpus 2 -m 64m --pids-limit 16 --volume ./storagebox_exporter.json:/app/storagebox_exporter.json:ro ghcr.io/rare-magma/storagebox-exporter:latest
For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph.
make build
make install
$EDITOR $HOME/.config/storagebox_exporter.json-
Build
storagebox_exporterwith:go build -ldflags="-s -w" -o storagebox_exporter main.go -
Copy
storagebox_exporterto$HOME/.local/bin/and make it executable. -
Copy
storagebox_exporter.jsonto$HOME/.config/, configure it (see the configuration section below) and make it read only. -
Copy the systemd unit and timer to
$HOME/.config/systemd/user/:cp storagebox-exporter.* $HOME/.config/systemd/user/
-
and run the following command to activate the timer:
systemctl --user enable --now storagebox-exporter.timer
It's possible to trigger the execution by running manually:
systemctl --user start storagebox-exporter.serviceThe config file has a few options:
{
"InfluxDBHost": "influxdb.example.com",
"InfluxDBApiToken": "ZXhhbXBsZXRva2VuZXhhcXdzZGFzZGptcW9kcXdvZGptcXdvZHF3b2RqbXF3ZHFhc2RhCg==",
"Org": "home",
"Bucket": "storagebox",
"ApiToken": "ZXhhbXBsZXRva2VuZXhhcXdzZGFzZGptcW9kcXdvZGptcXdvZHF3b2RqbXF3ZHFhc"
}InfluxDBHostshould be the FQDN of the influxdb server.Orgshould be the name of the influxdb organization that contains the energy consumption data bucket defined below.Bucketshould be the name of the influxdb bucket that will hold the energy consumption data.InfluxDBApiTokenshould be the influxdb API token value.- This token should have write access to the
BUCKETdefined above.
- This token should have write access to the
ApiTokenshould be the token used to access the hetzner api.- This can be configured in the Hetzner Console. Log in, choose a Project, go to Security → API Tokens and create a new read only token.
Check the systemd service logs and timer info with:
journalctl --user --unit storagebox-exporter.service
systemctl --user list-timers- size: Total space in bytes
- used: Used space in bytes
- used_data: Used space by data in bytes
- used_snapshot: Used space by snapshots in bytes
storagebox_stats,id=XXXX,name=box,type=bxxx,status=active,location=fsn1,samba=false,ssh=true,external_reachability=true,server=username.your-storagebox.de,host=FSN1-BXXXX,webdav=false,zfs=true size=5497558138880,used=3644984393728,used_data=2802055118848,used_snapshot=842929274880 1751132140
In storagebox-dashboard.json there is an example of the kind of dashboard that can be built with storagebox-exporter data:
Import it by doing the following:
- Create a dashboard
- Click the dashboard's settings button on the top right.
- Go to JSON Model and then paste there the content of the
storagebox-dashboard.jsonfile.
For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.
make uninstallRun the following command to deactivate the timer:
systemctl --user disable --now storagebox-exporter.timerDelete the following files:
~/.local/bin/storagebox_exporter
~/.config/storagebox_exporter.json
~/.config/systemd/user/storagebox-exporter.timer
~/.config/systemd/user/storagebox-exporter.serviceThis project takes inspiration from the following:
