BOOL CMonitorService::CheckMemory()
{
	UINT	nTotal, nUse, nFree, nCache, nBuffer;
	UINT	nFlashTotal=0, nFlashUse, nFlashFree;
	double	fSize, fFlashSize;
    BOOL    bReturn = TRUE;

	GetMemoryInfo(&nTotal, &nUse, &nFree, &nCache, &nBuffer);
	
#if defined(__TI_AM335X__)
    /** TI Multi boot 를 위해 두가지 검사를 한다.
      * SPI boot일 경우 /dev/root 를 검사하고
      * NAND boot일 경우에는 ubi1:rootfs 를 검사해야 한다
      */
	GetFlashInfo("/dev/root", &nFlashTotal, &nFlashUse, &nFlashFree);
    if(nFlashTotal <= 0)
    {
	    GetFlashInfo("ubi1:rootfs", &nFlashTotal, &nFlashUse, &nFlashFree);
    }    
    
#endif
	fSize = (double)nFree / (double)(1024*1024);
	fFlashSize = (double)nFlashFree / (double)(1024*1024);

	if (nFlashFree < (100*1024)) bReturn = FALSE;
	if (nFree < (5000*1024)) bReturn = FALSE;

    if(!bReturn) {
	    printf("Memory [Share] Total=%d, Use=%d, Free=%d(%.2fM)\r\n", nTotal, nUse, nFree, fSize);
	    printf("        [root] Total=%d, Use=%d, Free=%d(%.2fM)\r\n", nFlashTotal, nFlashUse, nFlashFree, fFlashSize);
    }

	return bReturn;
}
Beispiel #2
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	void WriteSystemSpecToLog(Log* log) {
		log->WriteLineStrongly("システム情報");

		log->BeginTable();

		log->Write("CPU名");
		log->ChangeColumn();
		log->Write(GetCPUName().c_str());
		log->ChangeRow();
		
		log->Write("OS情報");
		log->ChangeColumn();
#if defined(_WIN32)
		log->Write("OS: Windows\n");
		log->Write(GetWindowsVersion().c_str());
#else
		log->Write("Unavailable");
#endif
		log->ChangeRow();
		
		log->Write("メモリ情報");
		log->ChangeColumn();
		log->Write(GetMemoryInfo().c_str());

		log->EndTable();
	}
Beispiel #3
0
void REEMemoryObject::Write(void* source, size_t size)
{
    SIZE_T size_written;

    WriteProcessMemory(GetProcessHandle(), GetMemoryInfo(infoMemory)->address, source, size, &size_written);

    DEBUG_ASSERT(size_written != size);
}
Beispiel #4
0
void REEMemoryObject::Read(void* dest, size_t size)
{
    SIZE_T size_read;

    ReadProcessMemory(GetProcessHandle(), GetMemoryInfo(infoMemory)->address, dest, size, &size_read);

    DEBUG_ASSERT(size_read != size);
}
Beispiel #5
0
void REEMemoryReservedObject::Write(HREEMEMORY memory, void* source, size_t size)
{
    SIZE_T size_written;

    WriteProcessMemory(GetProcessHandle(), GetMemoryInfo(memory)->address, source, size, &size_written);

    DEBUG_ASSERT(size_written != size);
}
Beispiel #6
0
void REEMemoryReservedObject::Read(HREEMEMORY memory, void* dest, size_t size)
{
    SIZE_T size_read;

    ReadProcessMemory(GetProcessHandle(), GetMemoryInfo(memory)->address, dest, size, &size_read);

    DEBUG_ASSERT(size_read != size);
}
Beispiel #7
0
void REEMemoryReservedObject::Distroy(HREEMEMORY memory)
{
    REE_MEMORY_INFO* info = GetMemoryInfo(memory);

    DEBUG_ASSERT(!VirtualFreeEx(
        GetProcessHandle(),
        info->address,
        info->size,
        MEM_DECOMMIT));

    DistroyMemoryInfo(info);
}
Beispiel #8
0
STCltHardwareInfo& CSystemInfo::GetHardwareInfo()
{
	GetCPUInfo();
	GetMainboardInfo();
	GetMemoryInfo();
	GetHarddiskInfo();
	GetSoundCardInfo();
	GetGraphicsInfo();
	GetNICInfo();
	GetCameraInfo();

	return m_stCltHardInfo;
}
BOOL CMonitorService::Startup()
{
    struct  sigaction   handler;
    VAROBJECT *pObject;

    // Set Interrrupt Signal Handler
    handler.sa_handler = InterruptSignalHandler;
    sigfillset(&handler.sa_mask);
    sigaction(SIGINT, &handler, 0);
    sigaction(SIGTERM, &handler, 0);
    sigaction(SIGCHLD, &handler, 0);

	DisplaySplash();

	VARAPI_Initialize(VARCONF_FILENAME, (VAROBJECT *)m_Root_node, FALSE);

    // Local Port에 대한 설정 값을 얻어온다
	pObject = VARAPI_GetObjectByName("sysLocalPort");
	if (pObject != NULL) 
    {
        m_nPort = pObject->var.stream.u32;
    }

    if(m_nPort == 0)
    {
        m_nPort = 8000; // Default Port
    }

	IF4API_Initialize(m_nPort, NULL);

	GetMemoryInfo(&m_nTotal, &m_nUse, &m_nFree, &m_nCache, &m_nBuffer);

    usleep(60*1000000);
    m_tmLastCheck = uptime();
	for(;!m_bExitSignalPending;)
	{
		usleep(10*1000000);
		WatchSystem();
	}
	return TRUE;
}
Beispiel #10
0
 double GetMemoryUsage() {
     engine_memory_info mem = GetMemoryInfo();
     return (double) mem.myPhysicalUsed / (double) mem.totalPhysical;
 }
