Contact Info

Crumbtrail

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

Win32_PerfFormattedData_W3SVC_WebService jscript 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_PerfFormattedData_W3SVC_WebService WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;

var arrComputers = new Array("\localhost");
for (i = 0; i < arrComputers.length; i++) {
   WScript.Echo();
   WScript.Echo("==========================================");
   WScript.Echo("Computer: " + arrComputers[i]);
   WScript.Echo("==========================================");

   var objWMIService = GetObject("winmgmts:\\\\" + arrComputers[i] + "\\root\\CIMV2");
   var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_W3SVC_WebService", "WQL",
                                          wbemFlagReturnImmediately | wbemFlagForwardOnly);

   var enumItems = new Enumerator(colItems);
   for (; !enumItems.atEnd(); enumItems.moveNext()) {
      var objItem = enumItems.item();

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