First, using following DOS command to start AppFabric Cache PowerShell environment in one of the cache host server:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "Set-ExecutionPolicy RemoteSigned;Import-Module DistributedCacheAdministration;Import-Module DistributedCacheConfiguration;Use-CacheCluster;Cd C:\\;Cls"
Second, assume the script MonitorAppFabricCache.ps1 is under C:\ folder, run following in PowerShell environment. It will generate the output at c:\AppFabricCacheStatus.txt and open the output:
.\MonitorAppFabricCache.ps1
Following is the content of MonitorAppFabricCache.ps1.
$AppFabricCacheStatusFile = "c:\AppFabricCacheStatus.txt"
Get-Date -format g | Out-File $AppFabricCacheStatusFile -Force
Out-File $AppFabricCacheStatusFile -InputObject "" -Append
Out-File $AppFabricCacheStatusFile -InputObject "" -Append
Out-File $AppFabricCacheStatusFile -InputObject "" -Append
Out-File $AppFabricCacheStatusFile -InputObject "Cache hosts status" -Append
Out-File $AppFabricCacheStatusFile -InputObject "=========================" -Append
Get-CacheHost | Out-File $AppFabricCacheStatusFile -Append
Get-CacheClusterHealth | Out-File $AppFabricCacheStatusFile -Append
$CacheHosts = Get-CacheHost
foreach ($CacheHost in $CacheHosts)
{
Out-File $AppFabricCacheStatusFile -InputObject "Cache host config - $($CacheHost.HostName)" -Append
Out-File $AppFabricCacheStatusFile -InputObject "=========================" -Append
Get-CacheHostConfig -HostName $CacheHost.HostName -CachePort $CacheHost.PortNo | Out-File $AppFabricCacheStatusFile -Append
}
$Caches = Get-Cache
foreach ($Cache in $Caches)
{
Out-File $AppFabricCacheStatusFile -InputObject "Cache statistics - $($Cache.CacheName)" -Append
Out-File $AppFabricCacheStatusFile -InputObject "=========================" -Append
Get-CacheStatistics -CacheName $Cache.CacheName | Out-File $AppFabricCacheStatusFile -Append
}
foreach ($Cache in $Caches)
{
Out-File $AppFabricCacheStatusFile -InputObject "Cache config - $($Cache.CacheName)" -Append
Out-File $AppFabricCacheStatusFile -InputObject "=========================" -Append
Get-CacheConfig -CacheName $Cache.CacheName | Out-File $AppFabricCacheStatusFile -Append
}
Out-File $AppFabricCacheStatusFile -InputObject "Regions by cache" -Append
Out-File $AppFabricCacheStatusFile -InputObject "=========================" -Append
Get-Cache | Out-File $AppFabricCacheStatusFile -Append
Out-File $AppFabricCacheStatusFile -InputObject "Regions by cache host" -Append
Out-File $AppFabricCacheStatusFile -InputObject "=========================" -Append
Get-CacheRegion | Out-File $AppFabricCacheStatusFile -Append
Invoke-Expression -Command $AppFabricCacheStatusFile
No comments:
Post a Comment