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
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
for s in $(find tools/ -type f -iname "*.sh"); do
|
||||
for s in $(find tools/ -type f -regex ".*\.\(sh\|py\)"); do
|
||||
if ! [ -x $s ]; then
|
||||
echo "$s is not executable"
|
||||
exit 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
for s in $(find tools/ -type f -iname "*.sh"); do
|
||||
for s in $(find tools/ -type f -regex ".*\.\(sh\|py\)"); do
|
||||
[ -x $s ] && continue
|
||||
echo "fixing permissions for $s..."
|
||||
chmod +x $s
|
||||
|
|
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…
Reference in a new issue