Forum Discussion

ChrisPro's avatar
ChrisPro
Contributor
11 years ago

RAM and processor information

Hello,



I would like to display in log :

 - RAM information

 - processor information



Thanls for your answer.
  • Hi Chris,



    For CPU information, use Sys.CPU and Sys.CPUCount.



    For the memory size, use the WMI class Win32_PhysicalMemory. You'll need to sum the Capacity property values of all class instances:



    function PrintTotalMemoty()

    {

      var oWMI = GetObject("winmgmts:");

      var memSize = 0;

      var colItems = oWMI.ExecQuery("SELECT Capacity FROM Win32_PhysicalMemory");

      var enumItems = new Enumerator(colItems);

      for ( ; !enumItems.atEnd(); enumItems.moveNext())

      {

        memSize += aqConvert.StrToFloat(enumItems.item().Capacity);

      }

      Log.Message("Total physical memory: " + VarToStr(memSize) + " bytes");

    }

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Chris,



    For CPU information, use Sys.CPU and Sys.CPUCount.



    For the memory size, use the WMI class Win32_PhysicalMemory. You'll need to sum the Capacity property values of all class instances:



    function PrintTotalMemoty()

    {

      var oWMI = GetObject("winmgmts:");

      var memSize = 0;

      var colItems = oWMI.ExecQuery("SELECT Capacity FROM Win32_PhysicalMemory");

      var enumItems = new Enumerator(colItems);

      for ( ; !enumItems.atEnd(); enumItems.moveNext())

      {

        memSize += aqConvert.StrToFloat(enumItems.item().Capacity);

      }

      Log.Message("Total physical memory: " + VarToStr(memSize) + " bytes");

    }

  • Create a script and run it when you want to log the information. For instance (Java)




    function LogUsage()


    {


      Log.Message("CPU usage is " + Sys.CPUUsage + "%. Memory usage is " + Sys.MemUsage + "%.")


    }

     

  • I don't want the usage of processor or memory, but the size of processor, and the size of memory.



    Thanks for your answer.