feat: python script to get monthly cost

This commit is contained in:
Strix 2023-10-29 16:59:16 +01:00
parent e8e899f4ff
commit 9e69924211
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
3 changed files with 24 additions and 2 deletions

View file

@ -0,0 +1,22 @@
#!/bin/python3.11
try:
from hcloud import Client
except ModuleNotFoundError:
print("please install hcloud module")
exit(1)
import os
client = Client(token=os.environ.get("HCLOUD_TOKEN"))
price = 0
for server in client.servers.get_all():
for pricing in server.server_type.prices:
if pricing['location'] == server.datacenter.location.name:
price += float(pricing['price_monthly']['gross'])
if server.public_net.primary_ipv4 is not None:
price += .61 # this is the gross amount pulled from the console at Oct 29th 16:57.
print(f"~{price} EUR")