Automating OSWatcher Log Capture with oswlogs_capture.sh
Monitoring system performance is essential for ensuring stability, especially in production environments. Oracle’s OSWatcher (OSWbb) is a powerful tool that continuously captures vital operating system metrics. However, extracting logs for specific time periods can be cumbersome without a bit of scripting. That’s where the oswlogs_capture.sh script comes in — offering a simple yet effective way to extract OSWatcher logs for targeted hours within a 24-hour window.
What Does oswlogs_capture.sh do?
The oswlogs_capture.sh script enables flexible and selective extraction of OSWatcher archive logs. Instead of parsing through an entire day’s worth of data, this script allows administrators to specify a time range — extracting only the relevant logs and bundling them into a compressed ZIP file for easy access or sharing.
This is particularly useful when analyzing performance issues that occurred within a specific timeframe, allowing for a more focused and efficient troubleshooting process.
Script Overview
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
cat oswlogs_capture.sh #!/bin/bash #The oswlogs_capture.h provides flexible scheduling of OSWatcher data collection, enabling you to target specific hours within a 24-hour period for more precise and efficient system monitoring # $1 timestamp in YY.MM.DD format # $2 00 through 23 accepted # $3 00 through 23 accepted # $4 extract directory of logfiles # $5 is the OSWatcher Archive Location hostname=`hostname` extractdir=$4 mkdir -p $extractdir rm -f $extractdir/*zip date=$(date +%d_%m_%y) for i in $(seq -w $2 $3); do find $5 -name "$(hostname)_*_$1.${i}00.dat*" -exec zip $extractdir/osw_$(hostname -s)_${date}.zip {} \; done |
The script works by:
Accepting a specific date and hour range.
Searching the OSWatcher archive directory for log files matching that criteria.
Zipping the relevant files into a single archive for easy handling.
How to Use the Script
Below is an example command that extracts logs from April 25, 2025, for the full 24-hour period:
1 |
./oswlogs_capture.sh 25.04.12 00 23 /tmp/osw/12apr /u01/app/oracle.ahf/data/repository/suptools/<<host>>/oswbb/grid/archive |
25.04.12 | The log date (in YY.MM.DD format) |
00 | Start hour (midnight) |
23 | End hour (11 PM) |
/tmp/osw/12apr | Output directory where the ZIP file will be stored |
The last argument is the path to the OSWatcher archive logs.
The output will be a compressed ZIP file named something like osw_<hostname>_12_04_25.zip, containing all log files from the specified range.