How to find which applications are running in a Diego Cell
search cancel

How to find which applications are running in a Diego Cell

book

Article ID: 297717

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

This article describes how you can determine which applications are running on a specific Diego cell. You might want to do this prior to restarting or recreating a cell or perhaps as a part of a troubleshooting procedure.


Environment


Resolution

The following instructions are recommended with PCF v2.x:
 

1. Get the intended diego_cell id from the output of bosh vms.


For example, the cell_id for the diego_cell named as: diego_cell/0ee6797d-934c-####-####-e183b8e22e78 will be "0ee6797d-934c-####-####-e183b8e22e78". 

In case it's a windows diego_cell, it will be something like windows_diego_cell/d40b89f4-99cd-####-####-38811902027c and the cell id will be "d40b89f4-99cd-####-####-38811902027c"

2. bosh ssh into any linux diego_cell or diego_brain and run the below cfdot command:

cfdot cell-state <cell-id> | jq -r '. | "\ndiego_cell:", .cell_id, "\n", "App-Guids:", .LRPs[].process_guid[0:36]'

Notes: - Replace the above cell_id with the actual cell_id
             - cfdot works from any linux diego_cell or diego_brain VM but not from windows diego_cell, that is why you need to ssh into a linux diego_cell. Despite this fact, cfdot lists the apps running in every linux or windows diego_cell.


For example: 

cfdot cell-state  0ee6797d-934c-####-####-e183b8e22e78 | jq -r '. | "\ndiego_cell:", .cell_id, "\n", "App-Guids:", .LRPs[].process_guid[0:36]'

Please Note: The above process retrieves the app GUIDs by parsing the first 36 characters of the process GUID. While this is typically accurate, there are some scenarios where an app GUID may not be present in this output. Please see this knowledge base article for more details.

3. The output from step 2 will give the application guid's running in the diego_cell, and the corresponding application names can be pulled from the cf CLI (Cloud Foundry Command Line Interface) as below:

cf curl /v2/apps/$i/stats | grep name | uniq

Running cf CLI command for multiple guid's can also be automated as shown below:

  • Copy all the app guid to a file and you can run something like the below for loop against the file (replace the filename in the below loop)
for i in $(cat filename); do 
    echo $(cf curl /v2/apps/$i/stats | grep name | uniq)
done



Additional Information

The following instructions can be used for older versions of PCF or if the method above is not working.


Run the following command, where the cell-ip is the IP address of your Diego cell. 
curl -s -k --cert /var/vcap/jobs/auctioneer/config/certs/rep/client.crt --key /var/vcap/jobs/auctioneer/config/certs/rep/client.key https://<cell-ip>:1801/state | python -m json.tool | grep process_guid | cut -d ':' -f2 | cut -c 3-38 | xargs -I '<guid>' cf curl '/v2/apps/<guid>' | grep '"name"' | cut -d ':' -f2 | sort -u

For example:

ubuntu@pivotal-ops-manager:~$ curl -s -k --cert /var/vcap/jobs/auctioneer/config/certs/rep/client.crt --key /var/vcap/jobs/auctioneer/config/certs/rep/client.key https://192.168.####-####:1801/state | python -m json.tool | grep process_guid | cut -d ':' -f2 | cut -c 3-38 | xargs -I '<guid>' cf curl '/v2/apps/<guid>' | grep '"name"' |cut -d ':' -f2 | sort -u 
ubuntu@pivotal-ops-manager:~$