0

I want to monitore swap space usage on windows 2003 server. If the usage is over 80% for 10 minutes, an alarm will be generated. There are lot of tools for RAM, but how about swap usage? How do I simulate that condition and do the test?

4

2 回答 2

1

使用内置的性能计数器。您可以通过 WMI/Win32_Perf 获取它们:

http://msdn.microsoft.com/en-us/library/aa394270%28v=VS.85%29.aspx

或原始性能计数器/注册表接口:

http://msdn.microsoft.com/en-us/library/aa373083%28v=VS.85%29.aspx

于 2010-08-31T20:52:40.720 回答
1

To force the page file to be used. Start Commiting Memmory. Use the VirtualAlloc api call:

LPVOID WINAPI VirtualAlloc(
  __in_opt  LPVOID lpAddress,
  __in      SIZE_T dwSize,
  __in      DWORD flAllocationType,
  __in      DWORD flProtect
);

and set flAllocationType to MEM_COMMIT (0x1000), this should start memory being used. Once memory is suffcient exhausted, then the page file should be automatically employed. I suspect you'll have to start measuring usage and then determine heuristically as to when %usage you require happens.

To monitor it read the performance counters. The paging file set has a %usage counter you can read. Start here on how to consume them. All you need is to create a windows service that reads the info and then rings the appropriate alarms.

.Net : http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx C++ : http://msdn.microsoft.com/en-us/library/aa373219(v=VS.85).aspx or http://msdn.microsoft.com/en-us/library/aa373214(v=VS.85).aspx

于 2010-08-31T00:53:10.623 回答