예제 #1
0
파일: agent.cpp 프로젝트: Tushar-Naik/hpcl
 void
 handle_server_request( const MemInfo &in_msg ) {
    const MessageHeader *header
                         = reinterpret_cast<const MessageHeader *>(
                                         in_msg.get_data() );
     switch( header->m_type ) {
         case MessageType::MESSAGE_DATA:
         {
             const MessageData *data
                         = reinterpret_cast<const MessageData *>(
                                         in_msg.get_data());
             std::ostringstream sout;
             sout<<"AGENT("<<getpid()<<"): "<<data->msg;
             m_logger->log(sout.str());
             m_logger->disconnect();
             MessageCompleted completed;
             m_client->send_message( completed );
             std::lock_guard<std::mutex> l(g_mutex);
             g_stop = true;
             g_event.notify_one();
             break;
         }
         default:
         {
         }
     }
     return;
 }
예제 #2
0
int main(int argc, char *argv[])
{
	CpuInfo *cpuinfo = new CpuInfo();
	MemInfo *meminfo = new MemInfo();
	FILE * fp;

	fp = fopen("system_information.txt", "w");
	
	fprintf(fp, "Clockspeed\t: %llu\n", cpuinfo->GetClockSpeed());
	fprintf(fp, "Cores\t\t: %d\n", cpuinfo->GetCores());
	fprintf(fp, "Memory\t\t: %llu\n", meminfo->GetTotalMemSize());
	fclose(fp);
}
예제 #3
0
    void connection_cb(bool connected) {
        // if connection changes, start delayed version request
        version_retries = RETRIES_COUNT;
        if (connected)
            autopilot_version_timer.start();
        else
            autopilot_version_timer.stop();

        // add/remove APM diag tasks
        if (connected && disable_diag && uas->is_ardupilotmega()) {
#ifdef MAVLINK_MSG_ID_MEMINFO
            UAS_DIAG(uas).add(mem_diag);
#endif
#ifdef MAVLINK_MSG_ID_HWSTATUS
            UAS_DIAG(uas).add(hwst_diag);
#endif
#if !defined(MAVLINK_MSG_ID_MEMINFO) || !defined(MAVLINK_MSG_ID_HWSTATUS)
            ROS_INFO_NAMED("sys", "SYS: APM detected, but mavros uses different dialect. "
                           "Extra diagnostic disabled.");
#else
            ROS_DEBUG_NAMED("sys", "SYS: APM extra diagnostics enabled.");
#endif
        }
        else {
            UAS_DIAG(uas).removeByName(mem_diag.getName());
            UAS_DIAG(uas).removeByName(hwst_diag.getName());
            ROS_DEBUG_NAMED("sys", "SYS: APM extra diagnostics disabled.");
        }
    }
예제 #4
0
void
NameServiceClient::on_data_received( const SocketPtr &in_socket,
                            const MemInfo &in_msg ) {
    std::unique_lock<std::mutex> l( m_mutex );
    const DataServiceMessage *pMsg
                = reinterpret_cast<const DataServiceMessage *>(
                                                    in_msg.get_data());
    m_status = pMsg->m_status;
    switch( pMsg->m_header.m_type ) {
        case DataMessageType::DATA_SERVICE_INFO_REPLY:
        {
            std::string data(pMsg->m_data);
            std::istringstream sin( data );
            boost::archive::text_iarchive ia( sin );
            ia & m_info;
            break;
        }
        default:
        {
        }
    }
    m_response_ready = true;
    m_response_ready_cond.notify_one();
    return;
} 
예제 #5
0
void
RemoteLogServer::on_log_received(
                    const SocketPtr &in_socket, const MemInfo &in_info ) {
    std::string message( in_info.get_data() );
    m_signal_log_message_received( message );
    return;
}
예제 #6
0
bool HttpServer::CanContinue(const MemInfo& mem, int64_t rssMb,
                             int64_t rssNeeded, int cacheFreeFactor) {
  if (!mem.valid()) return false;
  if (mem.freeMb < RuntimeOption::ServerCriticalFreeMb) return false;
  auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor);
  auto const result = (rssMb + availableMb >= rssNeeded);
  if (result) assert(CanStep(mem, rssMb, rssNeeded, cacheFreeFactor));
  return result;
}
예제 #7
0
파일: MemInfo.cpp 프로젝트: celabtud/MAIP
void MemInfo::updateMax(const MemInfo& other)
{
    max_mai = max(max_mai, other.getMAIIndex());
    max_heap_mai = max(max_heap_mai, other.getHeapMAIIndex());
    max_moi = max(max_moi, other.getMOIIndex());
    max_heap_moi = max(max_heap_moi, other.getHeapMOIIndex());
    max_stack = max(max_stack, other.getStackRatio());
    max_flow = max(max_flow, other.getFlowRatio());
    max_heap_flow = max(max_heap_flow, other.getHeapFlowRatio());
    max_bpa = max(max_bpa, other.getBytesPerAccess());
}
예제 #8
0
bool HttpServer::CanContinue(const MemInfo& mem, int64_t rssMb,
                             int64_t rssNeeded, int cacheFreeFactor) {
  assert(CanStep(mem, rssMb, rssNeeded, cacheFreeFactor));
  if (!mem.valid()) return false;
  // Don't proceed if free memory is too limited, no matter how big
  // the cache is.
  if (mem.freeMb < rssNeeded / 16) return false;
  auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor);
  return (rssMb + availableMb >= rssNeeded);
}
예제 #9
0
파일: MemInfo.cpp 프로젝트: celabtud/MAIP
void MemInfo::updateMin(const MemInfo& other)
{
    static bool firsttime = true;

    min_mai = min(min_mai, other.getMAIIndex());
    min_heap_mai = min(min_heap_mai, other.getHeapMAIIndex());
    min_moi = min(min_moi, other.getMOIIndex());
    min_heap_moi = min(min_heap_moi, other.getHeapMOIIndex());
    min_stack = min(min_stack, other.getStackRatio());
    min_flow = min(min_flow, other.getFlowRatio());
    min_heap_flow = min(min_heap_flow, other.getHeapFlowRatio());
    min_bpa = min(min_bpa, other.getBytesPerAccess());
    firsttime = false;
}
예제 #10
0
bool HttpServer::CanStep(const MemInfo& mem, int64_t rssMb,
                         int64_t rssNeeded, int cacheFreeFactor) {
  if (!mem.valid()) return false;
  if (mem.freeMb < RuntimeOption::ServerCriticalFreeMb) return false;
  auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor);
  // Estimation of the memory needed till the next check point.  Since
  // the current check point is not the last one, we try to be more
  // optimistic, by assuming that memory requirement won't grow
  // drastically between successive check points, and that it won't
  // grow over our estimate.
  auto const neededToStep = std::min(rssNeeded / 4, rssNeeded - rssMb);
  return (availableMb >= neededToStep);
}
예제 #11
0
파일: logd.cpp 프로젝트: Tushar-Naik/hpcl
 void
 handle_server_commands( const MemInfo &in_msg ) {
     const MessageHeader *header
                             = reinterpret_cast<const MessageHeader *>(
                                                 in_msg.get_data() );
     switch( header->m_type ) {
         case MESSAGE_LOGD_SHUTDOWN:
         {
             std::lock_guard<std::mutex> l( m_log_mutex );
             m_stop = true;
             m_log_event.notify_one();
             break;
         }
         default:
         {
         }
     }
 }
