Initial adapted version
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0585672777
commit
f4b0c1d36a
7 changed files with 73 additions and 53 deletions
26
.drone.yml
Normal file
26
.drone.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build and publish
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
include:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: docker build and publish
|
||||||
|
image: plugins/docker
|
||||||
|
environment:
|
||||||
|
REVISION: ${DRONE_COMMIT_SHA}
|
||||||
|
CREATED: ${DRONE_BUILD_CREATED}
|
||||||
|
SOURCE_URL: ${DRONE_GIT_HTTP_URL}
|
||||||
|
settings:
|
||||||
|
purge: true
|
||||||
|
username:
|
||||||
|
from_secret: dockerhub_user
|
||||||
|
password:
|
||||||
|
from_secret: dockerhub_key
|
||||||
|
repo: varakh/hetzner-storagebox-exporter
|
||||||
|
tags:
|
||||||
|
- latest
|
1
.env
1
.env
|
@ -1 +0,0 @@
|
||||||
TAG=1.0
|
|
12
Dockerfile
12
Dockerfile
|
@ -1,4 +1,14 @@
|
||||||
FROM alpine
|
FROM alpine:3
|
||||||
|
LABEL maintainer="Varakh <varakh@varakh.de>" \
|
||||||
|
description="hetzner-storagebox-exporter" \
|
||||||
|
org.opencontainers.image.authors="Varakh" \
|
||||||
|
org.opencontainers.image.revision="${REVISION}" \
|
||||||
|
org.opencontainers.image.vendor="Varakh" \
|
||||||
|
org.opencontainers.image.title="hetzner-storagebox-exporter" \
|
||||||
|
org.opencontainers.image.description="hetzner-storagebox-exporter" \
|
||||||
|
org.opencontainers.image.base.name="alpine:3" \
|
||||||
|
org.opencontainers.artifact.created=${CREATED} \
|
||||||
|
org.opencontainers.image.source=${SOURCE_URL}
|
||||||
|
|
||||||
RUN apk add --no-cache nmap-ncat openssl coreutils openssh
|
RUN apk add --no-cache nmap-ncat openssl coreutils openssh
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
# Hetzner Storage Exporter
|
# Hetzner Storage Exporter
|
||||||
|
|
||||||
|
**Initially forked from https://github.com/gmasil/hetzner-storagebox-exporter**.
|
||||||
|
|
||||||
|
- Applied some improvements
|
||||||
|
- Adapted documentation
|
||||||
|
- Added pipeline for publish to DockerHub
|
||||||
|
|
||||||
This is a simple prometheus exporter to provide storage space metrics of a Hetzner Storagebox.
|
This is a simple prometheus exporter to provide storage space metrics of a Hetzner Storagebox.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
@ -9,15 +15,15 @@ A SSH private key to login via SSH has to be provided and SSH has to be enabled
|
||||||
|
|
||||||
Here you can see an example output of the hetzner-storage-exporter:
|
Here you can see an example output of the hetzner-storage-exporter:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
# HELP hetzner_storage_available Available storage
|
# HELP hetzner_storage_available Available storage in kilobytes
|
||||||
# TYPE hetzner_storage_available gauge
|
# TYPE hetzner_storage_available gauge
|
||||||
# HELP hetzner_storage_used Used storage
|
|
||||||
# TYPE hetzner_storage_used gauge
|
|
||||||
# HELP hetzner_storage_total Total storage
|
|
||||||
# TYPE hetzner_storage_total gauge
|
|
||||||
hetzner_storage_available{host="u123456.your-storagebox.de"} 1062381134
|
hetzner_storage_available{host="u123456.your-storagebox.de"} 1062381134
|
||||||
|
# HELP hetzner_storage_used Used storage in kilobytes
|
||||||
|
# TYPE hetzner_storage_used gauge
|
||||||
hetzner_storage_used{host="u123456.your-storagebox.de"} 11360690
|
hetzner_storage_used{host="u123456.your-storagebox.de"} 11360690
|
||||||
|
# HELP hetzner_storage_total Total storage in kilobytes
|
||||||
|
# TYPE hetzner_storage_total gauge
|
||||||
hetzner_storage_total{host="u123456.your-storagebox.de"} 1073741824
|
hetzner_storage_total{host="u123456.your-storagebox.de"} 1073741824
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -26,44 +32,44 @@ hetzner_storage_total{host="u123456.your-storagebox.de"} 1073741824
|
||||||
Build simply with docker:
|
Build simply with docker:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build .
|
docker build --no-cache -t "varakh/hetzner-storagebox-exporter:latest" .
|
||||||
```
|
```
|
||||||
|
|
||||||
Build with Compose:
|
**Note:** This will build an image called `varakh/hetzner-storagebox-exporter:latest`.
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose build
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** this will build an image called `registry.gmasil.de/docker/hetzner-storage-exporter`, this is my own docker registry.
|
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
You can use the image I uploaded to my docker registry, if you want to use your own build just replace the image name accordingly.
|
|
||||||
|
|
||||||
The exporter will **listen** on **port 80** and exposes it by default.
|
The exporter will **listen** on **port 80** and exposes it by default.
|
||||||
|
|
||||||
You have to provide your username for your storage box via environment variable `USERNAME` and a SSH private key to login.
|
You have to provide your username for your storage box via environment variable `USERNAME` and a SSH private key to login.
|
||||||
Additionally you need a `known_hosts` file to accept the SSH connection.
|
Additionally you need a `known_hosts` file to accept the SSH connection.
|
||||||
|
|
||||||
Usage with docker:
|
Usage with `docker`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -p 80:80 -e "USERNAME=u123456" -v "$(cd ~ && pwd)/.ssh:/root/.ssh" registry.gmasil.de/docker/hetzner-storage-exporter:1.0
|
docker run --rm -p 80:80 -e "USERNAME=u123456" \
|
||||||
|
-v "/home/myuser/.ssh/id_rsa:/root/.ssh/id_rsa" \
|
||||||
|
-v "/home/myuser/.ssh/known_hosts:/root/.ssh/known_hosts" \
|
||||||
|
varakh/hetzner-storagebox-exporter:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Example docker-compose file:
|
Example `docker-compose` file:
|
||||||
|
|
||||||
```bash
|
```yml
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
hetzner-storage-exporter:
|
hetzner-storage-exporter:
|
||||||
image: registry.gmasil.de/docker/hetzner-storage-exporter:1.0
|
container_name: hetzner-storage-exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
image: varakh/hetzner-storagebox-exporter:latest
|
||||||
|
port:
|
||||||
|
- "9494:80"
|
||||||
environment:
|
environment:
|
||||||
- "USERNAME=u123456"
|
- "USERNAME=u123456"
|
||||||
volumes:
|
volumes:
|
||||||
- "/home/peter/.ssh:/root/.ssh"
|
- "/home/myuser/.ssh/id_rsa:/root/.ssh/id_rsa"
|
||||||
|
- "/home/myuser/.ssh/known_hosts:/root/.ssh/known_hosts"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Prometheus
|
## Prometheus
|
||||||
|
@ -83,17 +89,3 @@ scrape_configs:
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** As the exporter will provide the metrics on all URIs, you can leave all defaults like scraping on the `/metrics` URI.
|
**Note:** As the exporter will provide the metrics on all URIs, you can leave all defaults like scraping on the `/metrics` URI.
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
[GNU GPL v3 License](LICENSE.md)
|
|
||||||
|
|
||||||
Hetzner Storage Exporter is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Hetzner Storage Exporter is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
17
check-storage.sh
Normal file → Executable file
17
check-storage.sh
Normal file → Executable file
|
@ -5,17 +5,16 @@ set -eu
|
||||||
PORT=${PORT:-23}
|
PORT=${PORT:-23}
|
||||||
HOST=${HOST:-$USERNAME.your-storagebox.de}
|
HOST=${HOST:-$USERNAME.your-storagebox.de}
|
||||||
|
|
||||||
echo "# HELP hetzner_storage_available Available storage"
|
|
||||||
echo "# TYPE hetzner_storage_available gauge"
|
|
||||||
|
|
||||||
echo "# HELP hetzner_storage_used Used storage"
|
|
||||||
echo "# TYPE hetzner_storage_used gauge"
|
|
||||||
|
|
||||||
echo "# HELP hetzner_storage_total Total storage"
|
|
||||||
echo "# TYPE hetzner_storage_total gauge"
|
|
||||||
|
|
||||||
ssh -p${PORT} ${USERNAME}@${HOST} df -k | tail -n +2 | while read FS TOTAL USED AVAIL PERCENT MOUNT; do
|
ssh -p${PORT} ${USERNAME}@${HOST} df -k | tail -n +2 | while read FS TOTAL USED AVAIL PERCENT MOUNT; do
|
||||||
|
echo "# HELP hetzner_storage_available Available storage in kilobytes"
|
||||||
|
echo "# TYPE hetzner_storage_available gauge"
|
||||||
echo "hetzner_storage_available{host=\"${HOST}\"} $AVAIL"
|
echo "hetzner_storage_available{host=\"${HOST}\"} $AVAIL"
|
||||||
|
|
||||||
|
echo "# HELP hetzner_storage_used Used storage in kilobytes"
|
||||||
|
echo "# TYPE hetzner_storage_used gauge"
|
||||||
echo "hetzner_storage_used{host=\"${HOST}\"} $USED"
|
echo "hetzner_storage_used{host=\"${HOST}\"} $USED"
|
||||||
|
|
||||||
|
echo "# HELP hetzner_storage_total Total storage in kilobytes"
|
||||||
|
echo "# TYPE hetzner_storage_total gauge"
|
||||||
echo "hetzner_storage_total{host=\"${HOST}\"} $TOTAL"
|
echo "hetzner_storage_total{host=\"${HOST}\"} $TOTAL"
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
version: "3.0"
|
|
||||||
|
|
||||||
services:
|
|
||||||
hetzner-storage-exporter:
|
|
||||||
build: .
|
|
||||||
image: registry.gmasil.de/docker/hetzner-storage-exporter:${TAG}
|
|
0
header.sh
Normal file → Executable file
0
header.sh
Normal file → Executable file
Loading…
Reference in a new issue