Last active
March 16, 2022 23:09
-
-
Save goneri/950f160abf9ee9ec2f94871d21ff7b9e to your computer and use it in GitHub Desktop.
vcenter_curl_rest_api.sh
This file contains hidden or 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
#!/bin/bash | |
set -x | |
server='https://vcenter.test' | |
password=$(crudini --get /tmp/inventory-vmware_rest 'vmware_rest:vars' 'vcenter_password') | |
session_id=$(curl -q --http1.1 -X POST -k -u "[email protected]:${password}" ${server}/rest/com/vmware/cis/session|jq -r .value) | |
function get() { | |
path=$1 | |
curl -ik -H vmware-api-session-id:${session_id} -X GET ${server}$path | |
echo "" | |
} | |
get /rest/appliance/monitoring | |
#get /rest/appliance/monitoring/dm-0 | |
#get '/rest/appliance/monitoring/queryitem.interval=MINUTES5&item.function=AVG&item.start_time=2021-03-01T12:00:00.000Z&item.end_time=2021-04-01T12:00:00.000Z&item.names.1=mem.usage' | |
get /api/vcenter/vm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment