Skip to content

Instantly share code, notes, and snippets.

@yjhjstz
Created May 10, 2019 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjhjstz/0f5dfd8ae74883a210a0378c6d5fc58f to your computer and use it in GitHub Desktop.
Save yjhjstz/0f5dfd8ae74883a210a0378c6d5fc58f to your computer and use it in GitHub Desktop.
Gdblive script
#!/bin/sh
# Usage: gdblive [ arguments to grep output of ps ]
cd $HOME
# tee /dev/tty is for user to see the set of procs considered
if [ $# -eq 0 ]
then
PROCS=`ps auxww | \
grep postgres: | \
grep -v -e 'grep postgres:' -e 'postgres: stats' -e 'postgres: writer' -e 'postgres: wal writer' -e 'postgres: checkpointer' -e 'postgres: archiver' -e 'postgres: logger' -e 'postgres: autovacuum' | \
tee /dev/tty | \
awk '{print $2}'`
else
PROCS=`ps auxww | \
grep postgres: | \
grep -v -e 'grep postgres:' -e 'postgres: stats' -e 'postgres: writer' -e 'postgres: wal writer' -e 'postgres: checkpointer' -e 'postgres: archiver' -e 'postgres: logger' -e 'postgres: autovacuum' | \
grep $@ | \
tee /dev/tty | \
awk '{print $2}'`
fi
if [ `echo "$PROCS" | wc -w` -eq 1 ]
then
exec gdb $PGINSTROOT/bin/postgres -silent "$PROCS"
else
exec gdb $PGINSTROOT/bin/postgres -silent
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment