Skip to content

Instantly share code, notes, and snippets.

@ekeih
Last active November 17, 2018 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekeih/ada50e524dbcfffcd31ea383164603cb to your computer and use it in GitHub Desktop.
Save ekeih/ada50e524dbcfffcd31ea383164603cb to your computer and use it in GitHub Desktop.
hetzner invoices
#!/usr/bin/env bash
# Put all your Hetzner invoices in a 'pdf' directory and keep the original name.
for filename in pdf/*.pdf; do
date="$(date -d "$(sed 's,.*_\(.*\)_.*,\1,' <<< "${filename})")" '+%s000000000')"
value="$(pdftotext "${filename}" - | grep -A 2 Brutto | tail -n 1 | sed "s;\([0-9]*\),\([0-9]*\).*€;\1.\2;")"
payload="invoice value=${value} ${date}"
curl -i -XPOST 'http://127.0.0.1:8086/write?db=hetzner' --data-binary "${payload}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment