Last active
May 15, 2019 16:22
-
-
Save jctanner/48bbfc30b15a181fd1dbb51ae926ac3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -x | |
| if [[ $EUID -ne 0 ]]; then | |
| echo "This script must be run as root" | |
| exit 1 | |
| fi | |
| RESDIR=/tmp/ansible_data | |
| THISHOST=$(hostname -f) | |
| TODAY=$(date --iso-8601) | |
| PYTHON=$(which python) | |
| PIP=$(which pip) | |
| if [[ -f /var/lib/awx/venv/ansible/bin/python ]]; then | |
| PYTHON=/var/lib/awx/venv/ansible/bin/python | |
| PIP=/var/lib/awx/venv/ansible/bin/pip | |
| fi | |
| if [[ ! -d $RESDIR ]]; then | |
| mkdir -p $RESDIR | |
| fi | |
| if [[ ! -d $RESDIR/$THISHOST ]]; then | |
| mkdir -p $RESDIR/$THISHOST | |
| fi | |
| rpm -q gdb 1>/dev/null || echo "please yum install gdb" | |
| rpm -q gdb 1>/dev/null || exit 1 | |
| rpm -q sysstat 1>/dev/null || echo "please yum install sysstat" | |
| rpm -q sysstat 1>/dev/null || exit 1 | |
| # check for the click lib | |
| $PYTHON -c 'import click' || echo "Please install the click python lib: $PIP install click" | |
| $PYTHON -c 'import click' || exit 1 | |
| if [[ ! -f $RESDIR/pystack.py ]]; then | |
| curl -o $RESDIR/pystack.py \ | |
| https://raw.githubusercontent.com/wooparadog/pystack/master/pystack.py | |
| fi | |
| chmod +x $RESDIR/pystack.py | |
| rpm -qa > $RESDIR/$THISHOST/rpmqa-${TODAY}.txt | |
| cat /proc/cpuinfo > $RESDIR/$THISHOST/cpuinfo-${TODAY}.txt | |
| cat /proc/meminfo > $RESDIR/$THISHOST/meminfo-${TODAY}.txt | |
| fdisk -l > $RESDIR/$THISHOST/fdisk-${TODAY}.txt | |
| ifconfig -a > $RESDIR/$THISHOST/ifconfig-${TODAY}.txt | |
| uname -a > $RESDIR/$THISHOST/uname-${TODAY}.txt | |
| who > $RESDIR/$THISHOST/who-${TODAY}.txt | |
| ansible --version > $RESDIR/$THISHOST/ansible_version-${TODAY}.txt | |
| COUNT=1 | |
| while true; do | |
| echo "ITERATING ${COUNT}" | |
| let "COUNT++" | |
| THISTIME=$(date +"%Y-%m-%d-%H-%M-%S") | |
| ps ef > $RESDIR/$THISHOST/psef-$THISTIME.txt | |
| ps aeux > $RESDIR/$THISHOST/psaeux-$THISTIME.txt | |
| top -H -bn1 > $RESDIR/$THISHOST/top-$THISTIME.txt | |
| vmstat 1 1 > $RESDIR/$THISHOST/vmstat-$THISTIME.txt | |
| sar -A > $RESDIR/$THISHOST/sar-$THISTIME.txt | |
| PIDS=$(ps aux | fgrep playbook | fgrep -v grep | awk '{print $2}') | |
| for XPID in $PIDS; do | |
| echo $XPID | |
| $PYTHON $RESDIR/pystack.py $XPID > $RESDIR/$THISHOST/pid-stack-$XPID-$THISTIME.txt | |
| done | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment