Skip to content

checks for newest servers on Hetzner server auction (server-bidding) and pushes them viatelegram_send

License

Notifications You must be signed in to change notification settings

danielskowronski/hetzner-auction-hunter

Repository files navigation

hetzner-auction-hunter

unofficially checks for newest servers on Hetzner server auction (server-bidding) and pushes to one of dozen providers supported by Notifiers library, including Pushover, SimplePush, Slack, Gmail, Email (SMTP), Telegram, Gitter, Pushbullet, Join, Zulip, Twilio, Pagerduty, Mailgun, PopcornNotify, StatusPage.io, iCloud, VictorOps (Splunk)

Hetzner Auction website

Docker Pulls

The price displayed on hetzner.com by default includes monthly rate for IPv4 address, therefore it's slightly higher than one reported by this tool. You can disable it by toggling Enable IPv6 only switch available on top of the list (on hetzner.com).

requirements

  • python3
  • properly configured Notifiers provider
  • some writable file to store processed offers (defaults to /tmp/hah.txt)

usage

usage: hah.py [-h] [--data-url DATA_URL] [--provider PROVIDER] [--tax TAX] [--price PRICE] [--disk-count DISK_COUNT] [--disk-size DISK_SIZE] [--disk-min-size DISK_MIN_SIZE] [--disk-quick] [--hw-raid] [--red-psu] [--gpu] [--ipv4] [--inic]
              [--cpu-count CPU_COUNT] [--ram RAM] [--ecc] [--dc DC] [-f [F]] [--exclude-tax] [--test-mode] [--debug] [--send-payload]

hah.py -- checks for newest servers on Hetzner server auction (server-bidding) and pushes to one of dozen providers supported by Notifiers library

options:
  -h, --help            show this help message and exit
  --data-url DATA_URL   URL to live_data_sb.json
  --provider PROVIDER   Notifiers provider name - see https://notifiers.readthedocs.io/en/latest/providers/index.html
  --tax TAX             tax rate (VAT) in percents, defaults to 19 (Germany)
  --price PRICE         max price (€)
  --disk-count DISK_COUNT
                        min disk count
  --disk-size DISK_SIZE
                        min disk capacity (GB)
  --disk-min-size DISK_MIN_SIZE
                        min disk capacity per disk (GB)
  --disk-quick          require SSD/NVMe
  --hw-raid             require Hardware RAID
  --red-psu             require Redundant PSU
  --gpu                 require discrete GPU
  --ipv4                require IPv4
  --inic                require Intel NIC
  --cpu-count CPU_COUNT
                        min CPU count
  --ram RAM             min RAM (GB)
  --ecc                 require ECC memory
  --dc DC               datacenter (FSN1-DC15) or location (FSN)
  -f [F]                state file
  --exclude-tax         exclude tax from output price
  --test-mode           do not send actual messages and ignore state file
  --debug               debug mode
  --send-payload        send server data as JSON payload

Since there are way too many combinations of providers and their parameters to support as CLI args, you must pass --provider PROVIDER as defined on Notifiers providers list and export all relevant ENV variables as per Notifiers usage guide.

directly on machine

You'll probably want to put it in crontab and make sure that state file is on permanent storage (/tmp/ may or may not survive reboot).

prepare local env

pyenv activate
python3 -m pip install -r requirements.txt

export ENV variables

Those are just examples. Check out https://notifiers.readthedocs.io/en/latest/providers/index.html

For Pushover: register, get your User Key from main page and then register app for which you'll get app token. Then export as follows:

export NOTIFIERS_PUSHOVER_USER=...
export NOTIFIERS_PUSHOVER_TOKEN=...
export HAH_PROVIDER=pushover

For Gmail: register, enable 2FA (required bacuse Google enforces app passwords for non-OAuth clients and you can't have app password without 2FA), create app password selecting Mail as service. Then export as follows:

export NOTIFIERS_GMAIL_USERNAME="[email protected]" # username
export NOTIFIERS_GMAIL_PASSWORD="..." # app password
export NOTIFIERS_GMAIL_FROM="$NOTIFIERS_GMAIL_USERNAME <$NOTIFIERS_GMAIL_USERNAME>" # optional From field, recommended to use real account email
export NOTIFIERS_GMAIL_TO="..." # recipient
export HAH_PROVIDER=gmail

For Telegram (discouraged, but provided for legacy compatibility): talk to @BotFather to create new bot and obtain token, talk to @myidbot to get your personal chat ID. Then export as follows:

export NOTIFIERS_TELEGRAM_TOKEN="...:..."
export NOTIFIERS_TELEGRAM_CHAT_ID="..." 
export HAH_PROVIDER=telegram

run

To get servers cheaper than 38 EUR with more than 24GB of RAM, disks at least 3TB:

./hah.py --provider $HAH_PROVIDER --price 38 --disk-size 3000 --ram 24

docker

Example run for Pushover:

docker build . -t hetzner-auction-hunter:latest --no-cache=true

docker run --rm \
  -v /tmp/hah:/tmp/ \
  -e NOTIFIERS_PUSHOVER_USER=$NOTIFIERS_PUSHOVER_USER \
  -e NOTIFIERS_PUSHOVER_TOKEN=$NOTIFIERS_PUSHOVER_TOKEN \
  hetzner-auction-hunter:latest --provider $HAH_PROVIDER --price 40 --disk-size 3000 --ram 24

For more universal executions, you may consider using docker run --env-file.

debugging

curl https://www.hetzner.com/_resources/app/jsondata/live_data_sb.json | jq > live_data_sb.json
./hah.py --data-url "file:///${PWD}/live_data_sb.json" --debug ...

docker image for hub.docker.com

hadolint Dockerfile
export TAG=danielskowronski/hetzner-auction-hunter:v...
docker build . -t $TAG --no-cache=true
docker push $TAG

About

checks for newest servers on Hetzner server auction (server-bidding) and pushes them viatelegram_send

Resources

License

Stars

Watchers

Forks

Packages

No packages published