IIS与ApplicationPool重启检测自动化解决方案

  • 时间:
  • 浏览:8
  • 来源:大发UU快3APP—大发快三代理

$global:i=$global:i+1

#最新W3Wp守护进程运行运行开启的时间

for($j=0;$j -lt $global:W3WPSProcesses.length;$j++){

process{

$global:process=$_

$global:HotfixTime=$global:HotfixLog.TimeWritten

}

$global:nameofthepool=(global:get-apppools|Where-Object {$_.pid -eq  $global:process.id}).apppoolid

        $cmd = $pattern.Match($_.commandline).Groups[1].Value

begin{

$global:Old=0

#判断IIS与否在打Hotfix以前 重启过

$global:shortNameOfThePool=$global:nameofthepool.substring(0,$global:IndexOfEnd)

$global:W3WPStartTime=$global:W3WPSProcesses.StartTime

}

#最近一一三个Hotfix时候时候刚结速的时间

Write-Host "-----------------------"

$global:IndexOfEnd=$global:nameofthepool.indexof('"')

if($_.TimeWritten -gt $global:HotfixTime){

if($global:NewOrOldProcess -ne 0){

$global:W3WPStartTime=0

if($_){

$global:IISLogs|IISCK

$global:process=$_

}

$global:NewOrOldProcess=$global:NewOrOldProcess+1

$global:W3WPStartTime=$global:W3WPSProcesses[$j].StartTime

#0位为最新的Hotfix时间

$global:IISLogs=Get-EventLog system| where-object {$_.source -like "*IIS*"}

下载地址:

}

Write-Host "All the application pool(s) has been reset or new created after the 'Hotfix' updated."

}

}

}else{

if($global:i -eq 0){

if($global:HotfixLog -is [array]){

$global:p=$global:p+1

Hotfix Automatic Check,简称Hot Check,"火柴"。

}else{

}

if($global:HotfixTime){

#将IISLogs装进过滤器进行判断

$global:New=0

另:感谢DL的Dora Liu强力打包的三个针对性测试patch和Zhenpeng Liu的各种支持。

Write-Host "The application pool [ $global:shortNameOfThePool ] has reset or the w3wp process of it is new created after the 'Hotfix' updated."

filter IISCK{

Write-Host "Since there're no 'Hotfix' updated, we don't need to care about whether the IIS has been reset yet."

$global:HotfixTime=$global:HotfixLog[0].TimeWritten

Write-Host "-----------------------"

        New-Object psobject | Add-Member -MemberType noteproperty -PassThru Name $name |

Write-Host "IIS hasn't been reset after the 'Hotfix' updated."

Write-Host "Through the analysis from 'HotCheck':"

1.右键tool,run as admin;需用联系我​:Tianyou.Lan

        $name=$_.name

$global:nameofthepool=(global:get-apppools|Where-Object {$_.pid -eq  $global:process.id}).apppoolid

Write-Host "Through the analysis from 'HotCheck':"

            Add-Member -MemberType noteproperty -PassThru AppPoolID $cmd |

end{

}

}

$global:Old=$global:Old+1

$global:IndexOfEnd=$global:nameofthepool.indexof('"')

#只一一三个w3wp守护进程运行运行时,获取到w3wp守护进程运行运行的starttime。

}else{

$global:NewOrOldProcess=0

Write-Host "Through the analysis from 'HotCheck':"

if($_.starttime -gt $global:HotfixTime){

}

}

Write-Host "The application pool [ $global:shortNameOfThePool ] has not reset after the 'Hotfix' updated."

$global:Old=$global:Old+1

if($global:W3WPSProcesses[$j].StartTime -gt $global:W3WPStartTime){

#时候 有全都的w3wp守护进程运行运行,取最新的那个。

}

            Add-Member -MemberType noteproperty -PassThru PID $procid

}

    gwmi win32_process -filter 'name="w3wp.exe"' | % {

if($global:i -ne 0){

}

        $procid = $_.ProcessId

}else{

}

$global:i=0

经历了:

Get-Process -Name w3wp -ErrorAction SilentlyContinue|CheckPool

#i和p一定会IISReset标记,0代表越来越重启过,时候 代表重启过。i代表越来越Hotfix,p代表有Hotfix。

Write-Host "IIS has been reset after the 'Hotfix' updated."

}

经历了一段时间的研究与学习,我终于完成了这种为检查打Hotfix以前 agent端Application/IIS与否重启过的自动化补救方案,时候 通过了几轮针对性的测试。时候 大伙在使用过程中遇到了大问题请联系我lync:tianyou lan

}

Write-Host "Not all the application pool(s) has been reset or new created after the 'Hotfix' updated."

function global:get-apppools{

$global:HotfixLog=Get-EventLog avepoint|Where-Object {$_.Category -like "*Update Manager*"}

if($global:New -eq $global:Old){

$global:W3WPSProcesses=Get-Process -Name w3wp -ErrorAction SilentlyContinue

    [regex]$pattern="-ap ""(.+)"""

function CheckPool{

}

#filter,判断每根小日志,总的结果输出为i或p。

}

$global:shortNameOfThePool=$global:nameofthepool.substring(0,$global:IndexOfEnd)

$global:p=0

if($global:p -eq 0){

if($_){

}

#$global:IISLogs=Get-EventLog system -After ((get-date).addhours(-5))| where-object {$_.source -like "*IIS*"}

if($global:New -lt $global:Old){

}

if($global:W3WPSProcesses -is [array]){

2.自动检测完成。

    }

$global:New=$global:New+1

Read-Host "Press any key to quit"

#获取w3wp守护进程运行运行所对应的Application pool(这种函数是在网上搜的)

}

#判断结果

if($global:p -ne 0){

Write-Host "No application pool has been reset or new created after the 'Hotfix' updated."

}else{

感谢Lardy 哥给予的支持;

感谢过程中得到的萌萌姐,Di Sun,Xue Pan在测试上的帮助;