Rapid printing of JSTACK and JSTAT

Source: Internet
Author: User
Tags jboss server

Rapid printing of JSTACK and JSTAT

At work, sometimes the JBoss server is on the machine and you need to use the command line to obtain the JSTACK and JSTAT logs for analysis of the cause. However, to obtain the preceding logs, You need to first query the process number, which is basically not allowed due to time issues in production.

Therefore, a batch processing command is written to complete this action.

Restrictions:

Only one java.exe process is running

You must add the java_home \ bin directory to the path environment variable.

 

@echo off&setlocal enabledelayedexpansionREM ======================set /a cnt=10REM ======================set /a j=0,k=16*1024*1024,p=0set dt=%date:~,4%%date:~5,2%%date:~8,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%for /f "skip=1 tokens=1-2 delims= " %%a in ('wmic process where "name='java.exe'" get WorkingSetSize^,Handle') do ( if %%b LSS !k! (    REM echo "%%b less than %k%" ) else (    set /a p=%%a   set /a j=j+1 ))if %p% EQU 0 ( echo Cannot find Java Process memory use greater than 16M.) else if NOT %j% EQU 1 ( echo Find too more Java Process, cannot determine which one.) else ( echo Saving JBoss thread status to c:... jstack -l %p% > "C:\JSTACK_%dt%.log" echo Saving JBoss memory status to c:... jstat -gc -t %p% 2000 %cnt% > "C:\JSTAT_%dt%.log")echo Finished!pause


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.