Giter Club home page Giter Club logo

hetzner-auction-hunter's Introduction

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

hetzner-auction-hunter's People

Contributors

danielskowronski avatar esurdam avatar janirad avatar pr0mises avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hetzner-auction-hunter's Issues

Script breaks if file contains any data

Hi, there one problem that must be fixed.
Sometimes script breaks if file already exists and contain any data.
It's can be fixed in both ways:

  1. importing os lib and adding after line 26 in if not args.test_mode:
    Something like this:
    if os.path.exists(file)
    os.remove(file)
  2. On line 28 f = open(file,'a+') 'a+' must be replaced with 'w+'

Both tested and working fine.

Inaccurate information, does not work

I am running the following command: ./hah.py --price 49 --disk-quick --ram 64 --exclude-tax --disk-size 500 --cpu-score 8000

It is sending notifications to Telegram which is great, but the information is inaccurate. It is sending me a bunch of notifications for servers that do not have SSD or NVMe when it should be doing the opposite.

Also, none of the IDs that it sends in the notifications are valid. For example, when I try searching for any of the IDs from the notifications there are no results on the Hetzner website.

Finally, there are a bunch of notifications for servers that are 27 euros but on the Hetzner website the cheapest server costs way more than that even without using any filters.

Are you able to fix this please? I think this tool is really cool and has major potential.

support price changes and replace data store

Tool for checking if there's some server cheaper than threshold monitoring service which whole point is to reduce prices, failed to support price reductions...

As noted in #15 this requires storing prices in a data store and the current format of text file is not suitable for that. Something like SQLite is needed.

Hetzner HTTP2 changes and enhancements

Hetzner has moved to HTTP/2 endpoint and deprecated HTTP/1.1. Python's requests module has yet to add HTTP/2 support leaving this script broken.

Feature requests:

  • Minimum HDD count
  • Minimum CPU count

mysterious difference

Hi

sorry for creating an "issue", you don't have "discussion" enabled.

The 1.7 v4 fee is known. But there is an additional difference of 1 compared to the "price" field in the json. Do you have any clue what that is? Just curious for accurate expectations and tracking.

Tried to upgrade to the newest version, can't get telegram notifications to work

trying:

docker run --rm -v /tmp/hah:/tmp/ -e NOTIFIERS_TELEGRAM_CHAT_ID="" -e NOTIFIERS_TELEGRAM_TOKEN=":*******************************" auctionhunter:latest --provider telegram --price 50 --disk-min-size 6000 --disk-count 4 --ram 16 -f /tmp/state

no error is thrown, but no messages are received. Is does work with the previous version with the /etc/telegram-send.conf file

any idea ?

script doesn't find anything under 30€

hi,

the script doesn't find anything under 30€
im looking for something cheap.

my command is:
hah.py --price 30 --disk-size 2000 --ram 16 --cpu-score 2000

i get results but only up from 30€, but on the site are a few listed for 24/25 €

Telegram config container secret support

Currently telegram-send will only use the default configuration paths when executing via Python. When leveraging containers with secrets for the Telegram bot API keys this causes issues with remapping the secret to a configuration file inside of telegran-send's path.

Please add support for providing different configuration files outside of the default paths.

error with telegram

seems there is an issue with the telegram class ...

Traceback (most recent call last):
File "./hah.py", line 4, in
import httpx, json, telegram_send, argparse
File "/usr/local/lib/python3.8/site-packages/telegram_send/init.py", line 2, in
from .telegram_send import configure, send
File "/usr/local/lib/python3.8/site-packages/telegram_send/telegram_send.py", line 33, in
from telegram.constants import MAX_MESSAGE_LENGTH
ImportError: cannot import name 'MAX_MESSAGE_LENGTH' from 'telegram.constants' (/usr/local/lib/python3.8/site-packages/telegram/constants.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.