2008/05/27

HowTo: Create a universal UDM report page in OEM

HowTo: Create a universal UDM report page in OEM

PROBLEM:
  • You have a bunch of User Defined Metrics (UDM) setup in OEM, and you want to know the staus of each of them.
  • OEM does not provide a single page to show the status of UDMs - users must navigate to each instance and look at the UDM page.
SOLUTION:
  • Create a standard OEM Report to display all of your UDMs in one place!
STEPS:
  1. First, if you have not already discovered this the hard way, you cannot create a Report against a non-EMREP/non-Repository tables. Why, i'll never know. But, whatever. The thing is, if you try to create a report using something easy like showing how many records are in an Target Database table, it will return the error "ORA-00942: table or view does not exist"
  2. In this case, we are actually hitting an OEM Repository table, but it's not one of the objects we are allowed to query via the "Table From SQL" report element type.
  3. Fortunately, "bwolter" found a work-around for this sorry situation and published how to it in this Oracle OEM Forum post.
  4. Follow his 3 easy steps, then continue with my Step 5 below.
  5. Create a new Report and choose whatever you want for Category, etc.
  6. Set the "Targets" value to the "Use the specified target" radio-button and select your Repository SID
  7. Set the "Privileges" value to "Run report using target privileges of the report owner (SYSTEM)"
  8. Click the "Elements" sub-tab, then Add a new element using the new "target_user_table_from_sql" type.
  9. Click the "Set Parameters" icon and enter your SQL. Note that your value of KEY_VALUE will be different than mine!
  10. SELECT DISTINCT UPPER(target_name) "Target Name",
           key_value || '__' "Metric Name",
           TO_CHAR(collection_timestamp, 'MM-DD-YYYY HH24:MI') "Last Collected_____",
           string_value "Metric Value"
      FROM sysman.em$current_metrics
     WHERE metric_name = 'SQLUDM'
       AND UPPER(key_value) LIKE 'ENSURE%'
       AND string_value IS NOT NULL
     ORDER BY 1, 2
  11. My KEY_VALUE (the "Name" you used for the UDM) is "Ensure PMON is running as MST", so obviously you will set your value to whatever the Name of your UDM is.
  12. Rinse-and-repeat Steps 8-10 for each UDM type or gorup you want to show on the Report.
NOTES:
  • I use underscore in my column alias names to stretch the columns out for easy reading.
  • During this project I found a UDM which had encountered errors and stopped running! OEM showed no indication outside of a small icon on the Instance's UDM page (nor did it send a notification). This report will save you from that potential embarrasement!!
RESULTS:
  • Here is what my final UDM Report looks like:

2008/02/15

Good article on MERGE statement enhancements in 10g

I don't get to use MERGE too often, but when I need it, it is usually something for something I need to Google the syntax for.

Here's a great post on using MERGE in Oracle 10g with plenty of syntax examples for each.

BTW, thanks Oracle for finally adding support for UPDATE-only or INSERT-only operations!

2008/02/11

HowTo: Setup SSH equivalency

Here's a simple approach to setting up SSH (Secure SHell) equivalency across 2 UNIX boxes. This is also known as "using SSH and SCP without passwords".

There are a variety of reasons to setup SSH equivalency across UNIX boxes. I assume you already have a desire to do so or you would not be reading this, so let's skip the sales patch and get to the howto part.

While there are scripts that do this for you (especially if you're doing this for OEM setup), this is really easy to do on your own, so forget those kludgey scripts!

NOTE: I'm using "UNIX01" and "UNIX02" below to represent 2 different UNIX boxes along with user "oracle" - you can use whatever user you want, just ensure it's the same on both boxes.

STEPS:
  1. On UNIX01:
    1. Create $HOME/.ssh, if it does not already exist
    2. $ cd $HOME/.ssh
    3. Generate your RSA key (NOTE: Your path may vary!)
      1. /usr/bin/ssh-keygen -t rsa
      2. When prompted for a passphrase, just press (ENTER) (leave it blank)
    4. Generate your DSA key
      1. /usr/bin/ssh-keygen -t dsa
      2. When prompted for a passphrase, just press (ENTER) (leave it blank)
    5. Store the 2 keys into the authorized_keys file
      1. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
      2. cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
  2. On UNIX02:
    1. Repeat steps 1-5 above
  3. On UNIX01:
    1. Copy the 2 lines from authorized_keys on UNIX02
    2. Add them to the authorized_keys file
  4. On UNIX02:
    1. Copy the 2 lines from authorized_keys on UNIX01
    2. Add them to the authorized_keys file
That's it!

Test your setup as follows:
  • [oracle@UNIX01] $ ssh -l oracle unix02 date
It should just show you the date without prompting for a password.

Now you can use scp and other ssh commands with ease!