Skip to content

Instantly share code, notes, and snippets.

@goneri
Last active March 16, 2022 23:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goneri/950f160abf9ee9ec2f94871d21ff7b9e to your computer and use it in GitHub Desktop.
Save goneri/950f160abf9ee9ec2f94871d21ff7b9e to your computer and use it in GitHub Desktop.
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