Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import requests
- username = 'STORM-UI-USERNAME'
- password = 'STORM-UI-PASSWORD'
- base_url = 'STORM-UI-URL'
- cluster_summary = '/api/v1/cluster/summary'
- topology_summary = '/api/v1/topology/summary'
- topology_detail = '/api/v1/topology/{topology}'
- component = '/api/v1/topology/{topology}/component/{component}'
- def get_data(base, endpoint, username, password):
- return requests.request("GET", base + endpoint, auth=(username, password)).json()
- if __name__ == '__main__':
- topology_ids = map(lambda x: x['id'], get_data(base_url, topology_summary, username, password)['topologies'])
- worker_stats = []
- for topology in topology_ids:
- topology_detail_json = get_data(base_url, topology_detail.format(topology=topology), username, password)
- spouts = map(lambda x: x['spoutId'], topology_detail_json['spouts'])
- bolts = map(lambda x: x['boltId'], topology_detail_json['bolts'])
- for comp in spouts + bolts:
- comp_detail = get_data(base_url, component.format(topology=topology, component = comp), username, password)
- worker_stats += [(worker['host'], worker['id'], worker['uptime']) for worker in comp_detail['executorStats']]
- print pd.DataFrame(sorted(list(set(worker_stats)))).to_string(header=False, index=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement