THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
WARNING: The client library is still in the works and not production ready.
Ambari python client can be used make use of Ambari APIs.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
from ambari_client.ambari_api import AmbariClient headers_dict={'X-Requested-By':'mycompany'} #Ambari needs X-Requested-By header client = AmbariClient("localhost", 8080, "admin", "admin", version=1,http_header=headers_dict) print client.version print client.host_url print"\n" |
...
Code Block language python title Show all clusters in Ambari firstline 1 linenumbers true all_clusters = client.get_all_clusters() print all_clusters.to_json_dict() print all_clusters
Code Block language python title Show all hosts in Ambari firstline 1 linenumbers true all_hosts = client.get_all_hosts() print all_hosts print all_hosts.to_json_dict() print"\n"
Get metrics
Code Block language python title get cpu-metrics of service component TASKTRACKER firstline 1 linenumbers true mr = mycluster.get_service("MAPREDUCE") mr_comp1 = mr.get_service_component('TASKTRACKER') metric_json = mr_comp1.get_metrics() print metric_json["metrics"]["cpu"] print"\n"
Code Block language python title get cpu-metrics from a host which has component NAMENODE firstline 1 linenumbers true host1 = mycluster.get_host('host1') nn = host1.get_host_component("NAMENODE") metric_json = nn.get_metrics() print metric_json["metrics"]["cpu"] print"\n"
Create & configure cluster
...