开发者

How to find out swap space usage on windows

I want to monitore swap space usage on windows 2003 server. If the usage is over 80% for 10 minutes,开发者_C百科 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?


Use the built-in performance counters. You can fetch them via WMI/Win32_Perf:

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

or the raw Performance counter/registry interfaces:

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


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 : https://learn.microsoft.com/en-us/archive/blogs/bclteam/how-to-read-performance-counters-ryan-byington

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