cpu and memory load

Hi,

Does anyone know how to get the current cpu load (in percentage). And the memory load (Ram and swap, if possible seperate).

Thanks
Marc
hellfire052497Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
thanks ;-)
0
 
intheCommented:
if this is for win9*
try this for cpu usage(it dont work for me though)

procedure UpdateTimer(Sender: TObject);
var
 RegIni  : TRegIniFile;
 I       : Integer;
begin
 RegIni := TRegIniFile.Create('');
 with RegIni do
  begin
   RootKey := HKEY_DYN_DATA;
   LazyWrite := True;
   OpenKey('\Perfstats\StatData',False);

   ReadBinaryData('KERNEL\CPUUsage', I, SizeOf(I));
   Free;
  end;
  OvcMeter1.Percent := I;
end;


i can give some other stuff (imcomplete)for nt to get he cpu usage by each process.



for the memory stuff you can use this:

unit GlobalMemoryStatusU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TGlobalMemoryStatusForm = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    ButtonGlobalMemoryStatus: TButton;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    procedure ButtonGlobalMemoryStatusClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  GlobalMemoryStatusForm: TGlobalMemoryStatusForm;

implementation

{$R *.DFM}

procedure TGlobalMemoryStatusForm.ButtonGlobalMemoryStatusClick(
  Sender: TObject);
var
  GlobalMemoryInfo : TMemoryStatus;  // holds the global memory status information
begin
  {set the size of the structure before the call.}
  GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo);

  {retrieve the global memory status...}
  GlobalMemoryStatus(GlobalMemoryInfo);

  {and display the information}
  Label1.caption := 'Results of GlobalMemoryStatus:';
  Label2.caption := 'Record structure size: '+IntToStr(
                     GlobalMemoryInfo.dwLength)+' bytes';
  Label3.caption := 'Current memory load: '+IntToStr(
                     GlobalMemoryInfo.dwMemoryLoad)+'%';
  Label4.caption := 'Total physical memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwTotalPhys/1])+' bytes';
  Label5.caption := 'Total available physical memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwAvailPhys/1])+' bytes';
  Label6.caption := 'Total paging file size: '+Format('%.0n',[
                     GlobalMemoryInfo.dwTotalPageFile/1])+' bytes';
  Label7.Caption := 'Total available paging file memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwAvailPageFile/1])+' bytes';
  Label8.caption := 'Total virtual memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwTotalVirtual/1])+' bytes';
  Label9.caption := 'Total available virtual memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwAvailVirtual/1])+' bytes';
end;

end.
0
 
hellfire052497Author Commented:
Hi,

sure give the NT stuff too, i'm switching to it next week.

Thanks
Marc
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
intheCommented:
see here for some (kind of relevent)info:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10243139 

but use the components from this link:
http://aldyn.chat.ru/
they work only on nt.
0
 
bryan7Commented:
listenning
0
 
rwilson032697Commented:
Eavesdropping
0
 
hellfire052497Author Commented:
Hi,

great, it all works. If you like to lock the question so I can give you the points

Marc
0
All Courses

From novice to tech pro — start learning today.