Code Repositories
Find and share code repositories
Cloudera Employee
Repo Description

You can use this script to automatically take jstacks. Copy the script and just execute something like: <./script_name.pl>. Please let me know if this helps. It works on the basis of jstack -F , for systems which are very busy you can replace it with kill -3 pid.

[root@node1 ~]# ./jstack.pl
Which component are you looking to take a jstack for:
namenode
Process name is :   namenode
Process id for namenode is: 15046
How many jstack required:
2
Sleep between each jstack
1
Process Id for Namenode: 15046
Taking a jstack now
jstack_output_1483629788
Process Id for Namenode: 15046
Taking a jstack now
jstack_output_1483629790
Repo Info
Github Repo URL https://github.com/sarunsingla/admin_utilities/blob/master/auto-jstack.pl
Github account name sarunsingla/admin_utilities/blob/master
Repo name auto-jstack.pl
704 Views
Comments
Super Guru

@ssingla - Taking jstack with the user who is running a daemon would be more effective. Just a suggestion! :)

"Make sure to run jstack as the same user that's running Jenkins itself instead of using the root user" - https://wiki.jenkins-ci.org/display/JENKINS/Obtaining+a+thread+dump

One more reference - http://stackoverflow.com/questions/7420501/jstack-target-process-not-responding