Last active
October 12, 2020 18:47
-
-
Save ableasdale/069ccfeca2636a029664bc8abd9ca265 to your computer and use it in GitHub Desktop.
MarkLogic: Simple pstack script
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 | |
# root check | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
# default argument check | |
if [[ -z $1 ]]; then | |
echo Usage: ./pstack.sh \[running time in seconds\] | |
echo e.g. ./pstack.sh 60 \(runs the application for 1 minute before closing\) | |
exit 1 | |
fi | |
# global vars | |
TSTAMP=`date +"%H%M%S-%m-%d-%Y"` | |
INTERVAL=3 TIME=$1 | |
# main | |
echo Support script started at: $TSTAMP - running for $TIME seconds with a sample every $INTERVAL seconds | |
mkdir /tmp/$TSTAMP | |
while [ $TIME -gt 0 ]; do | |
date >> /tmp/$TSTAMP/pstack.log | |
service MarkLogic pstack >> /tmp/$TSTAMP/pstack.log | |
sleep $INTERVAL | |
echo -e ". \c" | |
let TIME-=$(($INTERVAL)) | |
done | |
echo completed | |
# create zip | |
zip -9 -r /tmp/$TSTAMP.zip /tmp/$TSTAMP | |
echo /tmp/$TSTAMP.zip created |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment