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?

skaffman
  • 398,947
  • 96
  • 818
  • 769
eric young
  • 53
  • 1
  • 2
  • 7
  • I assumed that you're looking for a programming solution. Otherwise this question would be better asked on serverfault.com – Preet Sangha Aug 31 '10 at 05:16
  • @Preet: Actually i am looking for a solution for testing the usage of swap space (i.e., writting a program to dynamically change the usage of it to, say, 60%). Thanks for your answer though. It is useful info. – eric young Aug 31 '10 at 19:14

2 Answers2

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 : 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

Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
1

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

Bukes
  • 3,668
  • 1
  • 18
  • 20