Skip to content

Forensics Scripts

Reference for the scripts bundled with the Forensic Agent and what each one does.

4 min read Updated SS

These scripts are included in <path>/agents/ForensicAgent/agentIdentifier folder.

Script Name Description
forensic_config.sh This includes configuration parameters needed for forensic scripts.
forensic_db_mapper.sh This contains the mapping for group KPI with KPIs.
forensic_lib.sh This file contains common functions used in forensic scripts.
forensic_template.sh This is a common template file following which custom forensic scripts can be developed.
fetch_cpu_util.sh This provides details on system uptime, CPU utilization, process tree, pstack, truss (tracing system calls and signals) and JVM arguments of the top and CPU-consuming process. This provides additional information related to the CPU. This script will fetch the list of all the CPU processes and defunct processes. You can enable or disable agent filtering.
fetch_mem_util.sh This provides details on system uptime, memory utilization, process tree, pstack, truss (tracing system calls and signals) and JVM arguments of the top and memory-consuming process. This provides additional information related to memory. You can enable or disable agent filtering.
fetch_disk_io.sh This contains information on Disk IO and performance (sar -d output)
fetch_network_util.sh To report detailed statistics by protocol and state of the interfaces.
fetch_netstat.sh To get detail on KPIs: ESTABLISHED, CLOSE_WAIT, SYN_SENT, SYN_RCVD, TIME_WAIT, FIN_WAIT
DBWrapper.sh This captures details on the DB group KPIs: DBDiskIO, DBTablescans, DBLocks, DBSequence, DBExecutions, DBSessions, DBtablespace, DBCPU, DBQueryPerformance
fetch_defunct_Process.sh This captures the list of Defunct Processes.
fetch_user_load_ms.sh This script executes the queries in MSSQL for DB sessions.
hard_parse_count.sh Top Queries undergoing hard parse, table stats for all the tables for KPI Category: DBHardParsing
physical_reads.sh Top Queries by Physical reads, table stats for all the tables for the KPI category: DBPhysicalReads
check_ora_error.sh This script captures the details of the ORA error from the DB alert log.
ThreadDump_Jstack.sh To generate the thread dump (this script accepts a process name as an input parameter and generates a thread dump using the Jstack command).
OOB Forensic Script
Script NameDescription
Total_Port_Access_Count.batThis tracks the forensic details for the Access Count parameter (the total number of HTTP requests) from a particular server.

Executing Forensics Scripts#

Sl. No.CategoryPlatformScriptsCommandExampleDefault Value/ RemarksTimeout (sec)
1CPULinux/Unixfetch_cpu_util.sh./fetch_cpu_util.sh record_count=<value> trace_duration=<value> exclude_agents=<value>./fetch_cpu_util.sh record_count=10 trace_duration=5 exclude_agents=0record_count = 10
trace_duration = 10
exclude_agents = 0
120
Windowsfetch_cpu_util.ps1./fetch_cpu_util.ps1 record_count=<value>1 record_count=15
2MemoryLinux/Unixfetch_mem_util.sh./fetch_mem_util.sh record_count=<value> trace_duration=<value>./fetch_mem_util.sh record_count=10 trace_duration=5 exclude_agents=0record_count = 10
trace_duration = 10
exclude_agents = 0
120
Windowsfetch_mem_util.ps1./fetch_mem_util.ps1 record_count=<value>./fetch_mem_util.ps1 record_count=15
3DiskLinux/Unixfetch_disk_io.sh./fetch_disk_io.sh interval=<value> sample=<value>./fetch_disk_io.sh interval=3 sample=3interval=5,
sample=5
60
Windowsfetch_disk_io.ps1./fetch_disk_io.ps1./fetch_disk_io.ps1-
4NetworkLinux/Unixfetch_network_util.sh./fetch_network_util.sh interval=<value> sample=<value>./fetch_network_util.sh interval=3 sample=3interval=5,
sample=5
60
Windowsfetch_network_util.ps1./fetch_network_util.ps1./fetch_network_util.ps1-
5Network (Time wait and Sync)Linux/Unixfetch_netstat.sh./fetch_netstat.sh./fetch_netstat.sh--
6DB KPIs (Oracle)Linux/UnixDBWrapper.sh./DBWrapper.sh kpi_category="<value>" db_user="<value>" passcode="<value>" ipaddr="<value>" connect_port="<value>" db_name="<value>"./DBWrapper.sh kpi_category="DBExecutions" db_user="c##scott" passcode="<encrypted-password>" ipaddr="192.0.2.73" connect_port="1521" db_name="orcl24"Possible values for kpi_category:
DBDiskIO,
DBTablescans,
DBLocks,
DBSequence,
DBExecutions,
DBSessions,
DBtablespace,
DBCPU,
DBQueryPerformance
-
7ProcessLinux/Unixfetch_defunct_Process.sh./fetch_defunct_Process.sh./fetch_defunct_Process.sh--
8DB KPIs (MSSQL)Linux/Unixfetch_user_load_ms.sh./fetch_user_load_ms.sh ms_login_id="<value>" ms_passcode="<value>" ms_ipaddr="<value>" ms_connect_port="<value>"./fetch_user_load_ms.sh ms_login_id="monitor" ms_passcode="<encrypted-password>" ms_ipaddr="192.0.2.74" ms_connect_port="1433"KPIs:
MSSQLDBSessions
-
9DBHardParsingLinux/Unixhard_parse_count.sh./hard_parse_count.sh db_user="<value>" passcode="<value>" ipaddr="<value>" connect_port="<value>" db_name="<value>"./hard_parse_count.sh db_user="c##scott" passcode="<encrypted-password>" ipaddr="192.0.2.73" connect_port="1521" db_name="orcl24"--
10DBPhysicalReadsLinux/Unixphysical_reads.sh./physical_reads.sh db_user="<value>" passcode="<value>" ipaddr="<value>" connect_port="<value>" db_name="<value>"./physical_reads.sh db_user="c##scott" passcode="<encrypted-password>" ipaddr="192.0.2.73" connect_port="1521" db_name="orcl24"--
11Error Logs (Ora_Error_Logs)Linux/Unixcheck_ora_error.sh./check_ora_error.sh log_file="<log file name with path>"./check_ora_error.sh log_file="/home/appsone/DB_AlertLog_UBPERET1_45/DB_AlertLog_UBPERET1_45_For.out"--
OOB Forensic Script
12NetworkWindowsTotal_Port_Access_Count.bat./Total_Port_Access_Count.bat./Total_Port_Access_Count.bat--

