Pivotal Knowledge Base

Follow

How to find what apps are running in a Diego cell

Environment

Product Version
Pivotal Cloud Foundry® (PCF)  1.7.x

Purpose

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

Procedure

You can get either the apps name or the apps url in the following manner. I have two examples here and in both cases, I assume that the IP address of the Diego cell is 192.168.27.85. You can replace the IP address 192.168.27.85 with the suitable one on your side.

1. Here is the way to get the apps' name running in a specific cell.

You can use one command to achieve this. Please replace the ip_address_of_diego_cell with the real one on your side.

curl http://ip_address_of_diego_cell:1800/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

Here is an example on my side.

ubuntu@pivotal-ops-manager:~$ curl http://192.168.27.85:1800/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
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4780    0  4780    0     0   687k      0 --:--:-- --:--:-- --:--:--  777k
 "apps-manager-js",
 "apps-manager-js-venerable",
 "app-usage-scheduler",
 "app-usage-scheduler-venerable",
 "app-usage-server",
 "app-usage-server-venerable",
 "console",
 "console-venerable",
 "notifications-ui",
 "test-app",
ubuntu@pivotal-ops-manager:~$ 

2. Here is the other way to get the apps' URL running in a specific cell:

1) Get the password of Status Credentials in Elastic Runtime > Credentials > Router >Status Credentials
Here is mine for your reference:

{"credential":{"type":"simple_credentials","value":{"identity":"router_status","password":"xxxxxxxxxxxxxx"}}}

2) Get the IP address of gorouter:
Here is my example, it is 192.168.27.77 running in a specific cell. 

ubuntu@pivotal-ops-manager:~$ bosh vms|grep router
Acting as user 'director' on 'p-bosh-05f96aa4a0bc7e91b12f'
RSA 1024 bit CA certificates are loaded due to old openssl compatibility
| router-partition-1506967bb2eea78b2b46/0 (c66d0314-86c9-43da-a606-100d49bd80ee)                        | running | n/a | router-partition-1506967bb2eea78b2b46                        | 192.168.27.77 |
ubuntu@pivotal-ops-manager:~$ 

3) Open the following page of all app routes:

http://router_status:<password>@<router IP>:8080/routes

Here is my example, the password is get in step 1 while router IP is 192.168.27.77

{"*.login.system.xxxx.com":[{"address":"192.168.27.83:8080","ttl":0}],"*.uaa.system.xxxx.com":[{"address":"192.168.27.83:8080","ttl":0}],"api.system.xxxx.com":[{"address":"192.168.27.80:9022","ttl":0}],"app-usage.system.xxxx.com":[{"address":"192.168.27.86:61916","ttl":0}],"apps-manager-js.system.xxxx.com":[{"address":"192.168.27.86:61804","ttl":0},{"address":"192.168.27.86:61728","ttl":0},{"address":"192.168.27.85:61662","ttl":0},{"address":"192.168.27.86:61756","ttl":0},{"address":"192.168.27.85:61670","ttl":0},{"address":"192.168.27.86:62598","ttl":0}],"apps.system.xxxx.com":[{"address":"192.168.27.86:61754","ttl":0},{"address":"192.168.27.85:61666","ttl":0},{"address":"192.168.27.86:61762","ttl":0},{"address":"192.168.27.85:61674","ttl":0},{"address":"192.168.27.86:61776","ttl":0},{"address":"192.168.27.85:61736","ttl":0}],"apps.system.xxxx.com/2":[{"address":"192.168.27.86:61804","ttl":0},{"address":"192.168.27.86:61728","ttl":0},{"address":"192.168.27.85:61662","ttl":0},{"address":"192.168.27.86:61756","ttl":0},{"address":"192.168.27.85:61670","ttl":0},{"address":"192.168.27.86:62598","ttl":0}],"autoscale.system.xxxx.com":[{"address":"192.168.27.86:62596","ttl":0}],"c9cb3082-4710-410a-798d-fc885def1b55.app.xxxx.com":[{"address":"192.168.27.85:61678","ttl":0}],"console.system.xxxx.com":[{"address":"192.168.27.86:61754","ttl":0},{"address":"192.168.27.85:61666","ttl":0},{"address":"192.168.27.86:61762","ttl":0},{"address":"192.168.27.85:61674","ttl":0},{"address":"192.168.27.86:61776","ttl":0},{"address":"192.168.27.85:61736","ttl":0}],"console.system.xxxx.com/2":[{"address":"192.168.27.86:61804","ttl":0},{"address":"192.168.27.86:61728","ttl":0},{"address":"192.168.27.85:61662","ttl":0},{"address":"192.168.27.86:61756","ttl":0},{"address":"192.168.27.85:61670","ttl":0},{"address":"192.168.27.86:62598","ttl":0}],"doppler.system.xxxx.com":[{"address":"192.168.27.89:8081","ttl":0}],"loggregator.system.xxxx.com":[{"address":"192.168.27.89:8080","ttl":0}],"login.system.xxxx.com":[{"address":"192.168.27.83:8080","ttl":0}],"notifications-ui.system.xxxx.com":[{"address":"192.168.27.85:61668","ttl":0},{"address":"192.168.27.86:62602","ttl":0},{"address":"192.168.27.85:62126","ttl":0}],"p-mysql.system.xxxx.com":[{"address":"192.168.27.119:80","ttl":0},{"address":"192.168.27.120:80","ttl":0}],"proxy-0-p-mysql.internal.system.xxxx.com":[{"address":"192.168.27.78:80","ttl":0}],"proxy-0.p-mysql.system.xxxx.com":[{"address":"192.168.27.117:80","ttl":0}],"proxy-1.p-mysql.system.xxxx.com":[{"address":"192.168.27.118:80","ttl":0}],"uaa.system.xxxx.com":[{"address":"192.168.27.83:8080","ttl":0}]}

