Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os
import sys
sys.path.append('/home/kiru/cloudera-cm_api-cc9eac0/python/dist/cm_api-2.0.0-py2.7.egg')
from cm_api.api_client import ApiResource
api = ApiResource('localhost', username='admin', password='admin')
myclusters = api.get_all_clusters()
for cluster in myclusters:
thiscluster = api.get_cluster(cluster.name)
hosts = api.get_all_hosts()
services = thiscluster.get_all_services()
print 'CLUSTER SERVICE TYPE HOST STATUS'
for s in services:
roles = s.get_all_roles()
for r in roles:
print thiscluster.name, s.name, r.type, r.hostRef.hostId, r.healthSummary
# simulation code - adding fake datanodes/tasttrackers
if (r.type == 'DATANODE' or r.type == 'TASKTRACKER') :
for i in 1,2,3,4:
print thiscluster.name, s.name, r.type, r.hostRef.hostId+str(i), r.healthSummary
for i in 5,6:
print thiscluster.name, s.name, r.type, r.hostRef.hostId+str(i), 'BAD'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment