Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Last active October 12, 2020 18:47
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 ableasdale/069ccfeca2636a029664bc8abd9ca265 to your computer and use it in GitHub Desktop.
Save ableasdale/069ccfeca2636a029664bc8abd9ca265 to your computer and use it in GitHub Desktop.
MarkLogic: Simple pstack script
#!/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