Web/DB プログラミング徹底解説

ホーム > IIS 徹底解説! > アプリケーションプールの情報を表示する方法 (IIS WMI)

アプリケーションプールの情報を表示する方法 (IIS WMI)

スポンサーリンク

今度はアプリケーションプールの情報です。

IIS の 「アプリケーションプール」 というのは実際のところ、「複数の Web アプリケーションをホストするプロセス」 です。

アプリケーションプールの情報は ApplicationPool オブジェクトから取得可能です。 ここでは、SELECT * FROM ApplicationPool として (複数) 取得した結果を、For Each で全て表示しています。

Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

Set oAppPools = oWebAdmin.ExecQuery( "SELECT * FROM ApplicationPool" )

For Each oAppPool In oAppPools 
     
     WScript.Echo "**********"
     WScript.Echo "AutoStart = " + CStr( oAppPool.AutoStart )
     WScript.Echo "Cpu.Action = " + CStr( oAppPool.Cpu.Action )
     WScript.Echo "Cpu.Limit = " + CStr( oAppPool.Cpu.Limit )
     WScript.Echo "Cpu.ResetInterval = " + CStr( oAppPool.Cpu.ResetInterval )
     WScript.Echo "Cpu.SmpAffinitized = " + CStr( oAppPool.Cpu.SmpAffinitized )
     WScript.Echo "Cpu.SmpProcessorAffinityMask = " + CStr( oAppPool.Cpu.SmpProcessorAffinityMask )
     WScript.Echo "Cpu.SmpProcessorAffinityMask2 = " + CStr( oAppPool.Cpu.SmpProcessorAffinityMask2 )
     WScript.Echo "Enable32BitAppOnWin64 = " + CStr( oAppPool.Enable32BitAppOnWin64 )
     WScript.Echo "Failure.AutoShutdownExe = " + oAppPool.Failure.AutoShutdownExe
     WScript.Echo "Failure.AutoShutdownParams = " + oAppPool.Failure.AutoShutdownParams
     WScript.Echo "Failure.LoadBalancerCapabilities = " _
		 + GetLoadBalancerCapabilities( oAppPool.Failure.LoadBalancerCapabilities )
     WScript.Echo "Failure.OrphanActionExe = " + oAppPool.Failure.OrphanActionExe
     WScript.Echo "Failure.OrphanActionParams = " + oAppPool.Failure.OrphanActionParams
     WScript.Echo "Failure.OrphanWorkerProcess = " + CStr( oAppPool.Failure.OrphanWorkerProcess )
     WScript.Echo "Failure.RapidFailProtection = " + CStr( oAppPool.Failure.RapidFailProtection )
     WScript.Echo "Failure.RapidFailProtectionInterval = " _
		 + oAppPool.Failure.RapidFailProtectionInterval
     WScript.Echo "Failure.RapidFailProtectionMaxCrashes = " _
		 + CStr( oAppPool.Failure.RapidFailProtectionMaxCrashes )
     WScript.Echo "ManagedPipelineMode = " + CStr( oAppPool.ManagedPipelineMode )
     WScript.Echo "ManagedRuntimeVersion = " + oAppPool.ManagedRuntimeVersion
     WScript.Echo "Name = " + oAppPool.Name
     WScript.Echo "PassAnonymousToken = " + CStr( oAppPool.PassAnonymousToken )
     WScript.Echo "ProcessModel.IdentityType = " _
		 + GetIdentityType( oAppPool.ProcessModel.IdentityType )
     WScript.Echo "ProcessModel.IdleTimeout = " + CStr( oAppPool.ProcessModel.IdleTimeout )
     WScript.Echo "ProcessModel.LoadUserProfile = " + CStr( oAppPool.ProcessModel.LoadUserProfile )
     WScript.Echo "ProcessModel.ManualGroupMembership = " _
		 + CStr( oAppPool.ProcessModel.ManualGroupMembership )
     WScript.Echo "ProcessModel.MaxProcesses = " + CStr( oAppPool.ProcessModel.MaxProcesses )
     WScript.Echo "ProcessModel.Password = " + oAppPool.ProcessModel.Password
     WScript.Echo "ProcessModel.PingingEnabled = " + CStr( oAppPool.ProcessModel.PingingEnabled )
     WScript.Echo "ProcessModel.PingInterval = " + CStr( oAppPool.ProcessModel.PingInterval )
     WScript.Echo "ProcessModel.PingResponseTime = " _
		 + CStr( oAppPool.ProcessModel.PingResponseTime )
     WScript.Echo "ProcessModel.ShutdownTimeLimit = " _
		 + CStr( oAppPool.ProcessModel.ShutdownTimeLimit )
     WScript.Echo "ProcessModel.StartupTimeLimit = " + CStr( oAppPool.ProcessModel.StartupTimeLimit )
     WScript.Echo "ProcessModel.UserName = " + oAppPool.ProcessModel.UserName
     WScript.Echo "QueueLength = " + CStr( oAppPool.QueueLength )
     WScript.Echo "Recycling.DisallowOverlappingRotation = " _
		 + CStr( oAppPool.Recycling.DisallowOverlappingRotation )
     WScript.Echo "Recycling.DisallowRotationOnConfigChange = " _
		 + CStr( oAppPool.Recycling.DisallowRotationOnConfigChange )
     WScript.Echo "Recycling.LogEventOnRecycle = " + CStr( oAppPool.Recycling.LogEventOnRecycle )
     WScript.Echo "Recycling.PeriodicRestart.Memory = " _
		 + CStr( oAppPool.Recycling.PeriodicRestart.Memory )
     WScript.Echo "Recycling.PeriodicRestart.PrivateMemory = " _
		 + CStr( oAppPool.Recycling.PeriodicRestart.PrivateMemory )
     WScript.Echo "Recycling.PeriodicRestart.Requests = " _
		 + CStr( oAppPool.Recycling.PeriodicRestart.Requests )
     
     For Each s In oAppPool.Recycling.PeriodicRestart.Schedule
          WScript.Echo "Recycling.PeriodicRestart.Schedule = " + s.Value
     Next
     
     WScript.Echo "Recycling.PeriodicRestart.Time = " _
		 + CStr( oAppPool.Recycling.PeriodicRestart.Time )
      
     
     Set oApps = oAppPool.Associators_(, "Application")
     
     For Each oApp In oApps 
     
          WScript.Echo "[" + oApp.Path + "]"
          WScript.Echo "  ApplicationPool = " + oApp.ApplicationPool
          WScript.Echo "  EnabledProtocols = " + oApp.EnabledProtocols
          WScript.Echo "  Path = " + oApp.Path
          WScript.Echo "  SiteName = " + oApp.SiteName
          WScript.Echo "  VirtualDirectoryDefaults.AllowSubDirConfig = " _
		 + CStr( oApp.VirtualDirectoryDefaults.AllowSubDirConfig )
          WScript.Echo "  VirtualDirectoryDefaults.LogonMethod = " _
		 + CStr( oApp.VirtualDirectoryDefaults.LogonMethod )
          WScript.Echo "  VirtualDirectoryDefaults.Password = " _
		 + oApp.VirtualDirectoryDefaults.Password
          WScript.Echo "  VirtualDirectoryDefaults.Path = " + oApp.VirtualDirectoryDefaults.Path
          WScript.Echo "  VirtualDirectoryDefaults.PhysicalPath = " _
		 + oApp.VirtualDirectoryDefaults.PhysicalPath
          WScript.Echo "  VirtualDirectoryDefaults.UserName = " _
		 + oApp.VirtualDirectoryDefaults.UserName
          
     Next
     
      
Next 


Function GetIdentityType ( n )

     GetIdentityType = "Unknown " + CStr(n)

     Select Case n
     Case 0 GetIdentityType = "Local System"
     Case 1 GetIdentityType = "Local Service"
     Case 2 GetIdentityType = "Network Service"
     Case 3 GetIdentityType = "Specific User"
     End Select

End Function

Function GetLoadBalancerCapabilities( n )

     GetLoadBalancerCapabilities = CStr(n) + " (Unknown)"

     Select Case n
     Case 1 GetLoadBalancerCapabilities = "1 (TcpLevel)"
     Case 2 GetLoadBalancerCapabilities = "2 (HttpLevel)"
     End Select

End Function

コードが長くなってしまいましたが、要はいろんな情報をダンプしているだけですから、 適当に書き換えて使ってくださいね。

またこれも VBScript のコードですから、*.vbs ファイルとして保存して、コマンドプロンプトから cscript で実行してください。

ちなみに、この情報は実行時の情報ではなく、構成情報ですからアプリケーションプールのプロセスが起動していなくても、 情報が採取可能です。

スポンサーリンク
ホーム > IIS 徹底解説! > アプリケーションプールの情報を表示する方法 (IIS WMI)