Using EMCLI List Verb to Get Detailed Information of EM Targets

After the presentation about EMCLI at DOAG 2015, someone asked me how we can list database targets based on their operating systems. In my presentation, I told that there are more than 70 verbs which starts with “get_” and help you fetch information about EM objects, and if you can’t find what you’re looking for, you can use the “list” verb which is probably the most powerful verb of EMCLI. Now I try to show how we can use the list verb to fetch detailed information about EM targets.

Let’s say we want to list the databases running on Linux. The original question was how we can list the databases running on Windows but thanks God, I don’t have any databases running on Windows. So I changed the question. First let’s see what we can get by using “get_targets”:

emcli get_targets -target=”oracle_database”:

Screen Shot 2015-11-18 at 13.32.28

As we can see, there’s no information about the operating systems. There’s not even any information about which host these databases are running on. Now let’s try the “list verb” for any of the target databases such as DEVDB:

Using “list” verb, we found the host name. Now we can use the same command to get more information for that host:

The “TYPE_QUALIFIER1” column holds the name of OS if the target is a host. It holds the database version if the target is an oracle database. Unfortunately there’s not an easy way to combine this information when querying the “resources”. So we need to get all oracle databases and then get the host information for each database. Of course, it won’t be a practical approach but here’s a sample code to do it using EMCLI Python (Jython) scripting engine:

Save the above code as list_targets.py, then run it:

Screen Shot 2015-11-18 at 14.26.27

We got the desired result but the method we used is not efficient. Let’s try to get the same info using a different method. The list verb can also be used to execute SQL on EM repository. It will login as MGMT_VIEW, and run the query that you give in “-sql” parameter. So instead of querying “predefined” resources, we can directly query MGMT$TARGET view:

And this is the result:

Screen Shot 2015-11-18 at 14.42.33

We get the desired result with a simple EMCLI command. It’s much faster and cleaner.

Please share
  • 7
  •  
  •  
  •  
  •  
  •  

AWS Big Data Specialist. Oracle Certified Professional (OCP) for EBS R12, Oracle 10g and 11g. Co-author of "Expert Oracle Enterprise Manager 12c" book published by Apress. Awarded as Oracle ACE (in 2011) and Oracle ACE Director (in 2016) for the continuous contributions to the Oracle users community. Founding member, and vice president of Turkish Oracle User Group (TROUG). Presented at various international conferences including Oracle Open World.

6 Comments

  1. John Brunette

    Good post Gokhan,
    I have been working with the list command after seeing your post but have not been able to get exactly what I need.
    We have a list of URLs and we need to know which beacon server is polling each URL by querying the URL.
    Pseudo code:
    emcli get_beacon_server -target=’https:google.com’
    Wondering if you have run a similar query before.
    Thanks,
    John

    • John Brunette

      Gorkan,

      I was able to use the sql you sent me and make a small edit to get what we need.
      Thanks a lot!John
      SELECT MGMT_TARGETS.HOST_NAME,
      MGMT_TARGETS.TARGET_NAME,
      MGMT_BCN_STEP_PROPS.STRING_VALUE
      FROM MGMT_TARGETS,
      MGMT_BCN_TARGET,
      MGMT_BCN_STEP_DEFN,
      MGMT_BCN_STEP_PROPS
      WHERE MGMT_BCN_TARGET.BEACON_TARGET_GUID = MGMT_TARGETS.TARGET_GUID
      AND MGMT_BCN_STEP_PROPS.STEP_GUID = MGMT_BCN_STEP_DEFN.STEP_GUID
      AND MGMT_BCN_STEP_DEFN.TARGET_GUID = MGMT_BCN_TARGET.TARGET_GUID
      AND MGMT_BCN_STEP_PROPS.NAME = ‘url’
      AND MGMT_BCN_STEP_PROPS.STRING_VALUE = ‘https://www.testurl1111.com’;

      HOST_NAME
      ——————————————————————————–
      TARGET_NAME
      ——————————————————————————–
      STRING_VALUE
      ——————————————————————————–
      beaconserver01.domain.com
      beaconserver01
      https://www.testurl1111.com

  2. Santiago Justo

    Hello Everyone,

    I have kind of newbie/dumb question but I’ve been searching all over the net without luck.

    Goal: Add a target_type=oracle_essbase from emcli

    In order to do it effectively, I wanted to complete all the target properties when executing emcli add_target. So, how do I get all the properties of a specific target type? Even better how to I get the possible values for those properties?

    Thank you very much for your time.

    Santiago

     

  3. Michael Jones

    If you change the code to
    myDBs = list( resource=”Targets”, search=”TARGET_TYPE=’host'” )

    the jython script can be used to list hosts instead of DBs

    also the login use the below to avoid hardcoding the password:
    login( username=”sysman”, password=sys.argv[1])

  4. Rajiv N

    Hi Guys, thanks for a wonderful jython, just one question, if I want to filter by agent status, would it be possible?

Leave Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.