Support Questions

Find answers, ask questions, and share your expertise

API + namenode status

avatar

hi all

we want to verify the name nodes status from ambari by API ( namenode adtive/stand by under hdfs )

capture.png

is it possible to create API for that?

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor
5 REPLIES 5

avatar
Master Mentor

avatar
Master Mentor

@Michael Bronson

Example: Please check the "HAState" field value.

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/host_components?HostRoles/component_name=NAMENODE&metrics/dfs/FSNamesystem/HAState=active"

.

Output:

{
  "href" : "http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/host_components?HostRoles/component_name=NAMENODE&metrics/dfs/FSNamesystem/HAState=active",
  "items" : [
    {
      "href" : "http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/hosts/hdfcluster1.example.com/host_components/NAMENODE",
      "HostRoles" : {
        "cluster_name" : "TestCluster",
        "component_name" : "NAMENODE",
        "host_name" : "hdfcluster1.example.com"
      },
      "host" : {
        "href" : "http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/hosts/hdfcluster1.example.com"
      },
      "metrics" : {
        "dfs" : {
          "FSNamesystem" : {
            "HAState" : "active"
          }
        }
      }
    }
  ]
}

.

avatar

@Jay what should be the HAState for the standby machine ?

Michael-Bronson

avatar
what we get is only that
 curl -u admin:admin -H "X-Requested-By: ambari" -X GET "http://name2:8080/api/v1/clusters/clu45/host_components?HostRoles/component_name=NAMENODE&metrics/dfs/FSNamesytem/HAState=standby"
{
  "href" : "http://name2:8080/api/v1/clusters/clu45/host_components?HostRoles/component_name=NAMENODE&metrics/dfs/FSNamesystem/HAState=standby",
  "items" : [ ]
Michael-Bronson

avatar
Master Mentor

@Michael Bronson

There is a Type in your URL. The spelling of "FSNamesytem" (should be "FSNamesystem") one character 's' is missing in the word.

So please try this:

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "http://name2:8080/api/v1/clusters/clu45/host_components?HostRoles/component_name=NAMENODE&metrics/dfs/FSNamesystem/HAState=standby

.