Ejemplo n.º 1
0
def run_bolts(command, parser, cl_args, unknown_args):
  """ run bolts subcommand """
  cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ']
  topology = cl_args['topology-name']
  try:
    result = tracker_access.get_topology_info(cluster, env, topology, role)
    bolts = result['physical_plan']['bolts'].keys()
    bolt_name = cl_args['bolt']
    if bolt_name:
      if bolt_name in bolts:
        bolts = [bolt_name]
      else:
        Log.error('Unknown bolt: \'%s\'' % bolt_name)
        raise
  except Exception:
    Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
    return False
  bolts_result = []
  for bolt in bolts:
    try:
      metrics = tracker_access.get_component_metrics(bolt, cluster, env, topology, role)
      stat, header = to_table(metrics)
      bolts_result.append((bolt, stat, header))
    except Exception:
      Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
      return False
  for i, (bolt, stat, header) in enumerate(bolts_result):
    if i != 0:
      print ''
    print '\'%s\' metrics:' % bolt
    print tabulate(stat, headers=header)
  return True
Ejemplo n.º 2
0
def run_metrics(command, parser, cl_args, unknown_args):
  """ run metrics subcommand """
  cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ']
  topology = cl_args['topology-name']
  try:
    result = tracker_access.get_topology_info(cluster, env, topology, role)
    spouts = result['physical_plan']['spouts'].keys()
    bolts = result['physical_plan']['bolts'].keys()
    components = spouts + bolts
    cname = cl_args['component']
    if cname:
      if cname in components:
        components = [cname]
      else:
        Log.error('Unknown component: \'%s\'' % cname)
        raise
  except Exception:
    Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
    return False
  cresult = []
  for comp in components:
    try:
      metrics = tracker_access.get_component_metrics(comp, cluster, env, topology, role)
    except:
      Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
      return False
    stat, header = to_table(metrics)
    cresult.append((comp, stat, header))
  for i, (comp, stat, header) in enumerate(cresult):
    if i != 0:
      print ''
    print '\'%s\' metrics:' % comp
    print tabulate(stat, headers=header)
  return True
Ejemplo n.º 3
0
def run_metrics(command, parser, cl_args, unknown_args):
    """ run metrics subcommand """
    cluster, role, env = cl_args["cluster"], cl_args["role"], cl_args["environ"]
    topology = cl_args["topology-name"]
    try:
        result = tracker_access.get_topology_info(cluster, env, topology, role)
        spouts = result["physical_plan"]["spouts"].keys()
        bolts = result["physical_plan"]["bolts"].keys()
        components = spouts + bolts
        cname = cl_args["component"]
        if cname:
            if cname in components:
                components = [cname]
            else:
                Log.error("Unknown component: '%s'" % cname)
                raise
    except Exception:
        Log.error("Fail to connect to tracker: '%s'", cl_args["tracker_url"])
        return False
    cresult = []
    for comp in components:
        try:
            metrics = tracker_access.get_component_metrics(comp, cluster, env, topology, role)
        except:
            Log.error("Fail to connect to tracker: '%s'", cl_args["tracker_url"])
            return False
        stat, header = to_table(metrics)
        cresult.append((comp, stat, header))
    for i, (comp, stat, header) in enumerate(cresult):
        if i != 0:
            print ""
        print "'%s' metrics:" % comp
        print tabulate(stat, headers=header)
    return True
Ejemplo n.º 4
0
def run_bolts(command, parser, cl_args, unknown_args):
    """ run bolts subcommand """
    cluster, role, env = cl_args["cluster"], cl_args["role"], cl_args["environ"]
    topology = cl_args["topology-name"]
    try:
        result = tracker_access.get_topology_info(cluster, env, topology, role)
        bolts = result["physical_plan"]["bolts"].keys()
        bolt_name = cl_args["bolt"]
        if bolt_name:
            if bolt_name in bolts:
                bolts = [bolt_name]
            else:
                Log.error("Unknown bolt: '%s'" % bolt_name)
                raise
    except Exception:
        Log.error("Fail to connect to tracker: '%s'", cl_args["tracker_url"])
        return False
    bolts_result = []
    for bolt in bolts:
        try:
            metrics = tracker_access.get_component_metrics(bolt, cluster, env, topology, role)
            stat, header = to_table(metrics)
            bolts_result.append((bolt, stat, header))
        except Exception:
            Log.error("Fail to connect to tracker: '%s'", cl_args["tracker_url"])
            return False
    for i, (bolt, stat, header) in enumerate(bolts_result):
        if i != 0:
            print ""
        print "'%s' metrics:" % bolt
        print tabulate(stat, headers=header)
    return True
