0% found this document useful (0 votes)
185 views8 pages

Renaming #EM12c - #EM13c Targets - DBASolved

Renaming #EM12c

Uploaded by

akammiea Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views8 pages

Renaming #EM12c - #EM13c Targets - DBASolved

Renaming #EM12c

Uploaded by

akammiea Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Renaming #EM12c / #EM13c Targets

 March 8, 2016  dbasolved (https://www.dbasolved.com/author/dbasolved/)


 OEM (https://www.dbasolved.com/category/database-0/oem/)

Oracle Enterprise Manager is a complex piece of software that many organizations are running now. Some
organizations set out with a formalized naming standard; some do not. Those who do not ofter end up
identifying a naming standard later down the road and then making requests to change the names of the
targets being monitored. In order to do this, there are two ways:

1. Delete and rediscover the target and rename at time of discovery

2. Change the name from the backend using EMCLI

The first way is painful to say the least, especially when you have thousands upon thousands of targets. So
this post is going to focus on how to change the name from the backend using EMCLI and a few other little
tips.

EMCLI is a nice tool to use. It provides two options for renaming of targets. The first option is rename_target
and the second is modify_target. The rename_target option is used to rename the target on the repository
side, while the modify_target option is used to rename at the agent level. Both options are required when
renaming a target because the target needs to stay in-sync to retain the history of the target.

To make this process a bit more automated, I’ve created a perl script that will do the renaming for me based
on information in a space delimited flat file. The script is as follows:

01 #!/usr/bin/perl -w
02 use strict;
03 use warnings;
04 ##########################
05 #Notes
06 ##########################
07 #
08 #To help with renaming the entity_name in the repository database,
09 #comment out block of code in SYSMAN.EM_TARGET from line 8028 thru 8035
10 #
11 ##########################
12 #GLOBAL Variables
13 ##########################
14 my $oem_home_bin = "";
15 my $time_now = localtime();
16 my ($variable, $sysman_pwd) = @ARGV;
17 my $count = 0;
18 my @columns;
19 ##########################
20 #Main Program
21 ##########################
22 open (FILE, "< $variable") or die "$!\n";
23 @columns = ("", 0, 0, 0);
24 print "\nStart time: ".$time_now."\n";
25 emcli_login();
26 while()
27 {
28     my $line = $_;
29     @columns = split(' ',$line, 4);
30     rename_target(@columns);
31     $count = $count+1;
32 } #end file read
33 close (FILE) or die "$!\n";
34 my $end_time=localtime();
35 print "\nNumber of changes: ".$count;
36 print "\nEnd time: ".$end_time."\n";
37 emcli_logout();
38 ##########################
39 #Sub-Programs
40 ##########################
41 sub emcli_login{
42     print "\n";
43     system($oem_home_bin.'/emcli login -username=sysman -password='.$sysman_pwd);
44     system($oem_home_bin.'/emcli sync');
45     print "\n";
46 }
47 sub emcli_logout{
48     print "\n";
49     system($oem_home_bin.'/emcli logout');
50     print "\n";
51 }
52 sub rename_target{
53     #Parameters
54     my ($target_name, $target_type, $server_name )=@columns;
55     my $mod_target;
56     my $new_name;
57     my $cmd;
58     my $cmd1;
59     if ($target_type =~ /rac_database/)
60     {
61         chomp($target_name);
62         chomp($server_name);
63         $mod_target = $target_name;
64         $target_name = substr($target_name, 0, -4);
65         $new_name = $target_name."_".$server_name;
66         #print $new_name;
67         print "\n";
68         $cmd = 'emcli modify_target -name="'.$mod_target.'" -type="
69         print $cmd."\n";
70         #print "\n!!!!Executing on agent side!!!!\n";
71         #system($oem_home_bin.'/'.$cmd);
72         $cmd1 = 'emcli rename_target -target_type="'.$target_type.'" -ta
73         print $cmd1."\n";
74         #print "\n!!!!Executing on repository side!!!!\n";
75         #system($oem_home_bin.'/'.$cmd);
76     }
77 }
Notice that I’m doing the renaming at the agent side along with the repository side. Although this looks pretty
simple and straight forward, I’ve found that the EMCLI command to rename (rename_target) is actually driven
by the package EM_TARGET in the SYSMAN schema. There is a small set of code in this package that will
prevent renaming of certain target types if they are currently being monitored and managed by OEM.

To identify what targets are managed, the following SQL can be used:

1 SELECT ENTITY_TYPE, ENTITY_NAME, DISPLAY_NAME FROM EM_MANAGEABLE_ENTITIES


2 WHERE ENTITY_TYPE='oracle_database' and promote_status=3 and manage_status=‘2';

The SQL above will provide you with the target type (entity_type), name (entity_name), and display name
(display_name). These three columns are important because they directly correlate to what you will see in
OEM. About 90% of the screen in OEM use the display_name column. The other 10% of the screens use the
entity_name. When you start renaming, you will want these names to match, just keep in mind they may not
over the long haul.

Now, back to the code in the EM_TARGET package. When renaming targets, some target will report back that
the target cannot be changed. This is due to the target already being managed by OEM. In order to by-pass
this, you need to update the EM_TARGET package body and comment out a small set of code (make sure you
back up the package before doing anything). The lines of code that need to be commented out are between
8028 and 8035.

1 -- we will implement rename of agent side targets when it is fully


2      -- supported by agent
3     --IF ( l_trec.manage_status = MANAGE_STATUS_MANAGED AND
4     --     l_trec.emd_url IS NOT NULL)
5     --THEN
6     --  raise_application_error(MGMT_GLOBAL.INVALID_PARAMS_ERR,
7     --      MGMT_GLOBAL.INVALID_PARAMS_ERR||' Not allowed') ;
8     --END IF ;

After commenting out these lines of code, recompile the package. Then you will be able to rename repository
targets using EMCLI even though they are already managed targets. This will effect the entity_name column
and allow you to update the other 10% of pages that are not immediately changed.

Another way to change names of targets once the EM_TARGET package has been updated, is to use SQL to
make the changes.

1 exec sysman.em_target.rename_target(target_type, current_name, new_name, new_name);


2 commit;
Once the commit has happened, then the OEM pages can be refreshed and the new entity_name will be
displayed.

Well, I hope this has provided you some explanation on how to change existing targets within the EM
framework.

Enjoy!

about.me: http://about.me/dbasolved

Please follow and like:

(https://www.specificfeeds.com/widgets/emailSubscribeEncFeed/TUZjdzl1WUxRNW55d1gzd3hxaG85Y0Mxb2xO

(https://twitter.com/intent/tweet?text=Renaming+%23EM12c+%2F+%23EM13c+Targets+https://www.d

@em12c em13c emcli oms renaming targets repository sql

 Share on Facebook
(//www.facebook.com/sharer/sharer.php?u=https://www.dbasolved.com/2

 Share on Twitter
(//twitter.com/share?url=https://www.dbasolved.com/2016/03/renaming-em

 Share on Pinterest
(https://pinterest.com/pin/create/link/?url=https://www.dbasolved.com/2

 Share on LinkedIn
(https://www.linkedin.com/shareArticle?mini=true&url=https://www.dbaso

(http://rheodata.com)
Bobby Curtis

I’m Bobby Curtis and I’m just your normal average guy who has been working in the technology
field for awhile (started when I was 18 with the US Army). The goal of this blog has changed a bit
over the years. Initially, it was a general blog where I wrote thoughts down. Then it changed to
focus on the Oracle Database, Oracle Enterprise Manager, and eventually Oracle GoldenGate.

If you want to follow me on a more timely manner, I can be followed on twitter at @dbasolved or
on LinkedIn under “Bobby Curtis MBA”.

Search Blog:

Search … 

Follow if you like:


(https://www.dbasolved.com/feed/)
(https://www.specificfeeds.com/widgets/emailSubscribeEncFeed/TUZjdzl1WUxRNW55d1gzd3hxaG8
() (https://www.linkedin.com/in/bobbycurtis294/)

Related articles

 March 14, 2016 (https://www.dbasolved.com/2016/03/emd360-oem-health-checks-made-easy/)


 OEM (https://www.dbasolved.com/category/database-0/oem/)

#EMd360 … OEM health checks made easy


(https://www.dbasolved.com/2016/03/emd360-oem-
health-checks-made-easy/)
Read more 

 September 14, 2015 (https://www.dbasolved.com/2015/09/discovery-and-monitor-oracle-


database-appliance-oda-using-em12c/)
 OEM (https://www.dbasolved.com/category/database-0/oem/)

Discovery and Monitor Oracle Database Appliance


(#ODA) using #EM12C
(https://www.dbasolved.com/2015/09/discovery-and-
monitor-oracle-database-appliance-oda-using-em12c/)
Read more 

 September 11, 2015 (https://www.dbasolved.com/2015/09/zfs-storage-monitoring-with-em12c/)


 OEM (https://www.dbasolved.com/category/database-0/oem/)
ZFS Storage monitoring with #EM12C
(https://www.dbasolved.com/2015/09/zfs-storage-
monitoring-with-em12c/)
Read more 

Leave a Reply
Comment

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.
Post Comment

Home

About

Ask a Question

Privacy Policy

© 2020 DBASolved | All rights reserved |


Atlanta Web Design by Fame Marketing (https://youneedfame.com)

You might also like