# TLem.ctl: Executes Enterprise Manager Tools # $Id: TLem.ctl,v 1.3 2015/11/06 15:01:35 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EM/TLem.ctl,v 1.3 2015/11/06 15:01:35 RDA Exp $ # # Change History # 20151106 MSC Improve the documentation. =head1 NAME EM:TLem - Executes Enterprise Manager Tools =cut use Message options a:g:k:or: section begin # Initialization var $MOD = cond(isUnix(),'fx','fr') var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' # Set the abbreviation call setAbbr('EM_EM_') # Define the macros macro find_kit_home {var ($pgm,$hom,@dir) = @arg import %opt loop $dir ($opt{'k'},@dir,\ ${ENV.EMDIAG_HOME},${SYS.EMDIAG_HOME},\ cond(defined($hom),list(catDir($hom,'emdiag'),$hom),\ list())) {next !?testDir('d',$dir) if ?testFile('f',catFile(last,'bin',$pgm)) return lastTestDir() } return undef } # Start the tool section section tool # Identify the next section if !?$typ = shift(@arg) die 'Missing tool name' if !grep(@{CUR.W_SECTIONS},verbatim($typ,'e'),'f') die 'Unknown tool' var @{CUR.W_NEXT} = ($typ) var $dsp = true =head1 AGTVFY EXECUTION -XRda run em agtvfy ... run em agtvfy ... It tries to locate the Enterprise Manager diagnostic kit and to execute the specified Enterprise Manager F command. It supports the following switches: =over 10 =item B< -a dir> Specifies the agent Oracle home directory. =item B< -k dir> Specifies the EMDIAG kit home directory. =item B< -o> Displays the command results. =item B< -r nam> Stores the command results in the specified report. =back =cut section agtvfy # Determine agent oracle home macro find_agent_home {import %opt loop $dir(testDir('d',$opt{'a'}),\ ${SET.EM.AGT.D_ORACLE_HOME}) {next !?$dir if ?testFile('f',catFile($dir,'bin',${AS.BATCH:'emctl'})) return $dir } if ?${SET.EM.AGT.D_HOME} {if ?testDir('d',cleanPath([last,upDir(),'core',''],true)) {if grepDir(last,'^emctl(\.bat)?$','firw',2) return cleanPath([last,upDir(),''],true) } } loop $dir (${SET.EM.GRID.D_SERVER_HOME},\ ${SET.RDA.BEGIN.D_ORACLE_HOME},\ testDir('d',${ENV.ORACLE_HOME})) {if ?$dir {next !?testDir('d',cleanPath([last,upDir(),upDir(),'agent_inst',''],true)) next !?testDir('d',cleanPath([last,upDir(),'core',''],true)) if grepDir(last,'^emctl(\.bat)?$','firw',2) return cleanPath([last,upDir(),''],true) } } return undef } var $hom = find_agent_home() # Determine EMDIAG kit home var $kit = find_kit_home(${AS.BATCH:'agtvfy'},$hom,\ ${SET.EM.AGT.D_EMDIAG_TOP}) # Define the command descriptor var %dsc = (cat => {},\ corefile => {},\ dump => {},\ error => {},\ gcore => {},\ get => {},\ help => {},\ jinfo => {},\ jmap => {},\ jstack => {},\ list => {},\ ls => {},\ lsof => {},\ metric => {},\ more => {},\ parse => {},\ pstack => {},\ resolve => {},\ scrub => {},\ show => {},\ snapshot => {},\ start => {},\ status => {},\ stop => {},\ target => {},\ type => {},\ verify => {env => {EMDIAG_HOME => $kit,\ ORACLE_HOME => nvl($hom,${ENV.ORACLE_HOME})},\ rpt => 'verify'},\ version => {},\ zip => {},\ ziplist => {}) # Validate the request if !?$req = $arg[0] return new(${CUR.O_REQUEST},'Error.NoCommand',error=>'NO_COMMAND',\ exit_only=>100) if missing($dsc{$req}) return new(${CUR.O_REQUEST},'Error.BadCommand',error=>['BAD_COMMAND',$req],\ exit_only=>101) # Execute the request if !?$kit {if $dsp echo 'EMDIAG kit not found' return new(${CUR.O_REQUEST},'Error.NoKit',display=>'KitNotFound',\ error=>['NO_KIT','Agtvfy'],\ exit_only=>102) } if !?testFile($MOD,catFile($kit,'bin',${AS.BATCH:'agtvfy'})) return new(${CUR.O_REQUEST},'Error.BadPerms',error=>'BAD_PERMS',\ exit_only=>103) var $cmd = join(' ',lastTestCommand(),map(@arg,code(quote(last))),'2>&1') if ?cond(missing($opt{'o'}),nvl(isWord($opt{'r'},true),$dsc{$req,'rpt'})) {call $[OUT]->add_report('C',concat('agtvfy_',last),false) prefix {write '---+ EMDIAG Agtvfy Detail Output' write '---## Using: ',encode($cmd) } call writeCommand({cmd => $cmd,\ env => $dsc{$req,'env'}}) if isCreated(true) write $TOP var $ret = status() } else var $ret = system({cmd => $cmd,\ env => $dsc{$req,'env'}}) if $ret return new(${CUR.O_REQUEST},'Error.CommandFailure',exit_only=>last) return new(${CUR.O_REQUEST},'OK.Run') =head1 OMSVFY EXECUTION -XRda run em omsvfy ... run em omsvfy ... It tries to locate the Enterprise Manager diagnostic kit and to execute the specified Enterprise Manager F command. It supports the following switches: =over 10 =item B< -g dir> Specifies the Enterprise Manager grid Oracle home directory. =item B< -k dir> Specifies the EMDIAG kit home directory. =item B< -o> Displays the command results. =item B< -r nam> Stores the command results in the specified report. =back =cut section omsvfy # Determine OMS oracle home macro find_oms_home {import %opt loop $dir(testDir('d',$opt{'g'}),\ ${SET.EM.GRID.D_SERVER_HOME},\ ${SET.RDA.BEGIN.D_GRID_HOME},\ testDir('d',catDir(${SET.RDA.BEGIN.D_ORACLE_PARENT},'oms')),\ testDir('d',${ENV.ORACLE_HOME})) {next !?$dir if ?testFile('f',catFile($dir,'bin',${AS.BATCH:'emctl'})) return $dir } return undef } var $hom = find_oms_home() # Determine EMDIAG kit home var $kit = find_kit_home(${AS.BATCH:'omsvfy'},$hom,\ ${SET.EM.GRID.D_EMDIAG_OMSVFY_TOP}) # Define the command descriptor var %dsc = (cat => {},\ corefile => {},\ dump => {},\ error => {},\ gcore => {},\ get => {},\ help => {},\ jinfo => {},\ jmap => {},\ jstack => {},\ list => {},\ ls => {},\ lsof => {},\ metric => {},\ more => {},\ parse => {},\ pstack => {},\ resolve => {},\ scrub => {},\ show => {},\ snapshot => {},\ start => {},\ status => {},\ stop => {},\ tnsping => {},\ type => {},\ verify => {env => {EMDIAG_HOME => $kit,\ ORACLE_HOME => nvl($hom,${ENV.ORACLE_HOME})},\ rpt => 'verify'},\ version => {},\ zip => {},\ ziplist => {}) # Validate the request if !?$req = $arg[0] return new(${CUR.O_REQUEST},'Error.NoCommand',error=>'NO_COMMAND',\ exit_only=>100) if missing($dsc{$req}) return new(${CUR.O_REQUEST},'Error.BadCommand',error=>['BAD_COMMAND',$req],\ exit_only=>101) # Execute the request if !?$kit {if $dsp echo 'EMDIAG kit not found' return new(${CUR.O_REQUEST},'Error.NoKit',display=>'KitNotFound',\ error=>['NO_KIT','Omsvfy'],\ exit_only=>102) } if !?testFile($MOD,catFile($kit,'bin',${AS.BATCH:'omsvfy'})) return new(${CUR.O_REQUEST},'Error.BadPerms',error=>'BAD_PERMS',\ exit_only=>103) var $cmd = join(' ',lastTestCommand(),map(@arg,code(quote(last))),'2>&1') if ?cond(missing($opt{'o'}),nvl(isWord($opt{'r'},true),$dsc{$req,'rpt'})) {call $[OUT]->add_report('C',concat('omsvfy_',last),false) prefix {write '---+ EMDIAG Omsvfy Detail Output' write '---## Using: ',encode($cmd) } call writeCommand({cmd => $cmd,\ env => $dsc{$req,'env'}}) if isCreated(true) write $TOP var $ret = status() } else var $ret = system({cmd => $cmd,\ env => $dsc{$req,'env'}}) if $ret return new(${CUR.O_REQUEST},'Error.CommandFailure',exit_only=>last) return new(${CUR.O_REQUEST},'OK.Run') =head1 REPVFY EXECUTION -XRda run em repvfy ... run em repvfy ... It tries to locate the Enterprise Manager diagnostic kit and to execute the specified Enterprise Manager F command. It supports the following switches: =over 10 =item B< -k dir> Specifies the EMDIAG kit home directory. =item B< -o> Displays the command results. =item B< -r nam> Stores the command results in the specified report. =back =cut section repvfy # Determine EMDIAG kit home var $kit = find_kit_home(${AS.BATCH:'repvfy'}) # Define the command descriptor var %dsc = (analyze => {},\ deinstall => {},\ disable => {},\ dump => {},\ enable => {},\ execute => {},\ find => {},\ help => {},\ install => {},\ list => {},\ ls => {},\ locate => {},\ resolve => {},\ resolve => {},\ send => {},\ show => {},\ tnsping => {},\ upgrade => {},\ verify => {rpt => 'verify'},\ version => {},\ zip => {}) # Validate the request if !?$req = $arg[0] return new(${CUR.O_REQUEST},'Error.NoCommand',error=>'NO_COMMAND',\ exit_only=>100) if missing($dsc{$req}) return new(${CUR.O_REQUEST},'Error.BadCommand',error=>['BAD_COMMAND',$req],\ exit_only=>101) # Execute the request if !?$kit {if $dsp echo 'EMDIAG kit not found' return new(${CUR.O_REQUEST},'Error.NoKit',display=>'KitNotFound',\ error=>['NO_KIT','Repvfy'],\ exit_only=>102) } if !?testFile($MOD,catFile($kit,'bin',${AS.BATCH:'repvfy'})) return new(${CUR.O_REQUEST},'Error.BadPerms',error=>'BAD_PERMS',\ exit_only=>103) var $cmd = join(' ',lastTestCommand(),map(@arg,code(quote(last))),'2>&1') if ?cond(missing($opt{'o'}),nvl(isWord($opt{'r'},true),$dsc{$req,'rpt'})) {call $[OUT]->add_report('C',concat('repvfy_',last),false) prefix {write '---+ EMDIAG Repvfy Detail Output' write '---## Using: ',encode($cmd) } call writeCommand({cmd => $cmd,\ env => $dsc{$req,'env'}}) if isCreated(true) write $TOP var $ret = status() } else var $ret = system({cmd => $cmd,\ env => $dsc{$req,'env'}}) if $ret return new(${CUR.O_REQUEST},'Error.CommandFailure',exit_only=>last) return new(${CUR.O_REQUEST},'OK.Run') =head1 SEE ALSO L, L =begin credits =over 10 =item RDA 8.10: Eliane Papillon Le Noc. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. =head1 TRADEMARK NOTICE Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. =cut