示例#1
0
    def build(self, id='-1', state_interval=-1):
        global clusterId, clusterDefinitionRevision, firstContact
        timestamp = int(time.time() * 1000)
        queueResult = self.actionQueue.result()

        nodeStatus = {"status": "HEALTHY", "cause": "NONE"}

        heartbeat = {
            'responseId': int(id),
            'timestamp': timestamp,
            'hostname': hostname.hostname(),
            'nodeStatus': nodeStatus
        }

        if len(queueResult) != 0:
            heartbeat['reports'] = queueResult['reports']
            heartbeat['componentStatus'] = queueResult['componentStatus']
            pass
        logger.info("Sending heartbeat with response id: " + str(id) + " and "
                    "timestamp: " + str(timestamp))
        logger.debug("Heartbeat : " + pformat(heartbeat))

        if (int(id) >= 0) and state_interval > 0 and (int(id) %
                                                      state_interval) == 0:
            hostInfo = HostInfo()
            nodeInfo = {}
            # for now, just do the same work as registration
            hostInfo.register(nodeInfo)
            heartbeat['agentEnv'] = nodeInfo
            logger.debug("agentEnv : " + str(nodeInfo))

        return heartbeat
示例#2
0
    def build(self, id='-1', state_interval=-1, componentsMapped=False):
        global clusterId, clusterDefinitionRevision, firstContact
        timestamp = int(time.time() * 1000)
        queueResult = self.actionQueue.result()

        nodeStatus = {"status": "HEALTHY", "cause": "NONE"}
        nodeStatus["alerts"] = []

        heartbeat = {
            'responseId': int(id),
            'timestamp': timestamp,
            'hostname': hostname.hostname(self.config),
            'nodeStatus': nodeStatus
        }

        commandsInProgress = False
        if not self.actionQueue.commandQueue.empty():
            commandsInProgress = True

        if len(queueResult) != 0:
            heartbeat['reports'] = queueResult['reports']
            heartbeat['componentStatus'] = queueResult['componentStatus']
            if len(heartbeat['reports']) > 0:
                # There may be IN_PROGRESS tasks
                commandsInProgress = True
            pass

        # For first request/heartbeat assume no components are mapped
        if int(id) == 0:
            componentsMapped = False

        logger.info(
            "Building Heartbeat: {responseId = %s, timestamp = %s, commandsInProgress = %s, componentsMapped = %s}",
            str(id), str(timestamp), repr(commandsInProgress),
            repr(componentsMapped))

        if logger.isEnabledFor(logging.DEBUG):
            logger.debug("Heartbeat: %s", pformat(heartbeat))

        hostInfo = HostInfo(self.config)
        if (int(id) >= 0) and state_interval > 0 and (int(id) %
                                                      state_interval) == 0:
            nodeInfo = {}
            # for now, just do the same work as registration
            # this must be the last step before returning heartbeat
            hostInfo.register(nodeInfo, componentsMapped, commandsInProgress)
            heartbeat['agentEnv'] = nodeInfo
            mounts = Hardware.osdisks()
            heartbeat['mounts'] = mounts

            if logger.isEnabledFor(logging.DEBUG):
                logger.debug("agentEnv: %s", str(nodeInfo))
                logger.debug("mounts: %s", str(mounts))

        nodeStatus["alerts"] = hostInfo.createAlerts(nodeStatus["alerts"])

        if self.collector is not None:
            heartbeat['alerts'] = self.collector.alerts()

        return heartbeat
示例#3
0
文件: Heartbeat.py 项目: duxia/ambari
  def build(self, id='-1', state_interval=-1, componentsMapped=False):
    global clusterId, clusterDefinitionRevision, firstContact
    timestamp = int(time.time()*1000)
    queueResult = self.actionQueue.result()


    nodeStatus = { "status" : "HEALTHY",
                   "cause" : "NONE" }
    nodeStatus["alerts"] = []



    heartbeat = { 'responseId'        : int(id),
                  'timestamp'         : timestamp,
                  'hostname'          : hostname.hostname(self.config),
                  'nodeStatus'        : nodeStatus
                }

    commandsInProgress = False
    if not self.actionQueue.commandQueue.empty():
      commandsInProgress = True

    if len(queueResult) != 0:
      heartbeat['reports'] = queueResult['reports']
      heartbeat['componentStatus'] = queueResult['componentStatus']
      if len(heartbeat['reports']) > 0:
        # There may be IN_PROGRESS tasks
        commandsInProgress = True
      pass

    # For first request/heartbeat assume no components are mapped
    if int(id) == 0:
      componentsMapped = False

    logger.info("Building Heartbeat: {responseId = %s, timestamp = %s, commandsInProgress = %s, componentsMapped = %s}",
        str(id), str(timestamp), repr(commandsInProgress), repr(componentsMapped))

    if logger.isEnabledFor(logging.DEBUG):
      logger.debug("Heartbeat: %s", pformat(heartbeat))

    hostInfo = HostInfo(self.config)
    if (int(id) >= 0) and state_interval > 0 and (int(id) % state_interval) == 0:
      nodeInfo = { }
      # for now, just do the same work as registration
      # this must be the last step before returning heartbeat
      hostInfo.register(nodeInfo, componentsMapped, commandsInProgress)
      heartbeat['agentEnv'] = nodeInfo
      mounts = Hardware.osdisks()
      heartbeat['mounts'] = mounts

      if logger.isEnabledFor(logging.DEBUG):
        logger.debug("agentEnv: %s", str(nodeInfo))
        logger.debug("mounts: %s", str(mounts))

    nodeStatus["alerts"] = hostInfo.createAlerts(nodeStatus["alerts"])
    return heartbeat
