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