Find all the app instances running on the Windows Diego cell your interested in. You'll need to SSH into a regular Linux
Diego cell to be able to run the cfdot
command. Change the below to match the IP address of the Windows Diego cell
you're inspecting.
cfdot actual-lrps | grep "192.168.2.20" | jq
This will output a bunch of JSON with all the apps running on the cell. For example:
{
"process_guid": "fa2319e2-4ba5-42f9-8f8b-fdb6f1e9ef56-6b3749c2-60b2-4622-9441-036a158d8790",
"index": 1,
"domain": "cf-apps",
"instance_guid": "7897f639-8cd1-4c77-7096-da92",
"cell_id": "21d64718-4c1c-43e4-8ce7-fc4e74a2a309",
"address": "192.168.2.20",
"ports": [
{
"container_port": 8080,
"host_port": 40002
},
{
"container_port": 2222,
"host_port": 40003
}
],
"instance_address": "172.30.0.153",
"preferred_address": "HOST",
"crash_count": 0,
"state": "RUNNING",
"since": 1654894721255970600,
"modification_tag": {
"epoch": "7e1eb82d-473c-47e3-5abf-9553502a63a5",
"index": 2
},
"presence": "ORDINARY"
}
The first half of the process_guid
is the app ID which you can further narrow down to a named app using
cf curl
- which isn't documented here. The instance_guid
is the app instance ID, which also happens to be
the container ID on the Windows cell. Save this for later.
Next we need to create a map of HWC processes PIDs to CF App Instances IDs. All Windows diego cell containers are stored in c:\ProgramData\winc<appinstance-guid>. We just iterate over these reading the state.json and match that PID to the same container as the HWC process. Fortunately there's a script for this.
SSH into the Windows cell and start a PowerShell session. Execute the following script by copying and pasting it.
Get-ChildItem -Path /ProgramData/winc | Where-Object { $_.Name -CNotLike "*liveness*" } | Foreach-Object {
$stateJsonPath = Join-Path $_.FullName -ChildPath "state.json"
$appInstanceID = $_.Name
$p = (Get-Content $stateJsonPath | ConvertFrom-Json | Select-Object -expand pid)
$hwcPID = Get-Process | Where-Object {$_.si -eq $(Get-Process -id $p | Select-Object -expand si) -and $_.name -eq 'hwc'} | Select-Object -expand Id
Write-Output "$appInstanceID = $hwcPID"
}
This will dump out a mapping of all app instance IDs to HWC process IDs. Work this backwards from the cfdot output and you can now track down which hwc process is associated with which application.