Skip to content

Instantly share code, notes, and snippets.

@kbkaran
Created January 7, 2013 22:40
Show Gist options
  • Save kbkaran/4479195 to your computer and use it in GitHub Desktop.
Save kbkaran/4479195 to your computer and use it in GitHub Desktop.
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