Philipp
0010b6c1fc
panic: runtime error: index out of range [0] with length 0 goroutine 1 [running]: github.com/mrahbar/my-bloody-hetzner-sb-notifier/writer.(*TableWriter).Print(0xc00011be20, {{0x31e, 0x0}, {0x0, 0x0, 0x0}}) /home/philipp/git/my-bloody-hetzner-sb-notifier/writer/table.go:25 +0x27a main.run({0x731f00, 0xc0000ae008}, {0x0, 0x4041800000000000, 0x40, 0x100, 0x1800, 0x1800, 0x2, 0xf, ...}, ...) /home/philipp/git/my-bloody-hetzner-sb-notifier/main.go:251 +0x335 main.main() /home/philipp/git/my-bloody-hetzner-sb-notifier/main.go:138 +0x1a5 If no server was found we crashed, because we tried to print out the 0 element of an array. |
||
---|---|---|
client | ||
crawler | ||
hetzner | ||
strcase | ||
writer | ||
.gitignore | ||
build.sh | ||
build_gox.sh | ||
Dockerfile | ||
Dockerfile_only_build | ||
Dockerfile_with_build | ||
go.mod | ||
LICENSE | ||
main.go | ||
Readme.md |
The aim of my-bloody-hetzner-sb-notifier is a simple CLI to fetch the current Hetzner Serverbörse deals and filter them according to CLI parameters sorted by score.
For each offer a score is calculated from the amount of HDD space as well as RAM and CPU-Benchnmark for better comparability.
The CLI interface looks like this:
Usage of hetzner-sb-notifier:
-min-cpu-benchmark int
set min benchmark
-max-cpu-benchmark int
set max benchmark (default 20000)
-max-hdd-count int
set max hdd count (default 15)
-max-hdd-size int
set max hdd size (default 6144)
-max-price float
set max price (default 297)
-max-ram int
set max ram (default 256)
-min-hdd-count int
set min hdd count
-min-hdd-size int
set min hdd size
-min-price float
set min price
-min-ram int
set min ram
-serve-http
set serve http
-serve-http-port int
set serve http port (default 8080)
-output
set output: one of table, json (default table)
Http mode
In HTTP mode (app started with flag -serve-http) hetzner-sb-notifier runs continuously and can be queried via simple HTTP GET request. CLI parameters are translated to camel case. For example min-hdd-count becomes minHddCount
CLI-Example
./hetzner-sb-notifier --max-price 77 --min-ram 128 --min-hdd-count 2 --min-hdd-size 4096
Got 545 offers. Filtered offers: 3
ID| Ram| HDD| CPU| Price| Score| Reduce time|Specials
SB64-935022| 128 GB| 2x 2 TB (4096)| Intel Xeon E5-1650V2 (12518)| 64.00 €| 91.84| 47h 48m|ECC, Ent. HDD, iNIC
SB72-927788| 128 GB| 2x 2 TB (4096)| Intel Xeon E5-1650V3 (13335)| 72.00 €| 86.17| 21h 08m|ECC, Ent. HDD, iNIC
SB73-910394| 128 GB| 3x 2 TB (6144)| Intel Xeon E5-1650V2 (12518)| 73.00 €| 86.13| 03h 04m|ECC, Ent. HDD, iNIC
HTTP-Example
./hetzner-sb-notifier -serve-http
Running http server on address :8080
Got request: GET /?minRam=256&output=table HTTP/1.1
Host: localhost:8080
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Build
The Go project uses Go Modules and can be easily build with the wrapper script build.sh:
chmod +x build.sh
./build.sh