示例#4
0
  def build(self, id='-1', state_interval=-1, componentsMapped=False):
    global clusterId, clusterDefinitionRevision, firstContact
    timestamp = int(time.time()*1000)
    queueResult = self.actionQueue.result()

    
    nodeStatus = { "status" : "HEALTHY",
                   "cause" : "NONE"}
    
    heartbeat = { 'responseId'        : int(id),
                  'timestamp'         : timestamp,
                  'hostname'          : hostname.hostname(),
                  'nodeStatus'        : nodeStatus
                }

    commandsInProgress = False
    if not self.actionQueue.commandQueue.empty():
      commandsInProgress = True
    if len(queueResult) != 0:
      heartbeat['reports'] = queueResult['reports']
      heartbeat['componentStatus'] = queueResult['componentStatus']
      if len(heartbeat['reports']) > 0:
        # There may be IN_PROGRESS tasks
        commandsInProgress = True
      pass

    # For first request/heartbeat assume no components are mapped
    if int(id) == 0:
      componentsMapped = False

    logger.info("Sending heartbeat with response id: " + str(id) + " and "
                "timestamp: " + str(timestamp) +
                ". Command(s) in progress: " + repr(commandsInProgress) +
                ". Components mapped: " + repr(componentsMapped))
    logger.debug("Heartbeat : " + pformat(heartbeat))

    if (int(id) >= 0) and state_interval > 0 and (int(id) % state_interval) == 0:
      hostInfo = HostInfo(self.config)
      nodeInfo = { }
      # for now, just do the same work as registration
      # this must be the last step before returning heartbeat
      hostInfo.register(nodeInfo, componentsMapped, commandsInProgress)
      heartbeat['agentEnv'] = nodeInfo
      logger.debug("agentEnv : " + str(nodeInfo))
      mounts = Hardware.osdisks()
      heartbeat['mounts'] = mounts
      logger.debug("mounts : " + str(mounts))

    return heartbeat
示例#5
0
  def build(self, id='-1'):
    global clusterId, clusterDefinitionRevision, firstContact
    timestamp = int(time.time()*1000)
   
    hostInfo = HostInfo() 
    agentEnv = { }
    hostInfo.register(agentEnv)

    version = self.read_agent_version()
    
    register = { 'responseId'        : int(id),
                  'timestamp'         : timestamp,
                  'hostname'          : hostname.hostname(),
                  'publicHostname'    : hostname.public_hostname(),
                  'hardwareProfile'   : self.hardware.get(),
                  'agentEnv'          : agentEnv,
                  'agentVersion'      : version
                }
    return register
  def build(self, id='-1'):
    global clusterId, clusterDefinitionRevision, firstContact
    timestamp = int(time.time()*1000)
   
    hostInfo = HostInfo(self.config)
    agentEnv = { }
    hostInfo.register(agentEnv, False, False)

    version = self.agentInfo.version()
    current_ping_port = self.config.get('agent','current_ping_port')
    
    register = { 'responseId'        : int(id),
                 'timestamp'         : timestamp,
                 'hostname'          : hostname.hostname(),
                 'currentPingPort'   : int(current_ping_port),
                 'publicHostname'    : hostname.public_hostname(),
                 'hardwareProfile'   : self.hardware.get(),
                 'agentEnv'          : agentEnv,
                 'agentVersion'      : version
               }
    return register
示例#7
0
  def build(self, version, id='-1'):
    global clusterId, clusterDefinitionRevision, firstContact
    timestamp = int(time.time()*1000)

    hostInfo = HostInfo(self.config)
    agentEnv = { }
    hostInfo.register(agentEnv, False, False)

    current_ping_port = self.config.get('agent','current_ping_port')

    register = { 'responseId'        : int(id),
                 'timestamp'         : timestamp,
                 'hostname'          : hostname.hostname(self.config),
                 'currentPingPort'   : int(current_ping_port),
                 'publicHostname'    : hostname.public_hostname(self.config),
                 'hardwareProfile'   : self.hardware.get(),
                 'agentEnv'          : agentEnv,
                 'agentVersion'      : version,
                 'prefix'            : self.config.get('agent', 'prefix')
               }
    return register