Speedy #em12c template export

Wither you use a single OEM and migrating to a new OEM or have multiple OEMs, the need to move templates between environments will arise.  I had this exact problem come up recently at a customer site between an OEM 11g and OEM 12c.  In order to move the templates, I needed to export the multiple monitoring templates using EMCLI.  The command that I used to do individual exports was the following:

./emcli export_template -name="<template name>" -target_type="<target_type>" -output_file="/tmp/<template name>.xml"

If you have only one template to move, the EMCLI command above will work.  If you have more than one template to move, the easiest thing to do is to have the EMCLI command run in a script.  This is the beauty of EMCLI; the ability to interact with OEM at the command line and use it in scripts for repeated executions.  Below is a script that I wrote to export templates based on target_types.
Note: If you need to identify the target_types that are supported by OEM, they can be found in SYSMAN.EM_TARGET_TYPES in the repository.

#!/usr/bin/perl -w
#
#Author: Bobby Curtis, Oracle ACE
#Copyright: 2014
#
use strict;
use warnings;
#Parameters
my $oem_home_bin = "/opt/oracle/app/product/12.1.0.4/middleware/oms/bin";
my @columns = ("", 0, 0, 0, 0);
my @buf;
my $target_type = $ARGV[0];
#Program
if (scalar @ARGV != 1)
{
 print "\nUsage:\n";
 print "perl ./emcli_export_templates.pl <target_type>\n\n";
 print "<target_type> = target type for template being exported\n";
 print "refer to sysman.em_target_types in repository for more info.";
 print "\n";
 exit;
}
system($oem_home_bin.'/emcli login -username=<userid> -password=<password>');
system($oem_home_bin.'/emcli sync');
@buf = `$oem_home_bin/emcli list_templates`;
foreach (@buf)
{
 @columns = split (/ {2,}/, $_);
 if ($columns[2] eq $target_type )
 {
 my $cmd = 'emcli export_template -name="'.$columns[0].'" -target_type="'.$columns[2].'" -output_file="/tmp/'.$columns[0].'.xml"';
 system($oem_home_bin.'/'.$cmd);
 print "Finished export of: $columns[0] template\n";
 }
}
system($oem_home_bin.'/emcli logout');

If you would like to learn more about EMCLI and other ways to use it have a look at these other blogs:
Ray Smith: https://oramanageability.wordpress.com/
Kellyn Pot’Vin: http://dbakevlar.com/
Seth Miller: http://sethmiller.org/
Enjoy!
twitter: @dbasolved
blog: http://dbasolved.com

Please follow and like:
Comments
  • With havin so much written content do you ever run into any problems of plagorism or copyright infringement? My blog has a lot of completely unique content I’ve either created myself or outsourced but it appears a lot of it is popping it up all over the internet without my agreement. Do you know any methods to help protect against content from being stolen? I’d truly appreciate it.

  • After I initially left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and now every time a comment is added I get four emails with the same comment. There has to be a way you are able to remove me from that service? Thanks a lot.

  • Wow, superb blog format! How long have you ever been running a blog for? you made blogging glance easy. The full look of your web site is wonderful, let alone the content!

  • Great content! This is really insightful for anyone looking to start a startup. I found a lot of actionable advice that I’ll be able to implement in my personal business. Thanks for sharing such valuable information. Looking forward to reading more articles from you! Well done! For more insights on startup strategies, check out this useful guide: this page.

  • Excellent article! This is extremely insightful for anyone aiming to launch a venture. I came across several useful tips that I’ll be able to implement in my personal enterprise. Thank you for providing such valuable content. Excited to checking out more articles from you! Well done! To learn more insights on financial management, check out this great resource: this page.

  • Starting a enterprise can be overwhelming, but with the right guide, you can simplify your process. This comprehensive guide provides advice on how to build a successful startup and avoid common mistakes. Check out this link for further details and to learn more about unlocking growth.

  • I would like to thank you for the efforts you’ve put in writing this web site. I’m hoping the same high-grade blog post from you in the upcoming also. Actually your creative writing abilities has inspired me to get my own site now. Really the blogging is spreading its wings rapidly. Your write up is a great example of it.

Leave a Reply

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

Enquire now

Give us a call or fill in the form below and we will contact you. We endeavor to answer all inquiries within 24 hours on business days.