Process Debugging - Information Collection
Process Debugging - Information Collection
To identify the top ten CPU-consuming processes, use the command `ps -eo %cpu,pid,cmd | sort -nr | head -10`. This list is useful for diagnosing performance bottlenecks or understanding system load distribution .
To identify open files for a specific process ID, the `lsof -p <pid>` command is used. It lists all files that are opened by the given process .
Convert a core dump to a heap dump using the command `jmap -dump:format=b,file=jvm.<pid>.hprof /usr/local/java/jdk/bin/java ./core.<pid>`. This is used for analyzing Java heap memory to find memory leaks or inefficient memory use .
To find all JAVA processes, use the command `top -bcn 1 -p \\`pgrep java | tr "\n" "," | sed 's/,$//'\\``. This command uses `pgrep` to list PIDs of all JAVA processes, formats them, and then passes them to `top` for detailed display .
To determine the version of the operating system on a Red Hat-based system, use the command `more /etc/redhat-release`. To find the installed patch level, execute the command `rpm -qa` .
`pstack <pid>` provides a snapshot of stack traces for all threads within a process. This is valuable for diagnosing issues related to process state anomalies, performance drops, or verifying thread execution paths during troubleshooting .
Core dump files can be very large and contain detailed memory snapshots which aid in debugging. Storage considerations are crucial to avoid disk space issues, potentially hindering system operations .
A stack trace for a Java process is obtained using the command `jstack <pid>`. This information helps in diagnosing hangs, deadlocks, or performance bottlenecks by showing the call stack of each thread in the Java virtual machine .
To check network connections for a specific port, use either `netstat -an | grep <port_number>` or `lsof -i:<port_number>`. These commands display current network connections involving the specified port .
The `strace` command traces system calls and signals, revealing a process's interaction with the operating system. For network, file, and process tracing over 10 seconds, use `strace -t -e trace=network,file,process -fp <pid> & sleep 10 ; kill $!` .