Solved

How to monitor a production java process running on linux

Posted on 2013-12-26
10
1,859 Views
Last Modified: 2014-01-27
I need to monitor a java process. At present I monitor the cpu and memory used by it using top command.
And then for that process_id I log the output of
1. lsof -p ${process_pid}
2. pstack -p ${process_pid}
3. top -n 1 -b -p ${process_pid} -H

But these are not giving me any useful results together. How do i collate useful details from them?

I am aware of some useful tools inside jdk folder, but i cant use them as they are not part of the production server.
Is there any detail provided by jvm and linux OS other than what I have listed above?
0
Comment
Question by:pvinodp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 39741313
What do you need to monitor , apart from cpu and memory?
0
 

Author Comment

by:pvinodp
ID: 39741324
which jar is taking how much memory. what is the memory occupied by a class.
Same details for cpu as well.
0
 
LVL 11

Assisted Solution

by:Radek Baranowski
Radek Baranowski earned 250 total points
ID: 39741405
commandline/linux tools won't give you that. the only way is to analyze thread dump or use jmx console wchich is a part of JDK (not JRE)
(binary util jconsole in <jdkhome>/bin)
I'm not sure though if there's any way to use it in batch mode, I doubt it, so there's only way to monitor it visually)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pvinodp
ID: 39741456
i am well aware of tools within jdk.
I need to know if there is any help available from jre or linux OS
0
 
LVL 11

Assisted Solution

by:Radek Baranowski
Radek Baranowski earned 250 total points
ID: 39741538
hmmm..

I googled a bit and found something like that:

https://coderwall.com/p/il3h4g

yet this yields stats you want (I guess) but only AFTERWARDS I mean, the execution needs to end to generate java.hprof.txt file..

more options described here:
http://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html

enjoy
0
 

Author Comment

by:pvinodp
ID: 39741842
https://coderwall.com/p/il3h4g:: This link suggest that I start the java process with the arguments. But i need to sniff the production java process which has already started and giving trouble. Moreover jhat is part of jre and not jdk.

Even the second link requires similar process.


let me know if I have wrongly understood.
0
 
LVL 11

Expert Comment

by:Radek Baranowski
ID: 39741858
yes, possibly.

well what you are trying to do can only be achieved by either jconsole or dumping heap/thread dumps with kill -3 <pid> and analyzing it with available tools (Java Heap/Thread dump analyzer from IBM or write parser of your own)
0
 
LVL 8

Assisted Solution

by:AdminRAM
AdminRAM earned 125 total points
ID: 39744896
Performance Monitoring Infrastructure (PMI)

Use this page to learn about Performance Monitoring Infrastructure and other tools to help monitor the overall health of the application server.

A typical Web system consists of a Web server, application server, and a database. Monitoring and tuning the application server is critical to the overall performance of the Web system. Performance Monitoring Infrastructure (PMI) is the core monitoring infrastructure for WebSphere Application Server and WebSphere family products like Portal, Commerce, and so on. The performance data provided by WebSphere PMI helps to monitor and tune the application server performance.

When tuning the WebSphere Application Server for optimal performance, or fixing a poorly performing Java 2 Platform, Enterprise Edition (J2EE) application, it is important to understand how the various run time and application resources are behaving from a performance perspective. PMI provides a comprehensive set of data that explains the runtime and application resource behavior. For example, PMI provides database connection pool size, servlet response time, Enterprise JavaBeans (EJB) method response time, Java virtual machine (JVM) garbage collection time, CPU usage, and so on. This data can be used to understand the runtime resource utilization patterns of the thread pool, connection pool, and so on, and the performance characteristics of the application components like servlets, JavaServer Pages (JSP), and enterprise beans.

Using PMI data, the performance bottlenecks in the application server can be identified and fixed. For instance, one of the PMI statistics in the Java DataBase Connectivity (JDBC) connection pool is the number of statements discarded from prepared statement cache. This statistic can be used to adjust the prepared statement cache size in order to minimize the discards and to improve the database query performance. PMI data can be monitored and analyzed by Tivoli Performance Viewer (TPV), other Tivoli tools, your own applications, or third party tools. TPV is a graphical viewer for PMI data that ships with WebSphere Application Server. Performance advisors use PMI data to analyze the run-time state of the application server, and provide tuning advice to optimize the application server resource utilization.

PMI data can also be used to monitor the health of the application server. Some of the health indicators are CPU usage, Servlet response time, and JDBC query time. Performance management tools like Tivoli Monitoring for Web Infrastructure and other third party tools can monitor the PMI data and generate alerts based on some predefined thresholds.



Monitoring system performance using WebSphere PMI
http://pic.dhe.ibm.com/infocenter/wtelecom/v7r1m0/topic/com.ibm.twss.doc/com_perfmonitoring_c.html
0
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 125 total points
ID: 39747742
If a java process is already started with non-instrumentation options, there is very little we can do. However, in practice, i found the following handy and often helps me figure out most the the issues:


1. Take thread-dump: java -QUIT <pid> prints the thread-dump on the console. Useful in working with locks, dead-locks and application flows.
2. Heap dump, use jmap to dump the heap. It gives insights of the objects, leaks
3. jstat - prints stat information of running jvm.
0
 

Author Closing Comment

by:pvinodp
ID: 39811877
thats a lot useful information. thanks all
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to setup virtualization in Redhat? 4 44
IMAP copying tool 14 76
grep command usage 10 30
RHEL 6.0 - Does it support SHA2? 7 41
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question