For example:#

1. AIX Platform

a. Success scenario

Execute the below command:

./fetch_cpu_util.sh record_count=3 trace_duration=3

Expected output:

Name: uptime#@#@#APPSONE_NEWLINE#@#@#Description: Info on how long the system has been running#@#@#APPSONE_NEWLINE#@#@#Start Time:
07-24-2019, 12:33:39#@#@#APPSONE_NEWLINE#@#@#End Time: 07-24-2019, 12:33:39#@#@#APPSONE_NEWLINE#@#@#Execute Status:
Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode: 0#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
Uptime of the system is:
139 days 13:06 hour
#@#@#APPSONE_COMMAND_OUTPUT_SEPARATOR#@#@#
Name: ps#@#@#APPSONE_NEWLINE#@#@#Description: Reports currently running processes with CPU utilization
info#@#@#APPSONE_NEWLINE#@#@#Start Time: 07-24-2019, 12:33:39#@#@#APPSONE_NEWLINE#@#@#End Time: 07-24-2019,
12:33:40#@#@#APPSONE_NEWLINE#@#@#Execute Status: Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode:
0#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
USER PID CPU% CMD
support 12648668 19.4 15498:57
root 1048608 7.2 57647:12
root 983070 7.2 57714:34
#@#@#APPSONE_COMMAND_OUTPUT_SEPARATOR#@#@#

b. Failure scenario

Execute the below command:

./fetch_cpu_util.sh record_count=3

Expected output:

Name: ps#@#@#APPSONE_NEWLINE#@#@#Description: Reports currently running processes with CPU utilization
info#@#@#APPSONE_NEWLINE#@#@#Start Time: 07-24-2019, 14:47:07
#@#@#APPSONE_NEWLINE#@#@#End Time: 07-24-2019, 14:47:07#@#@#APPSONE_NEWLINE#@#@#Execute Status:
Failed#@#@#APPSONE_NEWLINE#@#@#ReturnCode: E5001
#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
Error: Invalid number of arguments received
#@#@#APPSONE_COMMAND_OUTPUT_SEPARATOR#@#@#

2. Windows Platform

Execute the below command:

.\fetch_cpu_util.ps1 record_count=10

Expected Output:

Name: Get-WmiObject win32_perfFormatteddata_perfproc_Process#@#@#APPSONE_NEWLINE#@#@#Description: Reports TOP N CPU
Ulitization details#@#@#APPSONE_NEWLINE#@#@#Start Time: 07-12-2019, 10:55:38#@#@#APPSONE_NEWLINE#@#@#End Time: 07-12-2019, 1
0:55:38#@#@#APPSONE_NEWLINE#@#@#Execute Status: Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode: 0#@#@#APPSONE_NEWLINE#@#@#Ke
yValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
Name PercentProcessorTime
---- ---------------------
VirtualBox#9 18
VirtualBox 0
rdpclip#1 0
jusched#1 0
dwm#1 0
explorer#1 0  
VirtualBox#1 0
VirtualBox#2 0
LSCNotify#1 0
VBoxSVC 0
#@#@#APPSONE_COMMAND_OUTPUT_SEPARATOR#@#@#

