Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 08-28-2017 05:09 AM
the following API give only the hosts from the amabri server
curl -sH "X-Requested-By: ambari" -u admin:admin -i http://localhost:8080/api/v1/hosts
is it possible to change the API in way that we can get also the IP address for each host?
the following example print only the hosts :
curl -sH "X-Requested-By: ambari" -u admin:admin -i http://localhost:8080/api/v1/hosts | grep host_name | sed s'/"//g' | awk '{print $NF}'
master01
master02
master03
worker01
worker02
expected results
master01 192.9.200.12
master02 192.9.200.13
master03 192.9.200.14
worker01 192.9.200.15
worker02 192.9.200.16
Created 08-28-2017 05:31 AM
You can try something like following:
# curl -sH "X-Requested-By: ambari" -u admin:admin -i http://localhost:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip | grep -A 1 host_name | sed s'/"//g' | awk '{print $NF}'
.
Example Output:
# curl -sH "X-Requested-By: ambari" -u admin:admin -i http://amb25101.example.com:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip | grep -A 1 host_name | sed s'/"//g' | awk '{print $NF}' http://amb25101.example.com:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip, [ -- amb25101.example.com, 172.10.116.149 -- amb25102.example.com, 172.10.116.148 -- amb25103.example.com, 172.10.116.151 -- amb25104.example.com, 172.10.116.150
.
Created 08-28-2017 05:31 AM
You can try something like following:
# curl -sH "X-Requested-By: ambari" -u admin:admin -i http://localhost:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip | grep -A 1 host_name | sed s'/"//g' | awk '{print $NF}'
.
Example Output:
# curl -sH "X-Requested-By: ambari" -u admin:admin -i http://amb25101.example.com:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip | grep -A 1 host_name | sed s'/"//g' | awk '{print $NF}' http://amb25101.example.com:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip, [ -- amb25101.example.com, 172.10.116.149 -- amb25102.example.com, 172.10.116.148 -- amb25103.example.com, 172.10.116.151 -- amb25104.example.com, 172.10.116.150
.
Created 08-28-2017 05:41 AM
is it possible to print as the following order
amb25101.example.com 172.10.116.149
amb25102.example.com 172.10.116.15
Created 08-28-2017 06:08 AM
Please try something like following:
# curl -sH "X-Requested-By: ambari" -u admin:admin -i http://localhost:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip | grep -A 1 host_name | awk '{print $NF}' > /tmp/hosts_details.txt; sed -e '1,2d' -e s'/--//g' -e 's/\n//g' -e 's/"//g' -e '/^$/d' /tmp/hosts_details.txt | awk 'NR%2{printf "%s ",$0;next;}1
.
Example Output:
# curl -sH "X-Requested-By: ambari" -u admin:admin -i http://amb25101.example.com:8080/api/v1/hosts?fields=Hosts/host_name,Hosts/ip | grep -A 1 host_name | awk '{print $NF}' > /tmp/hosts_details.txt; sed -e '1,2d' -e s'/--//g' -e 's/\n//g' -e 's/"//g' -e '/^$/d' /tmp/hosts_details.txt | awk 'NR%2{printf "%s ",$0;next;}1' amb25101.example.com 172.10.116.149 amb25102.example.com 172.10.116.148 amb25103.example.com 172.10.116.151 amb25104.example.com 172.10.116.150