Skip to content

Instantly share code, notes, and snippets.

@cobusc
Created April 16, 2013 13:29
Show Gist options
  • Save cobusc/5395884 to your computer and use it in GitHub Desktop.
Save cobusc/5395884 to your computer and use it in GitHub Desktop.
Quick check if Erlang VMs have swap memory
#!/bin/bash
# Check swap usage of Erlang VMs
for p in $(ps -e | grep beam | cut -d" " -f 1); do
SWAP=$(grep "Swap:" /proc/${p}/smaps | awk '{swap = swap + $2} END {print swap}')
CMDPREFIX=$(head -c 100 /proc/${p}/cmdline)
printf "PID ${p} SWAP %dKB CMDPREFIX '%s...'\n" ${SWAP} ${CMDPREFIX}
done
# Example output
#
# PID 20419 SWAP 28340KB CMDPREFIX '/some/app...'
# PID 21898 SWAP 102012KB CMDPREFIX '/some/other/app...'
# PID 22606 SWAP 14744KB CMDPREFIX '/yet/another...'
# PID 32665 SWAP 0KB CMDPREFIX '/last/example/app...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment