Created 08-29-2017 02:14 PM
Hi,
I want to list relevant Hardware and environment Information of an Ambari-Server with usage of the Ambari-REST-API. Interesting may be the capacity of RAM, disk volume, remaining disk space, operation system, java version, ambari version, CPUs …
Can you help me to find this Information in the REST-API?
Best Regards
Dominik
Created 08-29-2017 03:58 PM
If you have the ambari-agent also running on the ambari-server host then you can extract the informations using the following kind of API call for any host present in the cluster (including ambari server host)
# curl -sH "X-Requested-By: ambari" -u admin:admin http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com?fields=Hosts/disk_info,Hosts/rack_info,Ho...
.
Example Output:
# curl -sH "X-Requested-By: ambari" -u admin:admin http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com?fields=Hosts/disk_info,Hosts/rack_info,Ho... { "href" : "http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com?fields=Hosts/disk_info,Hosts/rack_info,Hosts/host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/ip,Hosts/total_mem,Hosts/os_arch,Hosts/os_type", "Hosts" : { "cluster_name" : "Sandbox", "cpu_count" : 4, "disk_info" : [ { "available" : "12288100", "device" : "overlay", "used" : "30125548", "percent" : "72%", "size" : "44707764", "type" : "overlay", "mountpoint" : "/" }, { "available" : "12288100", "device" : "/dev/sda3", "used" : "30125548", "percent" : "72%", "size" : "44707764", "type" : "ext4", "mountpoint" : "/hadoop" } ], "host_name" : "sandbox.hortonworks.com", "ip" : "172.17.0.2", "os_arch" : "x86_64", "os_type" : "centos6", "ph_cpu_count" : 4, "rack_info" : "/default-rack", "total_mem" : 8174640 } }
.
Please replace the "http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com"
localhost with your ambari server hostname.
sandbox.hortonworks.com with any of your host of your ambari cluster which has the ambari agent is installed.
Created 08-29-2017 03:58 PM
If you have the ambari-agent also running on the ambari-server host then you can extract the informations using the following kind of API call for any host present in the cluster (including ambari server host)
# curl -sH "X-Requested-By: ambari" -u admin:admin http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com?fields=Hosts/disk_info,Hosts/rack_info,Ho...
.
Example Output:
# curl -sH "X-Requested-By: ambari" -u admin:admin http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com?fields=Hosts/disk_info,Hosts/rack_info,Ho... { "href" : "http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com?fields=Hosts/disk_info,Hosts/rack_info,Hosts/host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/ip,Hosts/total_mem,Hosts/os_arch,Hosts/os_type", "Hosts" : { "cluster_name" : "Sandbox", "cpu_count" : 4, "disk_info" : [ { "available" : "12288100", "device" : "overlay", "used" : "30125548", "percent" : "72%", "size" : "44707764", "type" : "overlay", "mountpoint" : "/" }, { "available" : "12288100", "device" : "/dev/sda3", "used" : "30125548", "percent" : "72%", "size" : "44707764", "type" : "ext4", "mountpoint" : "/hadoop" } ], "host_name" : "sandbox.hortonworks.com", "ip" : "172.17.0.2", "os_arch" : "x86_64", "os_type" : "centos6", "ph_cpu_count" : 4, "rack_info" : "/default-rack", "total_mem" : 8174640 } }
.
Please replace the "http://localhost:8080/api/v1/hosts/sandbox.hortonworks.com"
localhost with your ambari server hostname.
sandbox.hortonworks.com with any of your host of your ambari cluster which has the ambari agent is installed.
Created 08-29-2017 04:07 PM
You can extract more information's from the host if you do not apply the Fields filter:
# curl -sH "X-Requested-By: ambari" -u admin:admin http://$AMBARI_SERVER:8080/api/v1/hosts/$HOST_TO_MONITOR
.
Please replace the "$HOST_TO_MONITOR" and "$AMBARI_SERVER" with the appropriate FQDN (hostnames)