Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

List Hardware and Enviroment Information with the Ambari-REST-API

Solved Go to solution

List Hardware and Enviroment Information with the Ambari-REST-API

New Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: List Hardware and Enviroment Information with the Ambari-REST-API

Super Mentor

@Dominik Ludwig

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.

2 REPLIES 2

Re: List Hardware and Enviroment Information with the Ambari-REST-API

Super Mentor

@Dominik Ludwig

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.

Re: List Hardware and Enviroment Information with the Ambari-REST-API

Super Mentor

@Dominik Ludwig

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)

Don't have an account?
Coming from Hortonworks? Activate your account here