Skip to content

Instantly share code, notes, and snippets.

@OneCricketeer
Created December 21, 2018 22:03
Show Gist options
  • Save OneCricketeer/a5a3da1fdd07954d0440934bb2a6aa81 to your computer and use it in GitHub Desktop.
Save OneCricketeer/a5a3da1fdd07954d0440934bb2a6aa81 to your computer and use it in GitHub Desktop.
Ambari API samples
#!/bin/bash
: ${AMBARI_API:=http://localhost:8080}
curl --silent --request GET \
--url "${AMBARI_API}/api/v1/clusters/little_data/hosts?fields=Hosts/rack_info' \
--header 'X-Requested-By: ambari' \
--header 'Accept: application/json, text/javascript, */*; q=0.01' \
--header 'cache-control: no-cache' | jq '.items[].Hosts.rack_info' | sort | uniq -c
### Sample output
# 7 "/rack1"
# 4 "/rack2"
# 5 "/rack3"
# 7 "/vmware"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment