feat: python script to get monthly cost
This commit is contained in:
parent
e8e899f4ff
commit
9e69924211
3 changed files with 24 additions and 2 deletions
22
tools/statistics/get-monthly-cost.py
Executable file
22
tools/statistics/get-monthly-cost.py
Executable 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")
|
Loading…
Add table
Add a link
Reference in a new issue