Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
vcenter_curl_rest_api.sh
#!/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 "administrator@vsphere.local:${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