Reply
Highlighted
New Contributor
Posts: 5
Registered: ‎01-11-2017
Accepted Solution

Getting impala daemon serves via cloudera rest API

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

Cloudera Employee
Posts: 196
Registered: ‎07-08-2013

Re: Getting impala daemon serves via cloudera rest API

[ Edited ]

 

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()]

 

 

New Contributor
Posts: 5
Registered: ‎01-11-2017

Re: Getting impala daemon serves via cloudera rest API

[ Edited ]

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

Cloudera Employee
Posts: 196
Registered: ‎07-08-2013

Re: Getting impala daemon serves via cloudera rest API

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

Announcements