def do_thread_info(self, args): try: parser = argparse.ArgumentParser(prog="thread_info") parser.add_argument("-f", nargs="+", help="fields to show", default=[]) parser.add_argument("--listfields", action="store_true", help="list available fields") pargs = parser.parse_args(esc_utils.arrayArgs(args)) except: return if pargs.listfields: esc_utils.NicePrint( self.es.cat.thread_pool(params={ "help": True, "v": True })) return if pargs.f: esc_utils.NicePrint( self.es.cat.thread_pool(params={ "v": True, "h": ",".join(pargs.f) })) return esc_utils.NicePrint(self.es.cat.thread_pool(params={"v": True}))
def do_nodes_allocation(self, args): try: parser = argparse.ArgumentParser(prog="nodes_allocation") parser.add_argument("-e", action="store_true", help="Exclude nodes from allocation") parser.add_argument("-d", action="store_true", help="Empty exclude list") parser.add_argument("--nodes", help="comma separated list of ips of nodes") pargs = parser.parse_args(esc_utils.arrayArgs(args)) except: return if pargs.e: esc_utils.NicePrint( self.es.cluster.put_settings( '{ "transient" :{"cluster.routing.allocation.exclude._ip" : "%s" }}' % (pargs.nodes))) return if pargs.d: esc_utils.NicePrint( self.es.cluster.put_settings( '{ "transient" :{"cluster.routing.allocation.exclude._ip" : "" }}' )) return
def do_cluster_set_disable_allocation(self, args): """ Set disable_allocation to true / false, feel the negative logic here ! """ if args.lower() in ["true", "false"]: esc_utils.NicePrint( self.es.cluster.put_settings( '{"transient":{"cluster.routing.allocation.disable_allocation": %s}}' % (args.lower()))) return print "Possible vaules: true / false"
def do_cluster_put_settings(self, args): """ Change cluster settings, default to transistent, use -p for persistent changes """ try: parser = argparse.ArgumentParser(prog="cluster_put_settings") parser.add_argument("-p", action="store_true", help="persistent") parser.add_argument("key", help="setting to change") parser.add_argument("value", help="value") pargs = parser.parse_args(esc_utils.arrayArgs(args)) except: return typ = "transient" if pargs.p: typ = "persistent" req = '{ "%s": { "%s" : %s }}' % (typ, pargs.key, pargs.value) esc_utils.NicePrint(self.es.cluster.put_settings(req))
def cluster_health(self): esc_utils.NicePrint(self.es.cluster.health())
def do_cluster_get_settings(self, args): """ Returns cluster settings. """ esc_utils.NicePrint(self.es.cluster.get_settings())
def do_info(self, args=""): """ Get basic cluster info """ esc_utils.NicePrint(self.es.info())
def shards_show_recovery(self, linelimit): esc_utils.NicePrint(self.es.cat.recovery(), linelimit=linelimit)
def do_index_get_settings(self, args="_all"): """ Get's settings of all or some indices """ esc_utils.NicePrint(self.es.indices.get_settings(args))
def do_nodes_info(self, args): esc_utils.NicePrint(self.es.nodes.info())
def cluster_pending_tasks(self, linelimit=-1): esc_utils.NicePrint(self.es.cluster.pending_tasks(), linelimit=linelimit)