Professional Documents
Culture Documents
Script for Checking the Grid Control Agent CPU, Memory & Threads Usage (Doc ID 464414.1)
Modified: 29-May-2013 Type: SCRIPT
In this Document
Purpose
Requirements
Configuring
Instructions
Script
Sample Output
APPLIES TO:
Enterprise Manager Base Platform - Version 10.2.0.1 to 11.1.0.1 [Release 10.2 to 11.1]
Linux x86
IBM AIX on POWER Systems (64-bit)
Oracle Solaris on SPARC (64-bit)
Linux x86-64
***Checked for relevance on 05-Oct-2011***
PURPOSE
The script is intended to provide an overview of the Agent CPU, Memory & Threads as well as of the running, ready
and scheduled collections. The script sample interval is 2 minutes. This can be customized.
REQUIREMENTS
This is a shell script. The only prerequisite is that the agent is running while running the script.
CONFIGURING
1. Download the Script or save its content in a file called "agent_snap.sh" under Agent's ORACLE_HOME/bin directory.
INSTRUCTIONS
1. Make sure the $ORACLE_HOME environment variable is set to the agent oracle home before running the script:
$ cd $ORACLE_HOME/bin
$ ./agent_snap.sh &
5. The script is set to collect data by default every 120 seconds. You can change the interval as required by modifying
the following line of the script:
sleep 120
Leave the script running for as long as you need to gather relevant information for the problem you are diagnosing.
Note that you can customize the script as needed to run other commands to capture additional information every 120
seconds.
Note: The script was tested on Linux, Oracle Solaris & AIX. It may need customization on other Unix platforms.
CAUTION
This sample code is provided for educational purposes only, and is not supported by Oracle Support. It has been tested
internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment
before using.
SCRIPT
#!/bin/sh
sleep 120
done
#!/bin/sh
sleep 120
done
#!/bin/sh
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=7x6o4ezyh_25 3/4
10/25/13 Document Display
emhome=`$ORACLE_HOME/bin/emctl getemhome | tail -1 | awk 'BEGIN {FS="="} {print $2}'`
echo "date\t\tcpu\tvmem\trmem\tthreads\trun\tready\tsched" >>
$emhome/sysman/log/agent_snap.log
while [ 2 -gt 1 ]
do
pid=`$ORACLE_HOME/bin/emctl status agent|grep "Agent Process ID" | awk '{print $5}'`
dateStr=`date "+%m/%d %H:%M:%S"`
cpu=`ps -p $pid -o "pcpu"| tail -1 | sed 's/^[ ]*//'`
threads=`ps -p $pid -o "thcount"| tail -1 | sed 's/^[ ]*//'`
vmem=`ps v $pid | tail -1 | sed 's/^[ ]*//' | awk '{print $6}'`
rmem=`ps v $pid | tail -1 | sed 's/^[ ]*//' | awk '{print $7}'`
$ORACLE_HOME/bin/emctl status agent scheduler > /tmp/snapschedule
sleep 120
done
SAMPLE OUTPUT
The agent_snap.log file will show the timestamp, CPU usage, virtual memory usage, physical memory usage and
number of threads spawned by the agent process. It will also show the number of running, ready and scheduled
collection items. The latter are based on the 'emctl status agent scheduler' and can show interesting trends in the
number of running metric collections - that can then be linked to what we see in terms of resource consumption.
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=7x6o4ezyh_25 4/4