Created
May 19, 2020 22:52
-
-
Save j6k4m8/d9b9ed32b8c4d2aec3528856edaae39d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EC2_NAME = "x1.32xlarge" | |
# https://stackoverflow.com/a/55109870/979255 | |
def get_uptime(): | |
with open('/proc/uptime', 'r') as f: | |
uptime_seconds = float(f.readline().split()[0]) | |
return uptime_seconds | |
def get_sec_cost(): | |
return ({ # hourly costs: | |
"?": 1.808, | |
"x1.32xlarge": 13.338, | |
}).get(EC2_NAME, 1.0) / (60*60) | |
if __name__ == "__main__": | |
print(round(get_uptime() * get_sec_cost(), 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment