Kevin Kempf's Blog

October 2, 2009

Using Custom Metrics in Enterprise Manager to Monitor Applications 11i (Part III)

Filed under: 11i, EM to monitor 11i — kkempf @ 10:02 am

I’m going to try to wrap up the monitoring posts with an explanation of how you can monitor what’s happening on the Applications tier(s).  Basically, you can monitor it as a custom metric if you can get a value back in a SQL query or you can get a shell script to output a value..

I have a couple  disclaimers:

  • I only have 1 Applications tier, and if you have multiple you’d have to take that into consideration for many of these operating system type metrics
  • You’ll need some basic shell script knowledge, as well as cron, and appropriate access to the operating system
  • You need to weigh security risks of some of these jobs
  • This is verified for socket connections.  It may change under servlet, not sure yet.

Lets start with a something really useful: Number of Forms Sessions.  There’s 4 major parts:


On the apps tier, I have a cron job set up like this in cron:

$ crontab -l

# Track the number of forms sessions
*/10 * * * * /scratch/oracle/dba/scripts/ PROD > /dev/null

In other words, every 10 minutes run a shell script called with the parameter PROD and redirect any output to the black hole of linux (/dev/null).  The command to edit cron (or at least, I should say, the way I do it) is crontab -e then add your lines.  This has the potential to be fairly dangerous, make sure you know what you’re doing!


I’ve artificially added line numbers to the beginning of each line in the script below so I can explain it more clearly; omit them if you use the script

$ cat /scratch/oracle/dba/scripts/
1 . ~/env/${1}_APPS
2 CUSTOMPASS=(custom schema password)
3 SESSIONS=`pgrep f60webmx | wc -l`
4 DATE_STAMP=`date +%d-%b-%y,%H:%M`
5 echo “update xxx.xxx_os_metrics_staging set forms_sessions = ${SESSIONS}, forms_sessions_date_stamp = ‘${DATE_STAMP}’;”|sqlplus -S xxx/${CUSTOMPASS}
6 echo $SESSIONS,$DATE_STAMP                    


1. this line merely sources environment variables; PROD_APPS basically just sources $APPL_TOP/APPSORA.env

2. plain text password of your custom schema; you can do this more securely if you know shell scripting

3. determine how many forms sessions are connected to this applications server

4. create a date stamp

5. connect to the database and insert 2 values

6. useful for debugging if you run it command line

Here’s the structure of the table I’m inserting into.  In reality, my table has many more columns, as I track other metrics at the OS level in this table through this same method (and you can too).


SQL> desc xxx.xxx_os_metrics_staging
 Name                            Null?    Type
 ------------------------------- -------- ----
 FORMS_SESSIONS                           NUMBER


Finally, you need to add a custom metric in enterprise manager for Forms Sessions (be sure to add schema xxx to the query if you’re not making the table as the apps user):

Setup of Forms Session Tracker in EM

Setup of Forms Session Tracker in EM


Blog at