예제 #12
0
int main(int argc, char **argv) {
  MPI_Init(NULL, NULL);

  // MemInfo class:
  MemInfo* mInfo = MemInfo::GetInstance();

  // Optional: initialize it with particular file name: 
  mInfo->Init("mem_info.log");

  // Test for the amount of memory in GB (all nodes):
  float chk_mem_gb = 2.0;
  int fail = mInfo->BelowThreshold(chk_mem_gb);
  if (fail > 0)
    fprintf(stderr, "WARNING: %d cores report memory shortage!\n", fail);

  // Print one line logs:
  for (int i = 0; i < 3; ++i) {
    void* p;
    if ((p=malloc(1<<28)) == NULL) {  // allocate 256MB
      puts("malloc() failed");
      break;
    }
    memset(p, 0, (1<<28));
    char info[32];
    snprintf(info, sizeof(info), "Step %d", i);
    mInfo->LogSummary(info);    // log memory status
  }

  // Print info for all MPI ranks to stdout:
  mInfo->PrintAll(stdout);

  // Get available and total memory for "my" node [GB]:
  float avail_mem, total_mem;
  mInfo->GetMemInfo(&avail_mem, &total_mem);

  MPI_Finalize();
  return(0);
}
예제 #13
0
 void handle_meminfo(const mavlink_message_t *msg, uint8_t sysid, uint8_t compid) {
     mavlink_meminfo_t mem;
     mavlink_msg_meminfo_decode(msg, &mem);
     mem_diag.set(mem.freemem, mem.brkval);
 }
예제 #14
0
void
DataServer::on_data_received(
            const SocketPtr &in_socket, const MemInfo &in_msg ) {
    const DataServiceMessage *pMsg
            = reinterpret_cast<const DataServiceMessage *>(
                                    in_msg.get_data());
    DataServiceMessage reply( DATA_SERVICE_GENERAL_REPLY );
    bool status = false;
    switch( pMsg->m_header.m_type ) {
        case DataMessageType::DATA_SERVICE_REGISTER:
        {
            std::string buf = pMsg->m_data;
            std::istringstream ifs( buf );
            boost::archive::text_iarchive ia( ifs );
            ServiceRequestData data;
            ia & data;
            status = on_service_register_request(
                                        data.m_service_name,
                                        data.m_hostname, data.m_port );
            break;
        }
        case DataMessageType::DATA_SERVICE_UNREGISTER:
        {
            std::string buf = pMsg->m_data;
            std::istringstream ifs( buf );
            boost::archive::text_iarchive ia( ifs );
            ServiceRequestData data;
            ia & data;
            status = on_service_unregister_request(
                                        data.m_service_name,
                                        data.m_hostname, data.m_port );
            break;
        }
        case DataMessageType::DATA_SERVICE_INFO_REQUEST:
        {
            std::string buf = pMsg->m_data;
            std::istringstream ifs( buf );
            boost::archive::text_iarchive ia( ifs );
            ServiceRequestData data;
            ia & data;
            ServiceInfoPtr info;
            status = on_service_info_request( data.m_service_name, info );
            if( info ) {
                std::ostringstream sout;
                boost::archive::text_oarchive oa(sout);
                oa & info;
                std::strncpy( reply.m_data,
                                sout.str().c_str(), sout.str().size());
            }
            reply.m_header.m_type =  DATA_SERVICE_INFO_REPLY;
            break;
        }
        default:
        {
        }
    }
    reply.m_status = status;
    MemInfo replyMsg( reinterpret_cast<char *>( &reply ),
                        sizeof( DataServiceMessage ) );
    in_socket->send_data( replyMsg );
}
예제 #15
0
파일: client.cpp 프로젝트: Tushar-Naik/hpcl
void
handle_data( const SocketPtr &in_socket, const MemInfo &in_data ) {
    std::string msg = in_data.get_data();
    std::cout<<"From server: "<<msg<<std::endl;
    return;
}