Created
January 7, 2013 22:40
-
-
Save kbkaran/4479195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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