Skip to main content

The pyjstack command-line tool for taking the thread dump

Project description

docs travis pypi coverage

The pyjstack command-line tool lets you to collect the thread dump of Java processes currently running on your system. A thread dump is a snapshot of the state of all threads that are part of the process. The state of each thread is presented with a so called stack trace, which shows the contents of a thread’s stack. Some of the threads belong to the Java application you are running, while others are JVM internal threads. A thread dump reveals information about an application’s thread activity that can help you diagnose problems and better optimize application and JVM performance; for example, thread dumps automatically shows the occurrence of a deadlock. Deadlocks bring some or all of an application to a complete halt. The pyjstack uses the jstack utility to print Java stack traces.

Most often a single thread dump will reveal the problem, this is especially true with deadlocks where two or more threads are waiting for locks obtained by each other. But in other cases, such as threads waiting on other processes, like IO from a database, you won’t be able to detect it with a single thread dump. In this case multiple thread dumps taken over time will show the same thread waiting for the process to complete during that time span. The pyjstack can generate multiple thread dumps over time. Running pyjstack from the command line, the default is 12 thread dumps with a 1 second delay between each dump, this is configurable from the command line. If you are running pyjstack without the pid and there are multiple Java processes running on the machine pyjstack will detect it and get the list of pids, you have to choose the pid to generate the thread dump.

Installation

The pyjstack can be installed via pip, the Python package manager. If pip isn’t already available on your system of Python, run the following commands to install it:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --user

Then install pyjstack

sudo pip install pyjstack

Install from GitHub via pip:

pip install git+https://github.com/sarathkumarsivan/pyjstack.git

You can also install the latest version directly from a cloned Git repository:

git clone https://github.com/sarathkumarsivan/pyjstack.git
cd pyjstack
python setup.py install

If you face any issue while installation related to six package, you can ignore it like this:

pip install pyjstack --ignore-installed six

Upgrade

You can upgrade pyjstack via pip; issue the below command to perform the upgrade:

sudo pip install pyjstack --upgrade

Usage

To obtain a thread dump using pyjstack, run the following command:

pyjstack --pid 12397 --count 12 --delay 1

Options

–pid:

The PID of your Java process. If you are running pyjstack without the pid and there are multiple Java processes running on the machine pyjstack will detect it and get the list of pids, you have to choose the pid to generate the thread dump.

–count:

The count indicates how many thread dumps to take.

–delay:

The delay indicates the time delay in seconds between each dump.

–verbose:

Enable debug level logging. You can enable verbose logging which exactly similar to the DEBUG level. If you see any unexpected behavior while issuing pyjstack, enablling this option would be a good choice to identify the problem and trace the root cause.

–quiet:

Make little or no noise while collecting the thread dump. During the normal execution of pyjstack command, INFO level logs would be printed on the console; but if you provide –quiet option, the command would be executed silently.

Supports

Tested on Python 2.7, 3.2, 3.4, 3.6, 3.7

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjstack-0.0.7.tar.gz (10.6 kB view details)

Uploaded Source

File details

Details for the file pyjstack-0.0.7.tar.gz.

File metadata

  • Download URL: pyjstack-0.0.7.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.10

File hashes

Hashes for pyjstack-0.0.7.tar.gz
Algorithm Hash digest
SHA256 525b4b36a79bdf969c496fa83b9b8de7c2e4646c3d32d4c9b5c0e257811a0b9c
MD5 92fc723b6fd252dabe4072961a4e30b7
BLAKE2b-256 b13cbaec85b3e5b2eeeb4b0774b5640561935d3172cfb1e5f761e0675126f1ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page