Skip to main content
srik123
Silver ⭐️
Oct 20, 2019 6:34 PM UTC
Solved

I would to write a script which will check the status of Hivserver2 is running or not.

I would to write a script which will check the status of Hivserver2 is running or not. I would like to connect beeline and show databases. if i get the output then Hiveserver 2 is running. Can any one help in writing the script for this ?

FrozenWave
Gold ⭐️⭐️
Oct 21, 2019 12:16 PM UTC

You can query the API exposed by Cloudera Manager and simplify your life. For example, you can run the following:

 

curl -u <CM_USER>:<CM_PASSWD> http://<CM_IP_ADDRESS>:7180/api/v19/clusters/<CLUSTER_NAME>/services/hive2

 

You'll get a Json answer in reply to your Query, with all the details related to the desired service's status. You can finally parse your Json answer (e.g. using "jq" or directly inside your bash script) and take the desired actions

 

HTH

1 reply

FrozenWave
Gold ⭐️⭐️
Oct 21, 2019 12:16 PM UTC

You can query the API exposed by Cloudera Manager and simplify your life. For example, you can run the following:

 

curl -u <CM_USER>:<CM_PASSWD> http://<CM_IP_ADDRESS>:7180/api/v19/clusters/<CLUSTER_NAME>/services/hive2

 

You'll get a Json answer in reply to your Query, with all the details related to the desired service's status. You can finally parse your Json answer (e.g. using "jq" or directly inside your bash script) and take the desired actions

 

HTH

Translate