Contact Info

Crumbtrail

ActiveXperts.com » Administration » Scripts » WMI » vbscript sample

Win32_PerfRawData_PerfOS_Memory vbscript sample code

The foundations for Manageability in Windows is Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself. The Win32_PerfRawData_PerfOS_Memory WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Description

The Win32_PerfFormattedData_PerfOS_Memory "cooked" data performance counter class represents calculated counters that describe the behavior of physical and virtual memory on the computer. Physical memory is the amount of random access memory on the computer. Virtual memory consists of the space in physical memory and on disk. Many of the memory counters monitor paging, which is the movement of pages of code and data between disk and physical memory. Excessive paging, a symptom of a memory shortage, can cause delays which interfere with all system processes. This class is the Memory object for the PerfOs performance provider. The WMI source of its data is the high-performance Cooked Counter Provider. This class derives its raw data from the corresponding raw class Win32_PerfRawData_PerfOS_Memory. The original data source is the PerfOS performance library. This class was added for Windows XP.

Sample Code

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfOS_Memory",,48)
For Each objItem in colItems
    Wscript.Echo "AvailableBytes: " & objItem.AvailableBytes
    Wscript.Echo "AvailableKBytes: " & objItem.AvailableKBytes
    Wscript.Echo "AvailableMBytes: " & objItem.AvailableMBytes
    Wscript.Echo "CacheBytes: " & objItem.CacheBytes
    Wscript.Echo "CacheBytesPeak: " & objItem.CacheBytesPeak
    Wscript.Echo "CacheFaultsPersec: " & objItem.CacheFaultsPersec
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CommitLimit: " & objItem.CommitLimit
    Wscript.Echo "CommittedBytes: " & objItem.CommittedBytes
    Wscript.Echo "DemandZeroFaultsPersec: " & objItem.DemandZeroFaultsPersec
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "FreeSystemPageTableEntries: " & objItem.FreeSystemPageTableEntries
    Wscript.Echo "Frequency_Object: " & objItem.Frequency_Object
    Wscript.Echo "Frequency_PerfTime: " & objItem.Frequency_PerfTime
    Wscript.Echo "Frequency_Sys100NS: " & objItem.Frequency_Sys100NS
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PageFaultsPersec: " & objItem.PageFaultsPersec
    Wscript.Echo "PageReadsPersec: " & objItem.PageReadsPersec
    Wscript.Echo "PagesInputPersec: " & objItem.PagesInputPersec
    Wscript.Echo "PagesOutputPersec: " & objItem.PagesOutputPersec
    Wscript.Echo "PagesPersec: " & objItem.PagesPersec
    Wscript.Echo "PageWritesPersec: " & objItem.PageWritesPersec
    Wscript.Echo "PercentCommittedBytesInUse: " & objItem.PercentCommittedBytesInUse
    Wscript.Echo "PercentCommittedBytesInUse_Base: " & objItem.PercentCommittedBytesInUse_Base
    Wscript.Echo "PoolNonpagedAllocs: " & objItem.PoolNonpagedAllocs
    Wscript.Echo "PoolNonpagedBytes: " & objItem.PoolNonpagedBytes
    Wscript.Echo "PoolPagedAllocs: " & objItem.PoolPagedAllocs
    Wscript.Echo "PoolPagedBytes: " & objItem.PoolPagedBytes
    Wscript.Echo "PoolPagedResidentBytes: " & objItem.PoolPagedResidentBytes
    Wscript.Echo "SystemCacheResidentBytes: " & objItem.SystemCacheResidentBytes
    Wscript.Echo "SystemCodeResidentBytes: " & objItem.SystemCodeResidentBytes
    Wscript.Echo "SystemCodeTotalBytes: " & objItem.SystemCodeTotalBytes
    Wscript.Echo "SystemDriverResidentBytes: " & objItem.SystemDriverResidentBytes
    Wscript.Echo "SystemDriverTotalBytes: " & objItem.SystemDriverTotalBytes
    Wscript.Echo "Timestamp_Object: " & objItem.Timestamp_Object
    Wscript.Echo "Timestamp_PerfTime: " & objItem.Timestamp_PerfTime
    Wscript.Echo "Timestamp_Sys100NS: " & objItem.Timestamp_Sys100NS
    Wscript.Echo "TransitionFaultsPersec: " & objItem.TransitionFaultsPersec
    Wscript.Echo "WriteCopiesPersec: " & objItem.WriteCopiesPersec
Next