# OIDinfo.def: Collects Generic Oracle Internet Directory Information # $Id: OIDinfo.def,v 2.9 2012/01/03 13:34:42 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/OIDinfo.def,v 2.9 2012/01/03 13:34:42 mschenke Exp $ # # Change History # 20120103 MSC Change the copyright notice. =head1 NAME OIDinfo - Collects Generic Oracle Internet Directory Information =head1 DESCRIPTION This module collects generic Oracle Internet Directory information. =cut # Initialization var ($AS11,$INS) = @arg import $LDAP_HOME,$ORACLE_HOME,$TOC,$TOP # Collect the database information if or(and($AS11,$INS),not($AS11)) {# Load the common macros run DBinfo() var $OID_USER = 'ODS' if $INS var $sid = 'OIDDB' elsif !$AS11 {var $OID_LOCAL = getSetting('OID_LOCAL') # Change the database context if $OID_LOCAL var $sid = getSetting('ORACLE_SID') elsif getSetting('OID_SID') var $sid = trim(last,'-') } if $sid {# Determine the user password if hasSqlPassword($OID_USER,$sid) var $pwd = undef else var $pwd = askPassword(concat('Enter ',$OID_USER,'@',$sid,' user password:')) # Switch the context var $log = setSqlLogin($OID_USER,$pwd,$sid) var $try = setSqlFailure(0) } else {# Disable the database access var $log = setSqlLogin('','') var $try = setSqlFailure(-1) } # Test the database connection if testSql() {echo '' echo tput('bold'),'The schema containing the OID repository is not \ accessible.',tput('off') echo tput('bold'),'Therefore RDA cannot collect repository information.',\ tput('off') if getSqlMessage() echo last echo '' } else var $DB_ACCESS = true =head2 oid_diag - OIDDIAG Output Displays the output of the F command. =cut if getSetting('OID_DIAG') {var $cmd = undef if findCommand('oiddiag') var $cmd = last elsif grepDir(catDir($LDAP_HOME,'bin'),'oiddiag','fip') var $cmd = catCommand(last) if $cmd {var $tmp = getTemp('oid','.txt') var $txt = getTemp('oiddiag','.txt') var $out = quote($txt,'x') debug ' Inside OID module, executing the OIDDIAG command' if compare('eq',$out,$txt) output | concat($cmd,' collect_all=true outfile=',$out,' >',quote($tmp,'x')) else output | concat($cmd,' collect_all=true >',quote($tmp,'x')) write getSetting('OID_DB_HOST') write getSetting('OID_DB_PORT') write getSetting('OID_SERVICE_NAME') write $pwd if $AS11 {write 'N' write 'N' } close report oid_diag prefix {write '---+!! OIDDIAG Command Output' write '---## Using: ',encode($cmd),' collect_all=true' } if grepFile($tmp,'^Done\! the output file is\s+(.*)\s*$') {var ($lin) = chomp(last) if match($lin,'^Done\! the output file is\s+(.*?)\s*$') call writeFile(last) } else call writeFile($tmp) call unlinkTemp('oid') call unlinkTemp('oiddiag') if isCreated(true) toc '2:[[',getFile(),'][rda_report][OIDDIAG Output]]' } } } =head2 oidctl - OIDCTL Status Displays the C status. =cut if or(and($AS11,not($INS)),not($AS11)) {var $chk = true if findCommand('oidctl') {var $cmd = concat(last,' connect=',$sid,' status 2>&1') debug ' Inside OID module, getting the OIDCTL status' report oidctl prefix {write '---+!! OIDCTL Status' write '---## Using: ',encode($cmd) } if loadCommand($cmd) {call writeLastFile() var $chk = false } if isCreated(true) toc '2:[[',getFile(),'][rda_report][OIDCTL Status]]' } =head2 ldapcheck - ldapcheck Displays the output of the command C<$ORACLE_HOME/ldap/bin/ldapcheck> when it encounters a problem for getting the C status. =cut if $chk {if or(isWindows(),isCygwin()) var $fil = catFile($ORACLE_HOME,'ldap','bin','ldapcheck.exe') else var $fil = catFile($ORACLE_HOME,'ldap','bin','ldapcheck') if testFile('x',$fil) {debug ' Inside OID module, getting the ldapcheck command output' report ldapcheck prefix {write '---+!! ldapcheck command output' write '---## Using: ',encode($fil) } if loadCommand($fil) call writeLastFile() if isCreated(true) toc '2:[[',getFile(),'][rda_report][ldapcheck]]' } } =head2 process - Processes Displays the information about processes. For Windows, RDA gets the processes only if the tasklist command is available. =cut debug ' Inside OID module, gathering information about processes' report process var $TTL = '---+!! Processes' if isUnix() {var $OSP = testCommand('ps -ef','/bin/ps -ef','/usr/bin/ps -ef') prefix {if $TTL {write $TTL write $TOC var $TTL = undef } write '---+ OID Processes' write '' } loop $lin (grepCommand($OSP,'\boid\w')) write $lin if hasOutput(true) {write '' write $TOP } prefix {if $TTL {write $TTL write $TOC var $TTL = undef } write '---+ DIP Processes' write '' } loop $lin (grepCommand($OSP,'\bodi\w')) write $lin if hasOutput(true) {write '' write $TOP } } elsif or(isWindows(),isCygwin()) {if findCommand('tasklist') {var $cmd = last prefix {if $TTL {write $TTL write $TOC var $TTL = undef } write '---+ OID Processes' write '' } loop $lin (grepCommand(concat($cmd,' /V'),'^oid','i')) write $lin if hasOutput(true) {write '' write $TOP } prefix {if $TTL {write $TTL write $TOC var $TTL = undef } write '---+ DIP Processes' write '' } loop $lin (grepCommand(concat($cmd,' /V'),'^odi','i')) write $lin if hasOutput(true) {write '' write $TOP } } } if !$AS11 {if or(isWindows(),isCygwin()) var $fil = catFile($ORACLE_HOME,'opmn','bin','opmnctl.exe') else var $fil = catFile($ORACLE_HOME,'opmn','bin','opmnctl') if testFile('x',$fil) {var $cmd = concat($fil,' status') prefix {if $TTL {write $TTL write $TOC var $TTL = undef } write '---+ ',encode($cmd) } call writeCommand($cmd) if hasOutput(true) write $TOP } } if isCreated(true) toc '2:[[',getFile(),'][rda_report][Processes]]' var $TTL = undef } =head2 ods_process - ODS Process Information Lists details from the C table on OID 11g, or from the C table in earlier versions. =cut if or(and($AS11,$INS),not($AS11)) {if $DB_ACCESS {debug ' Inside OID module, gathering ODS process information' report ods_process prefix {write '---+!! ',uc($tbl) write $hdr } if $AS11 var ($tbl,$flg) = ('ods_process_status',true) else {var ($tbl,$flg) = ('ods_process',\ getSqlColumns('RDA','','ODS_PROCESS','failedhost')) call clearSqlColumns('RDA') } if $flg {var $hdr = '| *Instance*| *Process ID*| *Server ID*|*Flags*|*Hostname*| \ *ConfigSet*| *State*|*Last Wake Time*| *Retry Count*|\ *Failed Host*|' set $sql {SELECT '| ' || " instance || '| ' || " pid || '| ' || " serverid || '|' || " flags || ' |' || " hostname || ' | ' || " configset || '| ' || " state || '|' || " TO_CHAR(lastwaketime,'DD-Mon-YYYY HH24:MI:SS') || ' | ' || " retrycount || '|' || " NVL(failedhost,'%NULL%') || ' |' " FROM :1; } } else {var $hdr = '| *Instance*| *Process ID*| *Server ID*|*Flags*|*Hostname*| \ *ConfigSet*| *State*|*Last Wake Time*| *Retry Count*|' set $sql {SELECT '| ' || " instance || '| ' || " pid || '| ' || " serverid || '|' || " flags || ' |' || " hostname || ' | ' || " configset || '| ' || " state || '|' || " TO_CHAR(lastwaketime,'DD-Mon-YYYY HH24:MI:SS') || ' | ' || " retrycount || '|' " FROM :1; } } call writeSql(bindSql($sql,$tbl)) if getSqlMessage() write last if isCreated(true) toc '2:[[',getFile(),'][rda_report][ODS Process Information]]' =head2 attrstore - DS_ATTRSTORE table Information Lists details from C table. =cut debug ' Inside OID module, gathering details from ds_attrstore table' report attrstore var $TTL = '---+!! DS_ATTRSTORE Table Information' var @TTL = ('',\ '---+ Default LDAP Settings',\ '---+ Other LDAP Settings',\ '---+ Default Replication Settings',\ '---+ Other Replication Settings',\ '---+ DIP Information - Profile Information',\ '---+ DIP Information - Default Profiles',\ '---+ DIP Information - DIP Configuration') var @HDR = ('',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|',\ '|*Entry ID*|*Name*|*Value*|*Kind*|*Version*|*Type*|') set $sql {SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(attrval,'%','%'),CHR(10),'%BR%') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=configset0,' || " '%cn=osdldapd,' || " '%cn=subconfigsubentry%') " ORDER BY entryid,attrname; "PROMPT ___Macro_separator(2)___ "SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(REPLACE(attrval,'%','%'), " CHR(10),'%BR%'), " '|','|') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=osdldapd,%cn=subconfigsubentry%' " AND attrval NOT LIKE '%cn=configset0,%') " ORDER BY entryid,attrname; "PROMPT ___Macro_separator(3)___ "SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(attrval,'%','%'),CHR(10),'%BR%') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=configset0,' || " '%cn=osdrepld,' || " '%cn=subconfigsubentry%') " ORDER BY entryid,attrname; "PROMPT ___Macro_separator(4)___ "SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(attrval,'%','%'),CHR(10),'%BR%') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=osdrepld,%cn=subconfigsubentry%' " AND attrval NOT LIKE '%cn=configset0,%') " ORDER BY entryid,attrname; "PROMPT ___Macro_separator(5)___ "SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(attrval,'%','%'),CHR(10),'%BR%') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=metadird,' || " '%cn=configsets,' || " '%cn=oracle internet directory%') " ORDER BY entryid,attrname; "PROMPT ___Macro_separator(6)___ "SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(attrval,'%','%'),CHR(10),'%BR%') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=provisioning profiles,' || " '%cn=changelog subscriber,' || " '%cn=oracle internet directory%') " ORDER BY entryid,attrname; "PROMPT ___Macro_separator(7)___ "SELECT '[[[' || CHR(10) || '|' || " entryid || '|' || " attrname || ' |' || " REPLACE(REPLACE(attrval,'%','%'),CHR(10),'%BR%') || ' |' || " attrkind || ' |' || " NVL(attrver,'%NULL%') || ' |' || " NVL(attrstype,'%NULL%') || ' |' || " CHR(10) || ']]]' " FROM ds_attrstore " WHERE entryid IN ( " SELECT entryid " FROM ds_attrstore " WHERE attrname IN ('orclentrydn','orclnormdn') " AND attrval LIKE '%cn=odi,%cn=oracle internet directory%') " ORDER BY entryid,attrname; "PROMPT ___Capture_Only_Config___ } if $AS11 {append $sql {SELECT 'port=' || attrval " FROM ds_attrstore " WHERE attrname = 'orclnonsslport' " AND entryid IN (SELECT entryid " FROM ds_attrstore " WHERE attrname = 'orcloidcomponentname'); } } else {append $sql {SELECT 'port=' || attrval " FROM ds_attrstore " WHERE attrname = 'orclnonsslport'; } } call separator(1) call writeSql($sql) call separator(0,'DS_ATTRSTORE Table Information') var $prt = value(grepSqlBuffer('Config','^port=','f')) } # Restore the previous context call setSqlLogin($log) call setSqlFailure($try) =head2 oidconf - OID Configuation Performs LDAP queries to get OID configuration information. =cut debug ' Inside OID module, getting the OID configuration information' var $flg = false if grepCommand(\ concat(catCommand($ORACLE_HOME,'bin','ldapsearch'),' -H 2>&1'),'\s-q\s','f') var ($flg,$pgm) = (true,lastCommand()) if !$flg var $pgm = findCommand('ldapsearch') if and($pgm,$prt) {var $pwd = askPassword('Enter the password for the OID cn=orcladmin user:') # Macro to get the output of ldapsearch command macro exec_ldapsearch {var ($cmd,$ttl,$flg,$pwd) = @arg import $TOP keep $TOP prefix write '---+ ',$ttl if $flg {suspend report var $out = getTemp('ldapsearch','.txt') var $cmd = concat($cmd,' >',quote($out,'x'),' 2>&1') output | $cmd write $pwd close resume report call writeFile($out,['C','ldapsearch']) call unlinkTemp('ldapsearch') } else call writeCommand(concat($cmd,' 2>&1')) if hasOutput(true) write $TOP } report oidconf title '---+!! OID Configuration Information using LDAP Queries' title $TOC var $cmd = concat($pgm,' -p ',$prt,' -D cn=orcladmin ',\ cond($flg,'-q',concat('-w ',$pwd)),\ ' -L -b "" -s sub "objectclass=pwdpolicy"') call exec_ldapsearch($cmd,'Password Policy Configuration',$flg,$pwd) var $cmd = concat($pgm,' -p ',$prt,' -D cn=orcladmin ',\ cond($flg,'-q',concat('-w ',$pwd)),\ ' -L -b "cn=plugin,cn=subconfigsubentry" -s sub \ "objectclass=*"') call exec_ldapsearch($cmd,'Plugin Configuration',$flg,$pwd) var $cmd = concat($pgm,' -p ',$prt,' -D cn=orcladmin ',\ cond($flg,'-q',concat('-w ',$pwd)),\ ' -L -b "orclagreementid=000001,cn=replication \ configuration" -s base "objectclass=*"') call exec_ldapsearch($cmd,'Replication Agreement Configuration',$flg,$pwd) if isCreated(true) toc '2:[[',getFile(),'][rda_report][OID Configuration]]' } } =head2 odiprop - $OH/ldap/odi/conf/odi.properties Displays the contents of the F<$ORACLE_HOME/ldap/odi/conf/odi.properties> file. =cut if or(and($AS11,not($INS)),not($AS11)) {pretoc '2:Configuration and Log Files' debug ' Inside OID module, displaying the file \ $OH/ldap/odi/conf/odi.properties' var $fil = catFile($ORACLE_HOME,'ldap','odi','conf','odi.properties') if testFile('r',$fil) {report odiprop write '---+!! Contents of ',encode($fil) if !writeFile($fil) {write '**',encode($fil),' not readable.**%BR%\ May be file permission problems.%BR%\ Permissions are:%BR%' call statFile('b',$fil) write 'User: ',id(),'%BR%' } toc '3:[[',getFile(),'][rda_report][$OH/ldap/odi/conf/odi.properties]]' } # End the section for 11g only if $AS11 unpretoc } =head1 SEE ALSO L =begin credits =over 10 =item RDA 4.4: Wes Root. =item RDA 4.9: Irina Donaldson, Anita Hegde, Satheesan Vettahil. =item RDA 4.12: Raju Channabasappa, Wes Root, Jerry Smith, Satheesan Vettahil. =item RDA 4.15: Greg Cook, Wes Root, Andrew Salt, Ram Sathyanarayan, Hector Viveros. =item RDA 4.22: Hector Viveros. =item RDA 4.24: Ralf Sahlmen. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2012, 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