Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Getting impala daemon serves via cloudera rest API

avatar
Explorer

Hi Guys,

I have been struggling to get the a list of the host on which cloudera daemon is installed,

I tried using the rest API, but I did not found any path to getting the list of nodes with impala daemon on.

Does someone know how to get it ?

 

King Regards,

Rotem

1 ACCEPTED SOLUTION

avatar
Master Collaborator

Then you will need to parse the REST result of the /hosts?view=full [0] endpoint which gives you map of host-to-roleRef "The list of roles assigned to this host."


$ curl -u admin:admin -X GET "http://cm-server:7180/api/v12/hosts?view=full" 

 

 

[0] https://cloudera.github.io/cm_api/apidocs/v16/ns0_apiHost.html

View solution in original post

3 REPLIES 3

avatar
Master Collaborator

 

Since you did not specify which approach, I had a python console open and below seems to return what may be looking for.

 

 

from cm_api.api_client import ApiResource
api = ApiResource(server_host="cloudera-manager.host.com",version=12)

cluster = api.get_cluster("___REPLACE_ME_WITH_CLUSTER_NAME__")
for host in api.get_all_hosts(view='full'):
# List (rolename,servicename,hostname) from all host where service name = impala
print [(x.roleName,x.serviceName,host.hostname) for x in host.roleRefs if "impala" in str(x.serviceName).lower()]

 

 

avatar
Explorer

Thanks for your answer.

I am trying  to write a shell script using HTTP REST API.

something like "curl -u 'admin:admin' http://cm_host:7180/api/v1/clusters/dev01/services/hdfs2"

could you please assist with a command I need to run (Is there a way doing it without python just a shell script)

King Regards,

Rotem

avatar
Master Collaborator

Then you will need to parse the REST result of the /hosts?view=full [0] endpoint which gives you map of host-to-roleRef "The list of roles assigned to this host."


$ curl -u admin:admin -X GET "http://cm-server:7180/api/v12/hosts?view=full" 

 

 

[0] https://cloudera.github.io/cm_api/apidocs/v16/ns0_apiHost.html