Skip to content

Forensic Scripts Usage

Run Forensic Agent scripts with parameters to collect metrics from local and remote servers.

3 min read Updated SS

Forensic Scripts#

1. To extract the CPU utilization metrics,

fetch_cpu_util.sh

To collect local server details

./fetch_cpu_util.sh record_count=<value> trace_duration=<value> exclude_agents=<value> ip_address=<ip address value>

For example:

./fetch_cpu_util.sh record_count=10 trace_duration=5 exclude_agents=0 ip_address=192.0.2.79

To collect remote server details

./fetch_cpu_util.sh record_count=<value> trace_duration=<value> exclude_agents=<value> <ip_address= ip address value> remote_user=<remote user> remote_port=<remote port>

For example:

./fetch_cpu_util.sh record_count=10 trace_duration=5 exclude_agents=0 ip_address=192.0.2.80 remote_user=root remote_port=22

2. To extract the memory utilization data,

fetch_mem_util.sh

To collect local server details

./fetch_mem_util.sh record_count=<value> trace_duration=<value> exclude_agents=<value> ip_address=<ip address value>

For example:

./fetch_mem_util.sh record_count=10 trace_duration=5 exclude_agents=0 ip_address=192.0.2.79

To collect remote server details

./fetch_mem_util.sh record_count=<value> trace_duration=<value> exclude_agents=<value> ip_address=<ip address value> remote_user=<remote user> remote_port=<remote port>

For example:

./fetch_mem_util.sh record_count=10 trace_duration=5 exclude_agents=0 ip_address=192.0.2.80 remote_user=root remote_port=22

3. To monitor and report on disk input/output (I/O) statistics on systems.

fetch_disk_io.sh

To collect local server details

./fetch_disk_io.sh interval=<value> sample=<value> ip_address=<ip address value>

For example:

./fetch_disk_io.sh interval=3 sample=3 ip_address=192.0.2.79

To collect remote server details

./fetch_disk_io.sh interval=<value> sample=<value> <ip_address= ip address value> remote_user=<remote user> remote_port=<remote port>

For Example:

./fetch_disk_io.sh interval=3 sample=3 ip_address=192.0.2.80 remote_user=root remote_port=22

4. To extract the network utilization data,

fetch_network_util.sh

To collect local server details

./fetch_network_util.sh interval=<value> sample=<value> ip_address=<ip address value>

For example:

./fetch_network_util.sh interval=3 sample=3 ip_address=192.0.2.79

To collect remote server details

./fetch_network_util.sh interval=<value> sample=<value> <ip_address= ip address value> remote_user=<remote user> remote_port=<remote port>

For example:

./fetch_network_util.sh interval=3 sample=3 ip_address=192.0.2.80 remote_user=root remote_port=22

5. To collect and possibly analyze network statistics,

fetch_netstat.sh

To collect local server details

./fetch_netstat.sh ip_address=<ip address value>

For example:

./fetch_netstat.sh ip_address=192.0.2.79

6. To identify and report on defunct processes:

fetch_defunct_process.sh

To collect local server details,

./fetch_defunct_process.sh ip_address=<ip address value>

For example:

./fetch_defunct_process.sh ip_address=192.0.2.79

To collect remote server details,

./fetch_defunct_process.sh ip_address=<ip address value>

For example:

./fetch_defunct_process.sh ip_address=192.0.2.79

7. To retrieve and display the content from specified log files:

getLogFileContent.sh

To collect local server details,

./getLogFileContent.sh ip_address=<ip address value> logfile_path=<log file name with path> number_of_lines=<number of lines to be shown>

For example:

./getLogFileContent.sh ip_address=19x.xxx.xx.xxx logfile_path="/usr/app/trace/transaction_data.log" number_of_lines=500

To collect remote server details,

./getLogFileContent.sh ip_address=<ip address value> logfile_path=<log file name with path> number_of_lines=<number of lines to be shown> remote_user=<remote user> remote_port=<remote port>

For example:

./getLogFileContent.sh ip_address=19x.xxx.xx.xxx

8. To generate the thread dump.

This script accepts a process name as an input parameter and generates a thread dump using the Jstack command.

Script: ThreadDump_Jstack.sh

Execute the below script with the "process name: shopping-eureka-server with pid 125812":

./ThreadDump_Jstack.sh Process_Name="shopping-eureka-server"

Expected Output:

  • Successful
Name: jstack#@#@#APPSONE_NEWLINE#@#@#Description: Generated thread dump#@#@#APPSONE_NEWLINE#@#@#Start Time: 05-06-2024,
09:32:05#@#@#APPSONE_NEWLINE#@#@#End Time: 05-06-2024, 09:32:06#@#@#APPSONE_NEWLINE#@#@#Execute Status:
Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode: 0#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
Attaching to process ID 125812, please wait..
Debugger attached successfully.
Server compiler detected.
JVM version is 25.402-b06
Deadlock Detection:

No deadlocks were found.

Thread 2474931: (state = BLOCKED)

Thread 125813: (state = BLOCKED)

Thread 125884: (state = BLOCKED)
 - sun.misc.Unsafe.park(boolean, long) @bci=0 (Interpreted frame)
 - java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=14, line=175 (Interpreted frame)
 - java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await() @bci=42, line=2044 (Interpreted frame)
 - java.util.concurrent.LinkedBlockingQueue.take() @bci=29, line=442 (Interpreted frame)
 - org.apache.tomcat.util.threads.TaskQueue.take() @bci=36, line=107 (Interpreted frame)
 - org.apache.tomcat.util.threads.TaskQueue.take() @bci=1, line=33 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor.getTask() @bci=149, line=1074 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=26, line=1134 (Interpreted frame)
 - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=624 (Interpreted frame)
 - org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run() @bci=4, line=61 (Interpreted frame)
 - java.lang.Thread.run() @bci=11, line=750 (Interpreted frame)
  • Failed Scenario:
Name: jstack#@#@#APPSONE_NEWLINE#@#@#Description: Generated thread dump#@#@#APPSONE_NEWLINE#@#@#Start Time: 05-06-2024,
09:30:13#@#@#APPSONE_NEWLINE#@#@#End Time: 05-06-2024, 09:30:13#@#@#APPSONE_NEWLINE#@#@#Execute Status:
Failed#@#@#APPSONE_NEWLINE#@#@#ReturnCode: E5004#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
Error: Issue with shared libraries for the command executed