From 6ac1cc485043765cf110f4e3b4aaa1769459afd4 Mon Sep 17 00:00:00 2001 From: Shivaram Venkataraman Date: Fri, 16 Aug 2013 11:28:07 -0700 Subject: [PATCH] Add scripts to print master hostnames and copy progress --- check-copy-progess.sh | 5 +++++ get-masters | 2 ++ get_masters.py | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 check-copy-progess.sh create mode 100755 get-masters create mode 100644 get_masters.py diff --git a/check-copy-progess.sh b/check-copy-progess.sh new file mode 100644 index 0000000..16d23bc --- /dev/null +++ b/check-copy-progess.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Usage +# check-copy-progress + +pssh -i -x "-i $1" -l root -h $2 '~/ephemeral-hdfs/bin/hadoop fs -dus /' diff --git a/get-masters b/get-masters new file mode 100755 index 0000000..97460bd --- /dev/null +++ b/get-masters @@ -0,0 +1,2 @@ +#!/bin/bash +PYTHONPATH="./third_party/boto-2.4.1.zip/boto-2.4.1:$PYTHONPATH" python get_masters.py $@ diff --git a/get_masters.py b/get_masters.py new file mode 100644 index 0000000..9e810aa --- /dev/null +++ b/get_masters.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import print_function +import json +import urllib2 +import boto +from optparse import OptionParser +from boto import * + +def is_active(instance): + return (instance.state in ['pending', 'running', 'stopping', 'stopped']) + +def main(): + parser = OptionParser(usage="get_masters [cluster_prefix]", + add_help_option=True) + (opts, args) = parser.parse_args() + if len(args) != 1: + get_cluster_masters() + else: + get_cluster_masters(args[0]) + +def get_cluster_masters(prefix=""): + conn = connect_ec2() + res = conn.get_all_instances() + # master reservations have only one node + masters = [i for i in res if len(i.instances) == 1] + master_instances = [m.instances[0] for m in masters if is_active(m.instances[0])] + + name_host = [(m.tags['cluster'], m.public_dns_name) for m in master_instances] + + for (name, host) in name_host: + if prefix in name: + print(name + " " + host) + +if __name__ == "__main__": + main()