4) Copy the result of all app routes into a file, format like below and then filter by the specific Diego cell IP address:

Here is my example, all app routes are saved into the file test and I would like to list apps in Diego cell 192.168.27.85 only. You can omit those URLs without the IP address followed.

ubuntu@pivotal-ops-manager:~$ python -mjson.tool test|grep -v '{'|grep -v '}'|grep -v ttl|egrep "\[|192.168.27.85"
    "*.login.system.xxxx.com": [
    "*.uaa.system.xxxx.com": [
    "api.system.xxxx.com": [
    "app-usage.system.xxxx.com": [
    "apps-manager-js.system.xxxx.com": [
            "address": "192.168.27.85:61662",
            "address": "192.168.27.85:61670",
    "apps.system.xxxx.com": [
            "address": "192.168.27.85:61666",
            "address": "192.168.27.85:61674",
            "address": "192.168.27.85:61736",
    "apps.system.xxxx.com/2": [
            "address": "192.168.27.85:61662",
            "address": "192.168.27.85:61670",
    "autoscale.system.xxxx.com": [
    "c9cb3082-4710-410a-798d-fc885def1b55.app.xxxx.com": [
            "address": "192.168.27.85:61678",
    "console.system.xxxx.com": [
            "address": "192.168.27.85:61666",
            "address": "192.168.27.85:61674",
            "address": "192.168.27.85:61736",
    "console.system.xxxx.com/2": [
            "address": "192.168.27.85:61662",
            "address": "192.168.27.85:61670",
    "doppler.system.xxxx.com": [
    "loggregator.system.xxxx.com": [
    "login.system.xxxx.com": [
    "notifications-ui.system.xxxx.com": [
            "address": "192.168.27.85:61668",
            "address": "192.168.27.85:62126",
    "p-mysql.system.xxxx.com": [
    "proxy-0-p-mysql.internal.system.xxxx.com": [
    "proxy-0.p-mysql.system.xxxx.com": [
    "proxy-1.p-mysql.system.xxxx.com": [
    "uaa.system.xxxx.com": [
ubuntu@pivotal-ops-manager:~$ 

 

 

Comments

  • Avatar
    Christian Stein

    Hi David, was using this curl command for troubleshooting Garden containers. Unfortunately port 1800 is blocked now with ERT 1.10. And on my customer site I cannot http into the router getting the status (only https/443 is allowed and no direct routing). Would you see any possibility how this could work with ERT 1.10?

  • Avatar
    Muni Chada

    `cd /var/vcap/jobs/rep/config/certs; curl -k -s https://localhost:1801/state --cert server.crt --key server.key | json_pp`.

    To scan all the diego cells and dump out the available resources -
    cd `/var/vcap/jobs/rep/config/certs` directory on diego cell.
    do this to get `jq` on the PATH: `source /var/vcap/jobs/cfdot/bin/setup; which jq`
    then `for u in $(curl http://127.0.0.1:8500/v1/kv/v1/locks/cell/?recurse -s | jq -r .[].Value | base64 -d | jq -r .rep_url); do echo $u; curl -s -k --cert server.crt --key server.key "${u}/state" | jq .AvailableResources; done`

Powered by Zendesk