3 Replies Latest reply on Jun 14, 2018 1:36 PM by Bob Anderson

    Need to fetch "Database name" as DB Instance name or alian name

    Rajat Jain
      Share This:



      By default, ADDM picks the "Database unique name" as DB instance name from srvctl command. But we also want to fetch the "Database Name" from the same command as an additional parameter for all the DB instance discovered. I understand that this value might be duplicate for multiple DB instances in a DB, but as a need of DB team we need to fetch this value as an external parameter.


      I tried writing a TPL for this, but it is not working at all. Like how to get CRS home for below command and how to change
      command depending upon OS, cluster and standalone


      dbname_command := '%crs_home%/bin/srvctl config database -d %db_unique_name%';


      If it is very difficult to write a whole new TPL for fetching this extra parameter, I can think of modifying the OOTB pattern, though it is something we need do every month whenever we apply TKU, but it is ok if it work.


      Please find my TPL below and let me know what changes could be done in it:



      // This is a pattern module containing a pattern for


      // running srvctl and collect db_name for Oracle RDBMS SI.




      tpl 1.14 module Oracle_OracleRDBMS_Set_DB_Name;




      pattern Oracle_OracleRDBMS_Set_DB_Name 1.0




        Simple pattern to run srvctl command and collect db_name for Oracle RDBMS SI.








        origin := "Custom TPL";


      end metadata;






          tags Dbname, OracleRDBMS;


        end overview;






      // command to run


        dbname_command := '%crs_home%/bin/srvctl config database -d %db_unique_name%';


         end constants;






          on ora_si := SoftwareInstance created, confirmed where type = 'Oracle Database Server';


        end triggers;






      //get the host for this SI


           host := model.host(ora_si);


           db_nameraw := discovery.runCommand(host, dbname_command);






      if db_nameraw then


          log.debug("DBname command output: %db_nameraw.result%");


          db_name :=regex.extract(db_nameraw.result, regex "(?m)name: (\S+[^:\s])", raw "\1");


      log.debug("DBname is: %db_name%");


      end if;




      // Write Extracted Value on SI page








      //Define custom field for this Values:




      model.addDisplayAttribute(ora_si, "Database_Name");




      end body;




      end pattern;