3. DB Script (Oracle)

Platform: Linux

Execute the below command:

./DBWrapper.sh kpi_category="DbExecutions" db_user="c##scott" passcode="<encrypted-password>"
ipaddr="192.0.2.73" connect_port="1521" db_name="orcl24"

Expected output:

Name: DbExecutions#@#@#APPSONE_NEWLINE#@#@#Description: Connect to Db to fetch details #@#@#APPSONE_NEWLINE#@#@#Start Time: 06-12-
2020, 13:50:44#@#@#APPSONE_NEWLINE#@#@#End Time: 06-12-2020, 13:50:53#@#@#APPSONE_NEWLINE#@#@#Execute Status:
Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode: 0#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
DB records for KPI: CURRENT_OPEN_CURSORS
DB URL: {jdbc:oracle:thin:@192.0.2.73:1521:orcl24}
Connection successful.
SID, USER_NAME, PROGRAM, SQL_ID, SQL_TEXT, OPEN_CURSORS, RNK
123, SYS, ORACLE.EXE (MMON), 772s25v1y0x8k, select shared_pool_size_for_estimate s, shared_pool, 1, 1
123, SYS, ORACLE.EXE (MMON), cuuh20gd15bwf, table_1_ff_29b_0_0_0, 1, 2
123, SYS, ORACLE.EXE (MMON), fzrshwabvtwc0, select max(FA#) from SYS_FBA_FA, 1, 3
123, SYS, ORACLE.EXE (MMON), 4acd3t101zpr6, select tab.rowid, tab.msgid, tab.corrid, tab.priority, tab., 1, 4
123, SYS, ORACLE.EXE (MMON), 8p447s6p0rv6b, select java_pool_size_for_estimate s, java_pool_si, 1, 5
DB records for KPI: CURRENT_LOGONS
DB URL: {jdbc:oracle:thin:@192.0.2.73:1521:orcl24}
Connection successful.
Active User, Inactive User, Inactive_User>48h
40, 1, 1

4. DB Script (MSSQL)

Platform: Linux

Execute the below command:

./fetch_user_load_ms.sh ms_login_id="monitor" ms_passcode="<password>" ms_ipaddr="192.0.2.74" ms_connect_port="1433"

Expected output:

Name: USER_LOAD_MSSQL#@#@#APPSONE_NEWLINE#@#@#Description: Connect to MSSQL to fetch User Load data #@#@#APPSONE_NEWLINE#@#@#Start
Time: 05-13-2020, 16:55:31#@#@#APPSONE_NEWLINE#@#@#End Time: 05-13-2020, 16:55:31#@#@#APPSONE_NEWLINE#@#@#Execute Status:
Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode: 0#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
DB records for KPI: USER_LOAD_MSSQL
ACTIVE_Sessions=23
INACTIVE_Sessions=0
Max_processes=0
Max_sessions=23
(4 rows affected)
#@#@#APPSONE_COMMAND_OUTPUT_SEPARATOR#@#@#  Asasacsc
Sxax

5. CPU Script:

Execute the below command:

./fetch_cpu_util.sh record_count=10 trace_duration=10 exclude_agents=0

Expected output:

Name: ps#@#@#APPSONE_NEWLINE#@#@#Description: Reports currently running processes with CPU utilization
info#@#@#APPSONE_NEWLINE#@#@#Start Time: 03-17-2021, 10:27:02#@#@#APPSONE_NEWLINE#@#@#End Time: 03-17-2021,
10:27:04#@#@#APPSONE_NEWLINE#@#@#Execute Status: Success#@#@#APPSONE_NEWLINE#@#@#ReturnCode:
0#@#@#APPSONE_NEWLINE#@#@#KeyValueOutput: #@#@#APPSONE_NEWLINE#@#@#Output:
CPU Utilization: 8.04%
Number of CPU cores: 2
Note: Total CPU Utilization depends on the number of CPU cores and can be > 100%
-----
USER PID CPU% CMD
root 7068 3.9 /usr/bin/kubelet
root 4963 0.7 /usr/bin/dockerd
root 16212 0.4 /usr/bin/weave-npc
root 16078 0.2 /usr/local/bin/kube-proxy
root 5184 0.1 docker-containerd
root 4617 0.1 /usr/bin/vmtoolsd
root 30690 0.1 sshd:
root 30649 0.1 sshd:
root 17033 0.1 /home/user/weaver
rpc 4646 0.0 /sbin/rpcbind
#@#@#APPSONE_COMMAND_OUTPUT_SEPARATOR#@#@#