Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import sys
import json
import requests
import datetime
args = sys.argv
conf_file = args[1]
insecure_warn = requests.packages.urllib3.exceptions.InsecureRequestWarning
with open(conf_file, "r") as file:
conf =
conf = json.loads(conf)
prism_addr = conf["prism_address"]
prism_user = conf["user_name"]
prism_pass = conf["password"]
def main():
base_url = 'https://' + prism_addr + ':9440/PrismGateway/services/rest/v2.0/'
s = requests.Session()
s.auth = (prism_user, prism_pass)
s.headers.update({'Content-Type': 'application/json; charset=utf-8'})
ts =
ts_str = ts.isoformat()
data = s.get(base_url + 'hosts', verify=False).json()
for entity in data['entities']:
hv_name = entity['name']
stats = entity['stats']
#stats = entity['usage_stats']
for stat_key in stats:
stat_value = stats[stat_key]
to_csv_list = (ts_str, hv_name, stat_key, stat_value)
if __name__ == '__main__':

This comment has been minimized.

Copy link
Owner Author

@gowatana gowatana commented Oct 30, 2018


Nutanix API v2 で Host stats を取得してみる。(Python での別パターン)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment