def get_check_command(oozie_url, host_name, configurations):
  from resource_management.libraries.functions import reload_windows_env
  reload_windows_env()
  oozie_home = os.environ['OOZIE_HOME']
  oozie_cmd = os.path.join(oozie_home, 'bin', 'oozie.cmd')
  command = format("cmd /c {oozie_cmd} admin -oozie {oozie_url} -status")
  return (command, None, None)
def get_check_command(oozie_url, host_name, parameters):
    from resource_management.libraries.functions import reload_windows_env
    reload_windows_env()
    oozie_home = os.environ['OOZIE_HOME']
    command = format(
        "{oozie_home}\\bin\\oozie.cmd admin -oozie {oozie_url} -status")
    return (command, None)
예제 #3
0
def get_check_command(oozie_url, host_name, configurations):
    from resource_management.libraries.functions import reload_windows_env
    reload_windows_env()
    oozie_home = os.environ['OOZIE_HOME']
    oozie_cmd = os.path.join(oozie_home, 'bin', 'oozie.cmd')
    command = format("cmd /c {oozie_cmd} admin -oozie {oozie_url} -status")
    return (command, None, None)
예제 #4
0
def execute(configurations={}, parameters={}, host_name=None):
    """
  Returns a tuple containing the result code and a pre-formatted result label

  Keyword arguments:
  configurations (dictionary): a mapping of configuration key to value
  parameters (dictionary): a mapping of script parameter key to value
  host_name (string): the name of this host where the alert is running
  """

    from resource_management.libraries.functions import reload_windows_env
    reload_windows_env()
    hive_home = os.environ['HIVE_HOME']

    if configurations is None:
        return (('UNKNOWN',
                 ['There were no configurations supplied to the script.']))
    if not HIVE_METASTORE_URIS_KEY in configurations:
        return (('UNKNOWN',
                 ['Hive metastore uris were not supplied to the script.']))

    metastore_uris = configurations[HIVE_METASTORE_URIS_KEY].split(',')

    # defaults
    hiveuser = HADOOPUSER_DEFAULT

    if HADOOPUSER_KEY in configurations:
        hiveuser = configurations[HADOOPUSER_KEY]

    result_code = None
    try:
        if host_name is None:
            host_name = socket.getfqdn()
        for uri in metastore_uris:
            if host_name in uri:
                metastore_uri = uri

        hive_cmd = os.path.join(hive_home, "bin", "hive.cmd")
        cmd = format(
            "cmd /c {hive_cmd} --hiveconf hive.metastore.uris={metastore_uri}\
                 --hiveconf hive.metastore.client.connect.retry.delay=1\
                 --hiveconf hive.metastore.failure.retries=1\
                 --hiveconf hive.metastore.connect.retries=1\
                 --hiveconf hive.metastore.client.socket.timeout=14\
                 --hiveconf hive.execution.engine=mr -e 'show databases;'")
        start_time = time.time()
        try:
            Execute(cmd, user=hiveuser, timeout=30)
            total_time = time.time() - start_time
            result_code = 'OK'
            label = OK_MESSAGE.format(total_time)
        except:
            result_code = 'CRITICAL'
            label = CRITICAL_MESSAGE.format(host_name, traceback.format_exc())
    except:
        label = traceback.format_exc()
        result_code = 'UNKNOWN'

    return ((result_code, [label]))
def execute(configurations={}, parameters={}, host_name=None):
  """
  Returns a tuple containing the result code and a pre-formatted result label

  Keyword arguments:
  configurations (dictionary): a mapping of configuration key to value
  parameters (dictionary): a mapping of script parameter key to value
  host_name (string): the name of this host where the alert is running
  """

  from resource_management.libraries.functions import reload_windows_env
  from resource_management.core.resources import Execute
  reload_windows_env()
  hive_home = os.environ['HIVE_HOME']

  if configurations is None:
    return ('UNKNOWN', ['There were no configurations supplied to the script.'])

  transport_mode = HIVE_SERVER_TRANSPORT_MODE_DEFAULT
  if HIVE_SERVER_TRANSPORT_MODE_KEY in configurations:
    transport_mode = configurations[HIVE_SERVER_TRANSPORT_MODE_KEY]

  port = THRIFT_PORT_DEFAULT
  if transport_mode.lower() == 'binary' and HIVE_SERVER_THRIFT_PORT_KEY in configurations:
    port = int(configurations[HIVE_SERVER_THRIFT_PORT_KEY])
  elif transport_mode.lower() == 'http' and HIVE_SERVER_THRIFT_HTTP_PORT_KEY in configurations:
    port = int(configurations[HIVE_SERVER_THRIFT_HTTP_PORT_KEY])

  hiveuser = HADOOPUSER_DEFAULT
  if HADOOPUSER_KEY in configurations:
    hiveuser = configurations[HADOOPUSER_KEY]

  result_code = None
  try:
    if host_name is None:
      host_name = socket.getfqdn()

    beeline_url = ['jdbc:hive2://{host_name}:{port}/', "transportMode={transport_mode}"]
    # append url according to used transport
    if transport_mode == "http":
      beeline_url.append('httpPath=cliservice')
    beeline_url_string = format(";".join(beeline_url))
    beeline_cmd = os.path.join(hive_home, "bin", "beeline.cmd")
    cmd = format("cmd /c {beeline_cmd} -u {beeline_url_string} -e '' 2>&1 | findstr Connected")

    start_time = time.time()
    try:
      Execute(cmd, user=hiveuser, timeout=30)
      total_time = time.time() - start_time
      result_code = 'OK'
      label = OK_MESSAGE.format(total_time, port)
    except:
      result_code = 'CRITICAL'
      label = CRITICAL_MESSAGE.format(host_name, port, traceback.format_exc())
  except:
    label = traceback.format_exc()
    result_code = 'UNKNOWN'

  return (result_code, [label])