Ejemplo n.º 5
0
def run_metrics(command, parser, cl_args, unknown_args):
  """ run metrics subcommand """
  cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ']
  topology = cl_args['topology-name']
  try:
    result = tracker_access.get_topology_info(cluster, env, topology, role)
    spouts = result['physical_plan']['spouts'].keys()
    bolts = result['physical_plan']['bolts'].keys()
    components = spouts + bolts
    cname = cl_args['component']
    if cname:
      if cname in components:
        components = [cname]
      else:
        Log.error('Unknown component: \'%s\'' % cname)
        raise
  except Exception:
    Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
    return False
  cresult = []
  for comp in components:
    try:
      metrics = tracker_access.get_component_metrics(comp, cluster, env, topology, role)
    except:
      Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
      return False
    stat, header = to_table(metrics)
    cresult.append((comp, stat, header))
  for i, (comp, stat, header) in enumerate(cresult):
    if i != 0:
      print('')
    print('\'%s\' metrics:' % comp)
    print(tabulate(stat, headers=header))
  return True
Ejemplo n.º 6
0
def run_bolts(command, parser, cl_args, unknown_args):
  """ run bolts subcommand """
  cluster, role, env = cl_args['cluster'], cl_args['role'], cl_args['environ']
  topology = cl_args['topology-name']
  try:
    result = tracker_access.get_topology_info(cluster, env, topology, role)
    bolts = result['physical_plan']['bolts'].keys()
    bolt_name = cl_args['bolt']
    if bolt_name:
      if bolt_name in bolts:
        bolts = [bolt_name]
      else:
        Log.error('Unknown bolt: \'%s\'' % bolt_name)
        raise
  except Exception:
    Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
    return False
  bolts_result = []
  for bolt in bolts:
    try:
      metrics = tracker_access.get_component_metrics(bolt, cluster, env, topology, role)
      stat, header = to_table(metrics)
      bolts_result.append((bolt, stat, header))
    except Exception:
      Log.error("Fail to connect to tracker: \'%s\'", cl_args["tracker_url"])
      return False
  for i, (bolt, stat, header) in enumerate(bolts_result):
    if i != 0:
      print('')
    print('\'%s\' metrics:' % bolt)
    print(tabulate(stat, headers=header))
  return True
Ejemplo n.º 7
0
def run_metrics(
    cluster: str,
    role: str,
    environment: str,
    topology: str,
    component: str,
) -> None:
    """Render a table of metrics."""
    try:
        result = tracker_access.get_topology_info(cluster, environment,
                                                  topology, role)
    except Exception:
        Log.error("Fail to connect to tracker")
        sys.exit(1)
    spouts = list(result['physical_plan']['spouts'].keys())
    bolts = list(result['physical_plan']['bolts'].keys())
    components = spouts + bolts
    if component:
        if component in components:
            components = [component]
        else:
            Log.error(f"Unknown component: {component!r}")
            sys.exit(1)
    cresult = []
    for comp in components:
        try:
            metrics = tracker_access.get_component_metrics(
                comp, cluster, environment, topology, role)
        except:
            Log.error("Fail to connect to tracker")
            sys.exit(1)
        stat, header = to_table(metrics)
        cresult.append((comp, stat, header))
    for i, (c, stat, header) in enumerate(cresult):
        if i != 0:
            print('')
        print(f"{c!r} metrics:")
        print(tabulate(stat, headers=header))