Contact Info

Crumbtrail

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

Win32_PerfRawData_W3SVC perl 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_W3SVC WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

use Win32::OLE('in');

my $computer = ".";

my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_PerfRawData_W3SVC_WebService", "WQL");

foreach my $objItem (in $colItems) {
	print "AnonymousUsersPersec: $objItem->{AnonymousUsersPersec}\n";
	print "BytesReceivedPersec: $objItem->{BytesReceivedPersec}\n";
	print "BytesSentPersec: $objItem->{BytesSentPersec}\n";
	print "BytesTotalPersec: $objItem->{BytesTotalPersec}\n";
	print "Caption: $objItem->{Caption}\n";
	print "CGIRequestsPersec: $objItem->{CGIRequestsPersec}\n";
	print "ConnectionAttemptsPersec: $objItem->{ConnectionAttemptsPersec}\n";
	print "CopyRequestsPersec: $objItem->{CopyRequestsPersec}\n";
	print "CurrentAnonymousUsers: $objItem->{CurrentAnonymousUsers}\n";
	print "CurrentBlockedAsyncIORequests: $objItem->{CurrentBlockedAsyncIORequests}\n";
	print "Currentblockedbandwidthbytes: $objItem->{Currentblockedbandwidthbytes}\n";
	print "CurrentCALcountforauthenticatedusers: $objItem->{CurrentCALcountforauthenticatedusers}\n";
	print "CurrentCALcountforSSLconnections: $objItem->{CurrentCALcountforSSLconnections}\n";
	print "CurrentCGIRequests: $objItem->{CurrentCGIRequests}\n";
	print "CurrentConnections: $objItem->{CurrentConnections}\n";
	print "CurrentISAPIExtensionRequests: $objItem->{CurrentISAPIExtensionRequests}\n";
	print "CurrentNonAnonymousUsers: $objItem->{CurrentNonAnonymousUsers}\n";
	print "DeleteRequestsPersec: $objItem->{DeleteRequestsPersec}\n";
	print "Description: $objItem->{Description}\n";
	print "FilesPersec: $objItem->{FilesPersec}\n";
	print "FilesReceivedPersec: $objItem->{FilesReceivedPersec}\n";
	print "FilesSentPersec: $objItem->{FilesSentPersec}\n";
	print "Frequency_Object: $objItem->{Frequency_Object}\n";
	print "Frequency_PerfTime: $objItem->{Frequency_PerfTime}\n";
	print "Frequency_Sys100NS: $objItem->{Frequency_Sys100NS}\n";
	print "GetRequestsPersec: $objItem->{GetRequestsPersec}\n";
	print "HeadRequestsPersec: $objItem->{HeadRequestsPersec}\n";
	print "ISAPIExtensionRequestsPersec: $objItem->{ISAPIExtensionRequestsPersec}\n";
	print "LockedErrorsPersec: $objItem->{LockedErrorsPersec}\n";
	print "LockRequestsPersec: $objItem->{LockRequestsPersec}\n";
	print "LogonAttemptsPersec: $objItem->{LogonAttemptsPersec}\n";
	print "MaximumAnonymousUsers: $objItem->{MaximumAnonymousUsers}\n";
	print "MaximumCALcountforauthenticatedusers: $objItem->{MaximumCALcountforauthenticatedusers}\n";
	print "MaximumCALcountforSSLconnections: $objItem->{MaximumCALcountforSSLconnections}\n";
	print "MaximumCGIRequests: $objItem->{MaximumCGIRequests}\n";
	print "MaximumConnections: $objItem->{MaximumConnections}\n";
	print "MaximumISAPIExtensionRequests: $objItem->{MaximumISAPIExtensionRequests}\n";
	print "MaximumNonAnonymousUsers: $objItem->{MaximumNonAnonymousUsers}\n";
	print "MeasuredAsyncIOBandwidthUsage: $objItem->{MeasuredAsyncIOBandwidthUsage}\n";
	print "MkcolRequestsPersec: $objItem->{MkcolRequestsPersec}\n";
	print "MoveRequestsPersec: $objItem->{MoveRequestsPersec}\n";
	print "Name: $objItem->{Name}\n";
	print "NonAnonymousUsersPersec: $objItem->{NonAnonymousUsersPersec}\n";
	print "NotFoundErrorsPersec: $objItem->{NotFoundErrorsPersec}\n";
	print "OptionsRequestsPersec: $objItem->{OptionsRequestsPersec}\n";
	print "OtherRequestMethodsPersec: $objItem->{OtherRequestMethodsPersec}\n";
	print "PostRequestsPersec: $objItem->{PostRequestsPersec}\n";
	print "PropfindRequestsPersec: $objItem->{PropfindRequestsPersec}\n";
	print "ProppatchRequestsPersec: $objItem->{ProppatchRequestsPersec}\n";
	print "PutRequestsPersec: $objItem->{PutRequestsPersec}\n";
	print "SearchRequestsPersec: $objItem->{SearchRequestsPersec}\n";
	print "ServiceUptime: $objItem->{ServiceUptime}\n";
	print "Timestamp_Object: $objItem->{Timestamp_Object}\n";
	print "Timestamp_PerfTime: $objItem->{Timestamp_PerfTime}\n";
	print "Timestamp_Sys100NS: $objItem->{Timestamp_Sys100NS}\n";
	print "TotalAllowedAsyncIORequests: $objItem->{TotalAllowedAsyncIORequests}\n";
	print "TotalAnonymousUsers: $objItem->{TotalAnonymousUsers}\n";
	print "TotalBlockedAsyncIORequests: $objItem->{TotalBlockedAsyncIORequests}\n";
	print "Totalblockedbandwidthbytes: $objItem->{Totalblockedbandwidthbytes}\n";
	print "TotalBytesReceived: $objItem->{TotalBytesReceived}\n";
	print "TotalBytesSent: $objItem->{TotalBytesSent}\n";
	print "TotalBytesTransferred: $objItem->{TotalBytesTransferred}\n";
	print "TotalCGIRequests: $objItem->{TotalCGIRequests}\n";
	print "TotalConnectionAttemptsallinstances: $objItem->{TotalConnectionAttemptsallinstances}\n";
	print "TotalCopyRequests: $objItem->{TotalCopyRequests}\n";
	print "TotalcountoffailedCALrequestsforauthenticatedusers: $objItem->{TotalcountoffailedCALrequestsforauthenticatedusers}\n";
	print "TotalcountoffailedCALrequestsforSSLconnections: $objItem->{TotalcountoffailedCALrequestsforSSLconnections}\n";
	print "TotalDeleteRequests: $objItem->{TotalDeleteRequests}\n";
	print "TotalFilesReceived: $objItem->{TotalFilesReceived}\n";
	print "TotalFilesSent: $objItem->{TotalFilesSent}\n";
	print "TotalFilesTransferred: $objItem->{TotalFilesTransferred}\n";
	print "TotalGetRequests: $objItem->{TotalGetRequests}\n";
	print "TotalHeadRequests: $objItem->{TotalHeadRequests}\n";
	print "TotalISAPIExtensionRequests: $objItem->{TotalISAPIExtensionRequests}\n";
	print "TotalLockedErrors: $objItem->{TotalLockedErrors}\n";
	print "TotalLockRequests: $objItem->{TotalLockRequests}\n";
	print "TotalLogonAttempts: $objItem->{TotalLogonAttempts}\n";
	print "TotalMethodRequests: $objItem->{TotalMethodRequests}\n";
	print "TotalMethodRequestsPersec: $objItem->{TotalMethodRequestsPersec}\n";
	print "TotalMkcolRequests: $objItem->{TotalMkcolRequests}\n";
	print "TotalMoveRequests: $objItem->{TotalMoveRequests}\n";
	print "TotalNonAnonymousUsers: $objItem->{TotalNonAnonymousUsers}\n";
	print "TotalNotFoundErrors: $objItem->{TotalNotFoundErrors}\n";
	print "TotalOptionsRequests: $objItem->{TotalOptionsRequests}\n";
	print "TotalOtherRequestMethods: $objItem->{TotalOtherRequestMethods}\n";
	print "TotalPostRequests: $objItem->{TotalPostRequests}\n";
	print "TotalPropfindRequests: $objItem->{TotalPropfindRequests}\n";
	print "TotalProppatchRequests: $objItem->{TotalProppatchRequests}\n";
	print "TotalPutRequests: $objItem->{TotalPutRequests}\n";
	print "TotalRejectedAsyncIORequests: $objItem->{TotalRejectedAsyncIORequests}\n";
	print "TotalSearchRequests: $objItem->{TotalSearchRequests}\n";
	print "TotalTraceRequests: $objItem->{TotalTraceRequests}\n";
	print "TotalUnlockRequests: $objItem->{TotalUnlockRequests}\n";
	print "TraceRequestsPersec: $objItem->{TraceRequestsPersec}\n";
	print "UnlockRequestsPersec: $objItem->{UnlockRequestsPersec}\n";
	print "\n";
	print "########\n";
	print "\n";
}