@raghu raghavendra
By making the following API call you will know how many HIVE_SERVER are running / not running in your Cluster.
# curl -k -H "X-Requested-By: ambari" -u admin:admin -X GET http://$AMBARI_SERVER_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/HIVE/components/HIVE_SERVER?fields=ServiceComponentInfo/started_count,ServiceComponentInfo/total_count
Please take a look at the "started_count" and "total_count" parameters in the output generated by the above API call.
.
If you already know the Hostnames where the HIVE_SERVER are configured then you can directly make the API call to get the status:
# curl -H "X-Requested-By: ambari" -u admin:admin -X GET http://$AMBARI_SERVER_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$HIVE_SERVER_HOSTNAME/host_components/HIVE_SERVER?fields=HostRoles/host_name,HostRoles/state
Please replace the $AMBARI_SERVER_HOST, $CLUSTER_NAME, $HIVE_SERVER_HOSTNAME variables with your own environment specific values.
.
Example Outputs:
# curl -s -H "X-Requested-By: ambari" -u admin:admin -X GET http://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/services/HIVE/components/HIVE_SERVER?fields=ServiceComponentInfo/started_count,ServiceComponentInfo/total_count | grep -e "started_count\|total_count" | grep -v 'href'
"started_count" : 2,
"total_count" : 2
For individual Hive Server status: (Suppose i want to check HiveServer2 status on host kerlatest3.example.com
# curl -s -H "X-Requested-By: ambari" -u admin:admin -X GET http://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/hosts/kerlatest3.example.com/host_coponents/HIVE_SERVER?fields=HostRoles/host_name,HostRoles/state | grep -e "host_name\|state" | grep -v 'href'
"host_name" : "kerlatest3.example.com",
"state" : "STARTED"
.