Beispiel #11
0
void* REEMemoryReservedObject::GetAddressOf(HREEMEMORY memory)
{
    return GetMemoryInfo(memory)->address;
}
Beispiel #12
0
std::string System::GetVirtualMemoryUsage() {
    return FormatOutput(GetMemoryInfo().PrivateUsage);
}
Beispiel #13
0
void ProcessCpuMemInfo(wstring apiKey, wstring envKey, SOCKET socketHandle, sockaddr_in remoteServAddr, int interval)
{
    StringBuilder sb;
    int sleepTime = interval * 1000;

    while (true)
    {
        if (g_servicePaused == FALSE)
        {
            sb.clear();

            sb.push_back(L"{");
            {
                sb.push_back(L"\"" + SystemInfo::Members::cpuUsage + L"\":");
                sb.push_back(L"{");
                {
                    float totalUsage = 0.0f;
                    sb.push_back(L"\"" + CpuInfo::Members::unit + L"\":[");
                    if (RetrieveCpuInfo(sb, &totalUsage) == false)
                    {
                        Sleep(1000);
                        continue;
                    }

                    sb.push_back(L"]");

                    wchar_t buf[40];
                    StringCchPrintf(buf, 40, L", \"%s\": %.2f", CpuInfo::Members::total.c_str(), totalUsage / 100);
                    sb.push_back(buf);
                }
                sb.push_back(L"},");

                __int64 maxMemory;
                __int64 currentUsage;
                GetMemoryInfo(&maxMemory, &currentUsage);

                sb.push_back(L"\"" + SystemInfo::Members::memoryUsage + L"\":");
                {
                    sb.push_back(L"{\"" + MemoryInfo::Members::max + L"\":");
                    sb.push_back(maxMemory);

                    sb.push_back(L", \"" + MemoryInfo::Members::current + L"\":");
                    sb.push_back(currentUsage);
                    sb.push_back(L"},");
                }

                sb.push_back(L"\"" + PacketBase::Members::groupKey + L"\":");
                sb.push_back(L"\"");
                sb.push_back(apiKey);
                sb.push_back(L"\",");

                sb.push_back(L"\"" + PacketBase::Members::machineId + L"\":");
                sb.push_back(L"\"");
                sb.push_back(envKey);
                sb.push_back(L"\"");
            }

            sb.push_back(L"}");

            SendToServer(socketHandle, remoteServAddr, sb);

            if (g_isConsoleApp == TRUE)
            {
                printf(".");
            }
        }

        if (::WaitForSingleObject(g_killServiceEvent, sleepTime) == WAIT_TIMEOUT)
        {
            continue;
        }

#if defined(_DEBUG)
        ::OutputDebugString(L"ProcessCpuMemInfo-thread exited.");
#endif

        break;
    }
}
Beispiel #14
0
std::string System::GetPhysicalMemoryUsage() {
    return FormatOutput(GetMemoryInfo().WorkingSetSize);
}
Beispiel #15
0
std::string System::GetVirtualMemoryUsage() {
    return FormatOutput(GetMemoryInfo().virtual_size);
}
bool CProtocolDemo::ChangeValue(CPointDemoBase *pPoint)
{
    switch(pPoint->m_nFunction)
    {
    //cpu
    case 10://CPU 占用率
        GetCPUInfo(pPoint);
        break;
    //内存 主存 虚存
    case 20://物理内存总数
        GetMemoryInfo(pPoint);
        break;
    case 22://物理内存空闲
        GetMemoryInfo(pPoint);
        break;
    case 24://物理内存使用
        GetMemoryInfo(pPoint);
        break;
    case 26://虚内存总数
        GetMemoryInfo(pPoint);
        break;
    case 28://虚内存空闲
        GetMemoryInfo(pPoint);
        break;
    case 30://虚内存占用
        GetMemoryInfo(pPoint);
        break;
    case 32://文件页总数
        GetMemoryInfo(pPoint);
        break;
    case 34://文件页空闲
        GetMemoryInfo(pPoint);
        break;
    case 36://文件页占用
        GetMemoryInfo(pPoint);
        break;
    case 38://内存占用率
        GetMemoryInfo(pPoint);
//        (2)   内存使用率
//          这里需要从/proc/meminfo文件中提取两个数据,当前内存的使用量(cmem)以及内存总量(amem)。
//          内存使用百分比   =   100   *   (cmem   /   umem)
        break;
    case 40://当前程序占用空间
        GetMemoryInfo(pPoint);
        break;
    case 42://内存使用峰值
        GetMemoryInfo(pPoint);
        break;
    case 44://占用的虚拟内存大小
        GetMemoryInfo(pPoint);
        break;
    case 46://占用的虚拟内存峰值
        GetMemoryInfo(pPoint);
        break;

    //时间 当前时间,系统启动时间,程序运行时间
    case 50://windows系统已经运行时间
//        fValue=GetTimeInfo(pPoint->m_nFunction);
        GetTimeInfo(pPoint);
        break;
    case 52://程序启动时间 秒
//        fValue=GetTimeInfo(pPoint->m_nFunction);
        GetTimeInfo(pPoint);
        break;
    case 54://程序运行时间 秒
//        fValue=GetTimeInfo(pPoint->m_nFunction);
        GetTimeInfo(pPoint);
        break;
    case 56://内核时间
//        fValue=GetTimeInfo(pPoint->m_nFunction);
//        GetTimeInfo(pPoint->m_nFunction);
        GetTimeInfo(pPoint);
        break;
    case 58://用户时间
//        fValue=GetTimeInfo(pPoint->m_nFunction);
//        GetTimeInfo(pPoint->m_nFunction);
        GetTimeInfo(pPoint);
        break;

        //磁盘空间 a b  c d e f g   占用/总/空闲
    case 60:
//        fValue=GetDiskInfo(pPoint->m_nPara1,pPoint->m_nPara2);
        break;

    //各种随机数据
    case 70://常量   参数为:70 常量值
        GetRand(pPoint);
        break;
    case 72://一定范围内的随机量 参数为:72 最大值 最小值
        GetRand(pPoint);
        break;
    case 74://单调增加 参数为:74 初值  终值 步长(<0 为单调递减)
        GetRand(pPoint);
        break;
    case 76://正弦变量 参数为:76 基值 幅值 步长(角度)
        GetRand(pPoint);
        break;
    case 78://方波  参数为:78 高值,低值(扫描周期就是方波长度)
        GetRand(pPoint);
        break;
    case 80://遥信量 参数为:80 (扫描周期就是变位周期)
        GetRand(pPoint);
        break;
    case 82://遥信量  参数为:82每次变位的可能性(0-100)
        GetRand(pPoint);
        break;
    default:
        Q_ASSERT(false);//"未定义的取值方式\n"
        break;
    }
    return true;
}
void CCrashDumpWriter::DumpMiniDump ( _EXCEPTION_POINTERS* pException, CExceptionInformation* pExceptionInformation )
{
    WriteDebugEvent ( "CCrashDumpWriter::DumpMiniDump" );

    // Try to load the DLL in our directory
    HMODULE hDll = NULL;
    char szDbgHelpPath [MAX_PATH];
    if ( GetModuleFileNameA ( NULL, szDbgHelpPath, MAX_PATH ) )
    {
        char* pSlash = _tcsrchr ( szDbgHelpPath, '\\' );
        if ( pSlash )
        {
            _tcscpy ( pSlash + 1, "DBGHELP.DLL" );
            hDll = LoadLibrary ( szDbgHelpPath );
        }
    }

    // If we couldn't load the one in our dir, load any version available
    if ( !hDll )
    {
        hDll = LoadLibrary( "DBGHELP.DLL" );
    }

    if ( !hDll )
        AddReportLog( 9201, "CCrashDumpWriter::DumpMiniDump - Could not load DBGHELP.DLL" );

    // We could load a dll?
    if ( hDll )
    {
        // Grab the MiniDumpWriteDump proc address
        MINIDUMPWRITEDUMP pDump = reinterpret_cast < MINIDUMPWRITEDUMP > ( GetProcAddress( hDll, "MiniDumpWriteDump" ) );
        if ( !pDump )
            AddReportLog( 9202, "CCrashDumpWriter::DumpMiniDump - Could not find MiniDumpWriteDump" );

        if ( pDump )
        {
            // Create the file
            HANDLE hFile = CreateFile ( CalcMTASAPath ( "mta\\core.dmp" ), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
            if ( hFile == INVALID_HANDLE_VALUE )
                AddReportLog( 9203, SString( "CCrashDumpWriter::DumpMiniDump - Could not create '%s'", *CalcMTASAPath ( "mta\\core.dmp" ) ) );

            if ( hFile != INVALID_HANDLE_VALUE )
            {
                // Create an exception information struct
                _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
                ExInfo.ThreadId = GetCurrentThreadId ();
                ExInfo.ExceptionPointers = pException;
                ExInfo.ClientPointers = FALSE;

                // Write the dump
                BOOL bResult = pDump ( GetCurrentProcess(), GetCurrentProcessId(), hFile, (MINIDUMP_TYPE)( MiniDumpNormal | MiniDumpWithIndirectlyReferencedMemory ), &ExInfo, NULL, NULL );

                if ( !bResult )
                    AddReportLog( 9204, SString( "CCrashDumpWriter::DumpMiniDump - MiniDumpWriteDump failed (%08x)", GetLastError() ) );
                else
                    WriteDebugEvent ( "CCrashDumpWriter::DumpMiniDump - MiniDumpWriteDump succeeded" );

                // Close the dumpfile
                CloseHandle ( hFile );

                // Grab the current time
                // Ask windows for the system time.
                SYSTEMTIME SystemTime;
                GetLocalTime ( &SystemTime );

                // Create the dump directory
                CreateDirectory ( CalcMTASAPath ( "mta\\dumps" ), 0 );
                CreateDirectory ( CalcMTASAPath ( "mta\\dumps\\private" ), 0 );

                SString strModuleName = pExceptionInformation->GetModuleBaseName ();
                strModuleName = strModuleName.ReplaceI ( ".dll", "" ).Replace ( ".exe", "" ).Replace ( "_", "" ).Replace ( ".", "" ).Replace ( "-", "" );
                if ( strModuleName.length () == 0 )
                    strModuleName = "unknown";

                SString strMTAVersionFull = SString ( "%s.%s", MTA_DM_BUILDTAG_LONG, *GetApplicationSetting ( "mta-version-ext" ).SplitRight ( ".", NULL, -2 ) );
                SString strSerialPart = GetApplicationSetting ( "serial" ).substr ( 0, 5 );
                uint uiServerIP = GetApplicationSettingInt ( "last-server-ip" );
                uint uiServerPort = GetApplicationSettingInt ( "last-server-port" );
                int uiServerTime = GetApplicationSettingInt ( "last-server-time" );
                int uiServerDuration = _time32 ( NULL ) - uiServerTime;
                uiServerDuration = Clamp ( 0, uiServerDuration + 1, 0xfff );

                // Get path to mta dir
                SString strPathCode;
                {
                    std::vector < SString > parts;
                    PathConform ( CalcMTASAPath ( "" ) ).Split ( PATH_SEPERATOR, parts );
                    for ( uint i = 0 ; i < parts.size () ; i++ )
                    {
                        if ( parts[i].CompareI ( "Program Files" ) )
                            strPathCode += "Pr";
                        else
                        if ( parts[i].CompareI ( "Program Files (x86)" ) )
                            strPathCode += "Px";
                        else
                        if ( parts[i].CompareI ( "MTA San Andreas" ) )
                            strPathCode += "Mt";
                        else
                        if ( parts[i].BeginsWithI ( "MTA San Andreas" ) )
                            strPathCode += "Mb";
                        else
                            strPathCode += parts[i].Left ( 1 ).ToUpper ();
                    }
                }

                // Ensure filename parts match up with EDumpFileNameParts
                SString strFilename ( "mta\\dumps\\private\\client_%s_%s_%08x_%x_%s_%08X_%04X_%03X_%s_%04d%02d%02d_%02d%02d.dmp",
                                             strMTAVersionFull.c_str (),
                                             strModuleName.c_str (),
                                             pExceptionInformation->GetAddressModuleOffset (),
                                             pExceptionInformation->GetCode () & 0xffff,
                                             strPathCode.c_str (),
                                             uiServerIP,
                                             uiServerPort,
                                             uiServerDuration,
                                             strSerialPart.c_str (),
                                             SystemTime.wYear,
                                             SystemTime.wMonth,
                                             SystemTime.wDay,
                                             SystemTime.wHour,
                                             SystemTime.wMinute
                                           );

                SString strPathFilename = CalcMTASAPath ( strFilename );

                // Copy the file
                CopyFile ( CalcMTASAPath ( "mta\\core.dmp" ), strPathFilename, false );

                // For the dump uploader
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "none" );
                SetApplicationSetting ( "diagnostics", "last-dump-save", strPathFilename );

                // Try to append pool sizes info to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-pools" );
                CBuffer poolInfo;
                GetPoolInfo ( poolInfo );
                AppendToDumpFile ( strPathFilename, poolInfo, 'POLs', 'POLe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-pools" );

                // Try to append d3d state info to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-d3d" );
                CBuffer d3dInfo;
                GetD3DInfo ( d3dInfo );
                AppendToDumpFile ( strPathFilename, d3dInfo, 'D3Ds', 'D3De' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-d3d" );

                // Try to append crash averted stats to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-crash-averted" );
                CBuffer crashAvertedStats;
                GetCrashAvertedStats ( crashAvertedStats );
                AppendToDumpFile ( strPathFilename, crashAvertedStats, 'CASs', 'CASe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-crash-averted" );

                // Try to append log info to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-log" );
                CBuffer logInfo;
                GetLogInfo ( logInfo );
                AppendToDumpFile ( strPathFilename, logInfo, 'LOGs', 'LOGe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-log" );

                // Try to append dx info to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-misc" );
                CBuffer dxInfo;
                GetDxInfo ( dxInfo );
                AppendToDumpFile ( strPathFilename, dxInfo, 'DXIs', 'DXIe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-misc" );

                // Try to append misc info to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-misc" );
                CBuffer miscInfo;
                GetMiscInfo ( miscInfo );
                AppendToDumpFile ( strPathFilename, miscInfo, 'MSCs', 'MSCe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-misc" );

                // Try to append memory info to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-mem" );
                CBuffer memInfo;
                GetMemoryInfo ( memInfo );
                AppendToDumpFile ( strPathFilename, memInfo, 'MEMs', 'MEMe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-mem" );

                // Try to logfile.txt to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-logfile" );
                CBuffer logfileContent;
                logfileContent.LoadFromFile( CalcMTASAPath( PathJoin( "mta", "logs", "logfile.txt" ) ) );
                AppendToDumpFile ( strPathFilename, logfileContent, 'LOGs', 'LOGe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-logfile" );

                // Try to report.log to dump file
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "try-report" );
                CBuffer reportLogContent;
                reportLogContent.LoadFromFile( PathJoin( GetMTADataPath(), "report.log" ) );
                AppendToDumpFile ( strPathFilename, reportLogContent, 'REPs', 'REPe' );
                SetApplicationSetting ( "diagnostics", "last-dump-extra", "added-report" );
            }
        }

        // Free the DLL again
        FreeLibrary ( hDll );
    }

    // Auto-fixes

    // Check if crash was in volumetric shadow code
    if ( ms_uiInCrashZone == 1 || ms_uiInCrashZone == 2 )
    {
        CVARS_SET( "volumetric_shadows", false );
        CCore::GetSingleton().SaveConfig();
        AddReportLog( 9205, "Disabled volumetric shadows" );
    }

    CNet* pNet = CCore::GetSingleton().GetNetwork();
    if ( pNet )
        pNet->PostCrash();    
}
Beispiel #18
0
size_t REEMemoryReservedObject::GetSizeOf(HREEMEMORY memory)
{
    return GetMemoryInfo(memory)->size;
}
Beispiel #19
0
std::string System::GetPhysicalMemoryUsage() {
    return FormatOutput(GetMemoryInfo().resident_size);
}
Beispiel #20
0
ECode CDebug::GetMemoryInfo(
    /* [in] */ IDebugMemoryInfo* memoryInfo)
{
    return GetMemoryInfo(getpid(), memoryInfo);
}