Contact Info

Crumbtrail

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

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


Sample Code

use strict;
use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my @computers = ("\localhost");
foreach my $computer (@computers) {
   print "\n";
   print "==========================================\n";
   print "Computer: $computer\n";
   print "==========================================\n";

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

   foreach my $objItem (in $colItems) {
      print "AnonymousRequests: $objItem->{AnonymousRequests}\n";
      print "AnonymousRequestsPerSec: $objItem->{AnonymousRequestsPerSec}\n";
      print "CacheAPIEntries: $objItem->{CacheAPIEntries}\n";
      print "CacheAPIHitRatio: $objItem->{CacheAPIHitRatio}\n";
      print "CacheAPIHitRatio_Base: $objItem->{CacheAPIHitRatio_Base}\n";
      print "CacheAPIHits: $objItem->{CacheAPIHits}\n";
      print "CacheAPIMisses: $objItem->{CacheAPIMisses}\n";
      print "CacheAPITurnoverRate: $objItem->{CacheAPITurnoverRate}\n";
      print "CacheTotalEntries: $objItem->{CacheTotalEntries}\n";
      print "CacheTotalHitRatio: $objItem->{CacheTotalHitRatio}\n";
      print "CacheTotalHitRatio_Base: $objItem->{CacheTotalHitRatio_Base}\n";
      print "CacheTotalHits: $objItem->{CacheTotalHits}\n";
      print "CacheTotalMisses: $objItem->{CacheTotalMisses}\n";
      print "CacheTotalTurnoverRate: $objItem->{CacheTotalTurnoverRate}\n";
      print "Caption: $objItem->{Caption}\n";
      print "CompilationsTotal: $objItem->{CompilationsTotal}\n";
      print "DebuggingRequests: $objItem->{DebuggingRequests}\n";
      print "Description: $objItem->{Description}\n";
      print "ErrorsDuringCompilation: $objItem->{ErrorsDuringCompilation}\n";
      print "ErrorsDuringExecution: $objItem->{ErrorsDuringExecution}\n";
      print "ErrorsDuringPreprocessing: $objItem->{ErrorsDuringPreprocessing}\n";
      print "ErrorsTotal: $objItem->{ErrorsTotal}\n";
      print "ErrorsTotalPerSec: $objItem->{ErrorsTotalPerSec}\n";
      print "ErrorsUnhandledDuringExecution: $objItem->{ErrorsUnhandledDuringExecution}\n";
      print "ErrorsUnhandledDuringExecutionPerSec: $objItem->{ErrorsUnhandledDuringExecutionPerSec}\n";
      print "Frequency_Object: $objItem->{Frequency_Object}\n";
      print "Frequency_PerfTime: $objItem->{Frequency_PerfTime}\n";
      print "Frequency_Sys100NS: $objItem->{Frequency_Sys100NS}\n";
      print "Name: $objItem->{Name}\n";
      print "OutputCacheEntries: $objItem->{OutputCacheEntries}\n";
      print "OutputCacheHitRatio: $objItem->{OutputCacheHitRatio}\n";
      print "OutputCacheHitRatio_Base: $objItem->{OutputCacheHitRatio_Base}\n";
      print "OutputCacheHits: $objItem->{OutputCacheHits}\n";
      print "OutputCacheMisses: $objItem->{OutputCacheMisses}\n";
      print "OutputCacheTurnoverRate: $objItem->{OutputCacheTurnoverRate}\n";
      print "PipelineInstanceCount: $objItem->{PipelineInstanceCount}\n";
      print "RequestBytesInTotal: $objItem->{RequestBytesInTotal}\n";
      print "RequestBytesOutTotal: $objItem->{RequestBytesOutTotal}\n";
      print "RequestsExecuting: $objItem->{RequestsExecuting}\n";
      print "RequestsFailed: $objItem->{RequestsFailed}\n";
      print "RequestsInApplicationQueue: $objItem->{RequestsInApplicationQueue}\n";
      print "RequestsNotAuthorized: $objItem->{RequestsNotAuthorized}\n";
      print "RequestsNotFound: $objItem->{RequestsNotFound}\n";
      print "RequestsPerSec: $objItem->{RequestsPerSec}\n";
      print "RequestsSucceeded: $objItem->{RequestsSucceeded}\n";
      print "RequestsTimedOut: $objItem->{RequestsTimedOut}\n";
      print "RequestsTotal: $objItem->{RequestsTotal}\n";
      print "SessionsAbandoned: $objItem->{SessionsAbandoned}\n";
      print "SessionsActive: $objItem->{SessionsActive}\n";
      print "SessionSQLServerconnectionstotal: $objItem->{SessionSQLServerconnectionstotal}\n";
      print "SessionStateServerconnectionstotal: $objItem->{SessionStateServerconnectionstotal}\n";
      print "SessionsTimedOut: $objItem->{SessionsTimedOut}\n";
      print "SessionsTotal: $objItem->{SessionsTotal}\n";
      print "Timestamp_Object: $objItem->{Timestamp_Object}\n";
      print "Timestamp_PerfTime: $objItem->{Timestamp_PerfTime}\n";
      print "Timestamp_Sys100NS: $objItem->{Timestamp_Sys100NS}\n";
      print "TransactionsAborted: $objItem->{TransactionsAborted}\n";
      print "TransactionsCommitted: $objItem->{TransactionsCommitted}\n";
      print "TransactionsPending: $objItem->{TransactionsPending}\n";
      print "TransactionsPerSec: $objItem->{TransactionsPerSec}\n";
      print "TransactionsTotal: $objItem->{TransactionsTotal}\n";
      print "\n";
   }
}