Support Questions

Find answers, ask questions, and share your expertise

CLI to get expiration date of Cloudera license

avatar
New Contributor

Hello,

I would like to write Bash script to run across all of our Cloudera hosts and to monitor if some envs are going to be expired

 

via GUI, i'm able to see it on http://<cloudera host>:7180/cmf/license/settings page

 

does anyone know how can i get result of Cloudera license expiration date via command line?

 

Thanks,

Noam

1 ACCEPTED SOLUTION

avatar
Master Mentor
3 REPLIES 3

avatar
Master Mentor

@noamsh88 
check out these cloudera API's
http://cloudera.github.io/cm_api/apidocs/v18/path__cm_license.html

 

Hope that helps

avatar
New Contributor

Thanks Shelton for the advise

will write something to get the expiration date via API

will be sharing example for future reference for community 

 

avatar
New Contributor

sending basic examples of getting the expiration date via API

 

for single host:

import cm_client
from cm_client.rest import ApiException
from pprint import pprint

# Configure HTTP basic authorization: basic
cm_client.configuration.username = '<USERNAME>'
cm_client.configuration.password = '<PASSWORD>'

# Create an instance of the API class
api_host = 'http://<Cloudera host>'
port = '7180'
api_version = 'v41'
# Construct base URL for API
api_url = api_host + ':' + port + '/api/' + api_version
api_client = cm_client.ApiClient(api_url)
cluster_api_instance = cm_client.ClouderaManagerResourceApi(api_client)

try:
# Retrieve information about the Cloudera Manager license.
api_response = cluster_api_instance.read_license()
pprint(api_response.expiration)
except ApiException as e:
print("Exception when calling ClouderaManagerResourceApi->read_license: %s\n" % e)


for several hosts:


import cm_client
from cm_client.rest import ApiException
from pprint import pprint
import datetime

# Configure HTTP basic authorization: basic
cm_client.configuration.username = '<USERNAME>'
cm_client.configuration.password = '<PASSWORD>'

hosts_list= {"<host 1>" , "<host 2>" , "<host 3>", ....}
# Create an instance of the API class

for cdh_host in hosts_list:
api_host = 'http://' + cdh_host
port = '7180'
api_version = 'v41'
# Construct base URL for API
api_url = api_host + ':' + port + '/api/' + api_version
api_client = cm_client.ApiClient(api_url)
cluster_api_instance = cm_client.ClouderaManagerResourceApi(api_client)
print cdh_host + ":"
try:
# Retrieve information about the Cloudera Manager license.
api_response = cluster_api_instance.read_license()
expiration_date = api_response.expiration[0:10]
print(expiration_date)
print "##############"
except ApiException as e:
print("Exception when calling ClouderaManagerResourceApi->read_license: %s\n" % e)