예제 #6
0
def execute(configurations={}, parameters={}, host_name=None):
  """
  Returns a tuple containing the result code and a pre-formatted result label

  Keyword arguments:
  configurations (dictionary): a mapping of configuration key to value
  parameters (dictionary): a mapping of script parameter key to value
  host_name (string): the name of this host where the alert is running
  """

  from resource_management.libraries.functions import reload_windows_env
  from resource_management.core.resources import Execute
  reload_windows_env()
  hive_home = os.environ['HIVE_HOME']

  if configurations is None:
    return ('UNKNOWN', ['There were no configurations supplied to the script.'])

  transport_mode = HIVE_SERVER_TRANSPORT_MODE_DEFAULT
  if HIVE_SERVER_TRANSPORT_MODE_KEY in configurations:
    transport_mode = configurations[HIVE_SERVER_TRANSPORT_MODE_KEY]

  port = THRIFT_PORT_DEFAULT
  if transport_mode.lower() == 'binary' and HIVE_SERVER_THRIFT_PORT_KEY in configurations:
    port = int(configurations[HIVE_SERVER_THRIFT_PORT_KEY])
  elif transport_mode.lower() == 'http' and HIVE_SERVER_THRIFT_HTTP_PORT_KEY in configurations:
    port = int(configurations[HIVE_SERVER_THRIFT_HTTP_PORT_KEY])

  hiveuser = HADOOPUSER_DEFAULT
  if HADOOPUSER_KEY in configurations:
    hiveuser = configurations[HADOOPUSER_KEY]

  result_code = None
  try:
    if host_name is None:
      host_name = socket.getfqdn()

    beeline_url = ['jdbc:hive2://{host_name}:{port}/', "transportMode={transport_mode}"]
    # append url according to used transport
    if transport_mode == "http":
      beeline_url.append('httpPath=cliservice')
    beeline_url_string = format(";".join(beeline_url))
    beeline_cmd = os.path.join(hive_home, "bin", "beeline.cmd")
    cmd = format("cmd /c {beeline_cmd} -u {beeline_url_string} -e '' 2>&1 | findstr Connected")

    start_time = time.time()
    try:
      Execute(cmd, user=hiveuser, timeout=30)
      total_time = time.time() - start_time
      result_code = 'OK'
      label = OK_MESSAGE.format(total_time, port)
    except:
      result_code = 'CRITICAL'
      label = CRITICAL_MESSAGE.format(host_name, port, traceback.format_exc())
  except:
    label = traceback.format_exc()
    result_code = 'UNKNOWN'

  return (result_code, [label])
def execute(configurations={}, parameters={}, host_name=None):
  """
  Returns a tuple containing the result code and a pre-formatted result label

  Keyword arguments:
  configurations (dictionary): a mapping of configuration key to value
  parameters (dictionary): a mapping of script parameter key to value
  host_name (string): the name of this host where the alert is running
  """

  from resource_management.libraries.functions import reload_windows_env
  reload_windows_env()
  hive_home = os.environ['HIVE_HOME']

  if configurations is None:
    return (('UNKNOWN', ['There were no configurations supplied to the script.']))
  if not HIVE_METASTORE_URIS_KEY in configurations:
    return (('UNKNOWN', ['Hive metastore uris were not supplied to the script.']))

  metastore_uris = configurations[HIVE_METASTORE_URIS_KEY].split(',')

  # defaults
  hiveuser = HADOOPUSER_DEFAULT

  if HADOOPUSER_KEY in configurations:
    hiveuser = configurations[HADOOPUSER_KEY]

  result_code = None
  try:
    if host_name is None:
      host_name = socket.getfqdn()
    for uri in metastore_uris:
      if host_name in uri:
        metastore_uri = uri

    hive_cmd = os.path.join(hive_home, "bin", "hive.cmd")
    cmd = format("cmd /c {hive_cmd} --hiveconf hive.metastore.uris={metastore_uri}\
                 --hiveconf hive.metastore.client.connect.retry.delay=1\
                 --hiveconf hive.metastore.failure.retries=1\
                 --hiveconf hive.metastore.connect.retries=1\
                 --hiveconf hive.metastore.client.socket.timeout=14\
                 --hiveconf hive.execution.engine=mr -e 'show databases;'")
    start_time = time.time()
    try:
      Execute(cmd, user=hiveuser, timeout=30)
      total_time = time.time() - start_time
      result_code = 'OK'
      label = OK_MESSAGE.format(total_time)
    except:
      result_code = 'CRITICAL'
      label = CRITICAL_MESSAGE.format(host_name, traceback.format_exc())
  except:
    label = traceback.format_exc()
    result_code = 'UNKNOWN'

  return ((result_code, [label]))
def get_check_command(oozie_url, host_name, configurations):
  from resource_management.libraries.functions import reload_windows_env
  reload_windows_env()
  oozie_home = os.environ['OOZIE_HOME']
  command = format("{oozie_home}\\bin\\oozie.cmd admin -oozie {oozie_url} -status")
  return (command, None)