Support Questions

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

How to track "HDP installation status using Ambari Blueprints"

avatar
Master Guru

I know we can track installation status using below API call or from directly using Ambari UI.

curl -H "X-Requested-By: ambari" -X GET -u admin:admin http://<ambari-hostname>:8080/api/v1/clusters/<cluster-name>/requests/

Is there any other efficient way to track the status of installation in an automated way ?

1 ACCEPTED SOLUTION

avatar

When I forked structor to add Blueprints support, I just used the API call in a while loop:

ProgressPercent=`curl -s --user admin:admin -H 'X-Requested-By:mycompany' -X GET http://<ambari-hostname>:8080/api/v1/clusters/<cluster-name>/requests/1 | grep progress_percent | awk '{print $3}' | cut -d . -f 1`
echo " Progress: $ProgressPercent"

while [[ `echo $ProgressPercent | grep -v 100` ]]; do
  ProgressPercent=`curl -s --user admin:admin -H 'X-Requested-By:mycompany' -X GET http://<ambari-hostname>:8080/api/v1/clusters/<cluster-name>/requests/1 | grep progress_percent | awk '{print $3}' | cut -d . -f 1`
  tput cuu1
  echo " Progress: $ProgressPercent %"
  sleep 2
done
echo "Cluster build is complete."

View solution in original post

7 REPLIES 7

avatar
Master Mentor
@Kuldeep Kulkarni

you can use command line tools like pdsh or some configuration management tool like ansible and tail /var/log/messages for installed RPMs, alternatively, you can run command ps aux | grep yum and see what's being installed as well.

avatar
Master Mentor

@Kuldeep Kulkarni you can also poke around in the ambari database for status installed but that's essentially the same as using API only much more intrusive.

avatar

When I forked structor to add Blueprints support, I just used the API call in a while loop:

ProgressPercent=`curl -s --user admin:admin -H 'X-Requested-By:mycompany' -X GET http://<ambari-hostname>:8080/api/v1/clusters/<cluster-name>/requests/1 | grep progress_percent | awk '{print $3}' | cut -d . -f 1`
echo " Progress: $ProgressPercent"

while [[ `echo $ProgressPercent | grep -v 100` ]]; do
  ProgressPercent=`curl -s --user admin:admin -H 'X-Requested-By:mycompany' -X GET http://<ambari-hostname>:8080/api/v1/clusters/<cluster-name>/requests/1 | grep progress_percent | awk '{print $3}' | cut -d . -f 1`
  tput cuu1
  echo " Progress: $ProgressPercent %"
  sleep 2
done
echo "Cluster build is complete."

avatar
Expert Contributor

This approach should work fine, but I would suggest a refinement that may improve performance somewhat, and will also make the returned status play load quite a bit smaller in size:

If you use the partial response syntax provided in the Ambari REST API, you can filter out much of the data returned in the request resource returned by the call listed above.

An example of using the partial response syntax is below:

http://ambari-hostname:ambari-port-number/api/v1/clusters/clusterone/requests/1?fields=Requests/comp...

The "fields" query parameter is used to limit the fields returned from the request resource. The fields I've mentioned here are the set I use, but you can also check the other properties returned by the resource, if a particular property is more straightforward to use for this type of monitoring.

I use this syntax quite a bit when I want to monitor the status of a Blueprint deployment.

avatar
Explorer

I wrote a python script that does the same thing. I noticed that immediately after I install the cluster hostmap to kickstart the install, and then check the request it returns, I get a 100% `progress_percent`. I had to introduce a delay (I set it to 5 seconds) before I start polling the request API.

avatar

This recently started happening in my scripts too and I hadn't figured out why. Thanks for the tip!

avatar
Super Collaborator

If you want to use a standard tool rather than managing the API/HTTP calls via scripts, you can use Ansible.

We've enabled such a feature on the Rackspace deployment playbooks: https://github.com/rackerlabs/ansible-hadoop/blob/master/playbooks/roles/ambari-server/tasks/main.ym...

I've create a gist only for that function: https://gist.github.com/alexandruanghel/68a16994028563be12cee4e3b93f7e89 if you want to use it straight away.

So once you download the statuscheck.yml just set the variables and run it:

AMBARI_HOST=127.0.0.1
AMBARI_PASSWORD=admin
CLUSTER_NAME=hadoop-poc
ansible-playbook -e "ansible_nodename=$AMBARI_HOST cluster_name=$CLUSTER_NAME ambari_password=$AMBARI_PASSWORD wait_timeout=1800" statuscheck.yml