Skip to content

Instantly share code, notes, and snippets.

@mdelillo
Created July 11, 2018 13:39
Show Gist options
  • Save mdelillo/4cfc5ba66ae8c3fdda23abb630f8dd97 to your computer and use it in GitHub Desktop.
Save mdelillo/4cfc5ba66ae8c3fdda23abb630f8dd97 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
credhub_pid=$(cat /var/vcap/sys/run/credhub/pid)
uaa_pid=$(cat /var/vcap/data/sys/run/uaa/uaa.pid)
lsof_output="$(lsof)"
total_open_files=$(echo "$lsof_output" | wc -l)
credhub_open_files=$(echo "$lsof_output" | grep "java *$credhub_pid" | wc -l)
uaa_open_files=$(echo "$lsof_output" | grep "java *$uaa_pid" | wc -l)
credhub_connections=$(echo "$lsof_output" | grep "java *$credhub_pid" | grep ESTABLISHED | wc -l)
uaa_connections=$(echo "$lsof_output" | grep "java *$uaa_pid" | grep ESTABLISHED | wc -l)
credhub_web_connections=$(echo "$lsof_output" | grep "java *$credhub_pid" | grep ESTABLISHED | grep ":8844->" | grep ".bc.googleusercontent.com" | wc -l)
credhub_postgres_connections=$(echo "$lsof_output" | grep "java *$credhub_pid" | grep ESTABLISHED | grep ":postgresql" | wc -l)
uaa_postgres_connections=$(echo "$lsof_output" | grep "java *$uaa_pid" | grep ESTABLISHED | grep ":postgresql" | wc -l)
echo "Total open files: $total_open_files
Credhub open files: $credhub_open_files
Credhub connections: $credhub_connections
***Credhub <-> Web: $credhub_web_connections***
Credhub <-> Postgres: $credhub_postgres_connections
UAA open files: $uaa_open_files
UAA connections: $uaa_connections
UAA <-> Postgres: $uaa_postgres_connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment