Renaming #EM12c - #EM13c Targets - DBASolved
Renaming #EM12c - #EM13c Targets - DBASolved
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:
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:
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.
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.
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
(https://www.specificfeeds.com/widgets/emailSubscribeEncFeed/TUZjdzl1WUxRNW55d1gzd3hxaG85Y0Mxb2xO
(https://twitter.com/intent/tweet?text=Renaming+%23EM12c+%2F+%23EM13c+Targets+https://www.d
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 …
Related articles
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