<!-- $Header: emdb/sysman/admin/metadata/database.xmlp /st_emdbsa_11.2/36 2011/05/09 23:28:17 mperugu Exp $
   MODIFIED    (MM/DD/YY)
      mperugu   05/04/11 - fix 12405800
      sshastry  06/24/10 - Bug: 9879516
      sresrini  11/25/09 - LRG Problem 4219111
      rtakeish  10/13/09 - bug9014074, insertfailure, privileges, proxyaccount
                           metric are not defined for 11.2 target
      mperugu   10/07/09 - define textIndexStats for 11gR2
      sresrini  09/30/09 - bug 8889374
      sudvarma  09/24/09 - To fix bug-7239916 : performance tune certain metric
                           sqls
      sresrini  09/15/09 - fix streams latency metric
      yemeng    08/31/09 - ER 7044386
      rtakeish  08/28/09 - bug8664860, nmeegd_getmetricdata failed : result has
                           repeating key value in 10.2.0.5
      sjconnol  08/24/09 - change nlsids for ha_dg_target_summary
      pbantis   08/11/09 - Bug 8677212 ha_backup
      rsamaved  08/08/09 - RAC 11.2 to 11.1GC backport
      rgiroux   08/07/09 - fix for bug 8565112; ignore DELAYED OPEN in Missing
                           Media Files metric
      yozhang   07/20/09 - Fix bug 8684208: exclude more users
      mperugu   06/21/09 - enable textIndexStats for 11gR2
      sshastry  06/16/09 - Backport merge from 112SA to 10.3
      manaraya  06/16/09 - Fix bug 7931482
      rimmidi   06/11/09 - Bug fix 8592685
      amahalin  06/02/09 - bug fix 7836472 
      yozhang   05/29/09 - Project 28210: Add edition support
      yemeng    05/22/09 - bug 8532141
      hpalitan  05/19/09 - Include 11R2 for DatabaseVault metrics
      mnihalan  05/18/09 - Fix 8219796
      nzhao     05/08/09 - Fix bug 8305641.
      amahalin  05/04/09 - bug 7836472
      ngade     04/28/09 - fix bug 8271949
      sshastry  04/24/09 - Bug fix: 7208274. Added metric aq_msgs_bufferedqueue
      yemeng    04/07/09 - XbranchMerge yemeng_bug-7554977_dbsa1 from
                           st_emdbsa_11.2
      sudvarma  03/24/09 - To fix bug-8234380 - Introducing esm_dirObjUsersWithExeAndOtherPrivs
                           and esm_publicHavingExePrivOnDirObj config metric which inturn
                           will be used Em security policies
      yozhang   03/06/09 - Fix RFI bug 8242774: perf issues
      ajdsouza  03/04/09 - convert hasmanaged and resource_name to metrics
      manaraya  02/23/09 - Bug 7931482
      sshastry  02/20/09 - Bug Fix: 7591499
      yozhang   02/18/09 - Fix bug 7599693: metrics for 9.2DB
      ngade     02/18/09 - add observer metric 11gR2
      ngade     02/17/09 - Code slap 10.2.0.5.0 -> 11.2 round 2
      yozhang   02/17/09 - Fix bug 8216584: remove vtempfiles for 11.2DB
      mnihalan  02/09/09 - Fix bug 7514386
      yozhang   02/05/09 - Fix bug 8216584
      hpalitan  02/02/09 - Add 11gR2 for Database Vault metrics
      amahalin  01/28/09 - Database Vault xbranchMerge
      hpalitan  01/27/09 - Add Database Vault Metrics
      sshastry  01/21/09 - Streams forward merge from 10.2.0.5.0GC to 11.2 SA
      yemeng    12/22/08 - add key sql profile
      sadattaw  02/17/10 - enabling streams server generated alerts for 11gR2
      rtakeish  02/02/10 - bug9342695, add openmode instance property to
                           pushdescriptors for aqmetrics fetchlet
      rtakeish  01/22/10 - bug8934580, gc query is running forever
      pbantis   01/20/10 - ha_flashrecovery to use v$recovery_file_dest.
      hpalitan  01/15/10 - Bug #9169817
      mnihalan  01/13/10 - Fix bug 9274612
      keiwong   01/13/09 - add db replay client metric
      pardutta  12/03/08 - Merging AQ monitoring and Streams metric definitions
                           from 10205.
      pbantis   10/17/08 - Fix typo.
      yozhang   09/24/08 - Fix bug 6510791 in 11.2DBC
      prjaiswa  09/24/08 - 
      mmootha   09/22/08 - 
      prjaiswa  08/18/08 - bug 6733346
      pbantis   08/15/08 - Bug 7215327 ha_backup query.
      ngade     08/12/08 - Code slap 10.2.0.5GC -> 112SA
      ngade     08/06/08 - Code Slap 10.2.0.5GC -> 11.2SA
      rimmidi   08/04/08 - 
      mappusam  07/30/08 - Backport mappusam_bug-6778532 from main
      sradhakr  07/26/08 - RFI Backport of Bug#6758113 to 10205
      rimmidi   07/17/08 - 
      anosriva  07/01/08 - 
      mpawelko  06/16/08 - Add 11.2 editions support
      pbantis   06/12/08 - Bug 5458217 update ha_recovery.
      yozhang   06/12/08 - Fix RFI bug 7044772
      sshastry  06/04/08 - Forward merge of streams/aq metrics from 11.1GC to
                           11.2
      sresrini  05/28/08 - To add version condition for text manager metric
      sshastry  05/20/08 - Backport streams/aq metrics from 11.1GC to 10.2.0.5GC
      rsamaved  05/08/08 - add 11gR2 version
      rimmidi   05/06/08 - Code slap from 11GC to 10.2.0.5
      sradhakr  05/05/08 - Backport sradhakr_bug-6758113 from main
      dchakumk  03/10/08 - XbranchMerge dchakumk_6752_xbmsrc from
                           st_emdbsa_11.1
      gallison  10/17/07 - Bug 6504943
      jsoule    10/04/07 - add ADR sweep support
      manosing  09/17/07 - 6411390
      yozhang   09/14/07 - fix db_recTablespaceSettings metrics
      gallison  08/08/07 - Add columns to ha tables
      ngade     07/25/07 - fix bug 4880147
      rsamaved  07/06/07 - move UDM metrics from instancel.xmlp for RAC support
      keiwong   04/21/07 - fix bug 5898320
      manosing  04/06/07 - modify installAndDemoAcccounts to use sys.user$
      mappusam  03/26/07 - XbranchMerge mappusam_bug-5770438 from main
      loliu     03/25/07 - Changed adrviewer.pl to use target ADR base and home
                           from environment
      mnihalan  03/16/07 - Fix bug 5937135
      ngade     03/16/07 - Backport ngade_bug-5172489 from main
      mappusam  03/13/07 - Backport mappusam_bug-5770438 from main
      pbantis   02/28/07 - Pre-11g for ha_recovery.
      ganessub  02/08/07 - Added Text Statistics metric.
      mappusam  02/08/07 - Bug-5770438 Fix
      manosing  01/12/07 - XbranchMerge manosing_lastpols from main
      manosing  01/10/07 - flood control for NT policies
      sshastry  01/09/07 - Changes to add streams server generated alerts
      sjconnol  12/14/06 - add cols to ha_flashrecovery
      manosing  11/07/06 - adding metric for 10.2.0.4 policies
      manosing  11/07/06 - adding metric for 10.2.0.4 policies
      dsukhwal  10/30/06 - add audit insert failure metric
      hopark    10/27/06 - use double quote to pass argument for adrviewer
                           in order to make it on NT
      dsukhwal  10/12/06 - add proxy account metric
      jsoule    10/10/06 - add 11g support
      hopark    09/13/06 - use single quote to pass argument for adrviewer
      ngade     09/11/06 - add observer 11g metric
      mappusam  08/31/06 - Bug-5300799 Fix
      jsoule    08/29/06 - add 11gR1 version
      sjconnol  08/18/06 - ha_dg_target_summary metric
      mappusam  08/06/06 - Backport mappusam_bug-5230259 from main
      jsoule    08/06/06 - support versions > 10gR2 
      mappusam  07/25/06 - Adding FROM keyword in the tbsp query which missed 
                           out part of the bug-5230259 Fix. 
      rmadampa  07/24/06 - ER 5259286: chk for pwd complexity function set 
      sjconnol  07/24/06 - DG FSFO 11g metric
      rmadampa  07/16/06 - fix bug 5257531: replace the list of accounts with 
                           the list used by DPS tool 
      hopark    06/01/06 - add adr_viewer metric 
      mappusam  06/07/06 - Bug-5230259 Fix
      ngade     05/23/06 - fix COMPUTE_EXPR for fsfo metric 
      lhan      04/28/06 - move UDM from instance.xmlp to support RAC
      jsoule    03/28/06 - support versions > 10gR2 
      mmootha   03/14/06 - 4759988
      mnihalan  11/21/05 - Fix bug 4531630 - problemTbsp add NLSID 
      hying     09/22/05 - clear block corruption 
      hying     09/07/05 - Datafiles with Error 
      hying     08/22/05 - ha_recovery fix 
      kramarat  08/11/05 - Hide the metric DGPrimaryDBName 
      gallison  08/13/05 - Fix 4547507 
      ysun      08/09/05 - workaround for bug 4158316
      kramarat  07/29/05 - Convert DGPrimaryDBName into a metric 
      dsukhwal  07/27/05 - perl fetchlet for ESA reports 
      kramarat  07/15/05 - New metric for observer 
      xshen     07/15/05 - fixing bug 4453429 - rounding mem data 
      dkjain    07/11/05 - Fixed bug 4422016 
      rreilly   07/12/05 - bug 4145603 fix tbspAllocation UNDO support 
      dkjain    07/06/05 - Fixing the ValidMidTierVersions position for ESA 
                           metrics 
      dkjain    07/06/05 - dbLink invalid for 9iR2 
      dsukhwal  07/04/05 - ESA support flood control for all policies 
      dsukhwal  07/01/05 - ESA reports complete path 
      rreilly   07/01/05 - bug 4294495 seg extents, loc tbsp with alloc of USER
      dkjain    06/23/05 - Fixed the bug-4335841(Add ValidMidTierVersions )
      gallison  06/15/05 - Fix FSFO metric 
      rreilly   06/13/05 - bug 3377171 add not in and in to where clause
      jsoule    05/31/05 - update metadata for keyonly, nonthresholded 
      dsukhwal  05/20/05 - Adding support for limiting uploaded rows
      xshen     05/18/05 - config RAW metrics compatibility 
      pbantis   05/16/05 - Fix dup key for mgmt_ha_rman_config. 
      pbantis   05/02/05 - ValidMidTierVersions.
      pbantis   05/02/05 - Add CustomTableMapper for mgmt_ha_backup.
      sresrini  04/22/05 - make config false for streams_processes_count metric
      pbantis   04/21/05 - Comment out CustomTableMapper for mgmt_ha_backup.
      pbantis   04/21/05 - Remove REP_TABLE_NAME for mgmt_ha_backup.
      rreilly   04/14/05 - add audit_failed_logins_historical metric
      gallison  04/06/05 - Make dg columns transient
      dkjain    03/28/05 - Fixed bug-4233284
      kramarat  03/24/05 - change HA metric text
      rreilly   03/18/05 - remove controlfiles_size again
      mnihalan  03/16/05 - Change segment_advisor_count
      pbantis   03/15/05 - Dynamic SQL for ha_flashrecovery and ha_recovery. 
      sshastry  03/02/05 - Changes to add Streams topology metrics 
      gallison  02/25/05 - rename dg metrics
      dkjain    02/21/05 - Added 10gR2 Metric version for unlimited login attempt and installdemoacc
      kashukla  02/21/05 - changes to ESA metrics 
      kashukla  02/21/05 - changes to ESA metrics 
      ysun      02/16/05 - update for with split
      mnihalan  01/17/05 - Fix bug 4122210 exclude TSMSYS tablespace 
      gallison  12/01/04 - Update DG Metric 
      gallison  11/13/04 - Change PDL to RNA 
      rreilly   11/11/04 - add tbspAllocation metric 
      rreilly   11/11/04 - bug 3377171 Invalid Objects - filter out sys 
                           invalid objects 
      rreilly   11/04/04 - bug 3978294 db_tablespaces fix col order 
      gallison  10/29/04 - DG support 
      pbantis   10/15/04 - Remove unused HA columns. 
      sbadrina  10/14/04 -  bug 3950666 - fix duplicate values for key cfsize 
                           col in SH due to multiplexed CF 
      pbantis   10/01/04 - Add ha_recovery_usage and ha_flashback_info. 
      pbantis   09/17/04 - Update ha_backup metric. 
      sbadrina  09/09/04 - change the query for db_controlfiles_size for 10gR2 
      rreilly   08/12/04 - bug 3581777 3377171 
      rreilly   08/12/04 - bug 3264676 remove Invalid Objects metric 
      rreilly   08/02/04 - enh 3062024 problemTbsp bytesFree support 
      ajdsouza  07/22/04 - changed the db_datafiles, db_redologs, db_controlfiles to oslinetoken executions
      rreilly   07/16/04 - bug 3548431 db_recSegmentSettings_sysseg perf fix 
      ychan     07/09/04 - Remove 10gBeta 
      rreilly   06/26/04 - add free space metric 
      mnihalan  06/25/04 - Segment Advisor Recommendations 
      blivshit  06/29/04 - move hidden metrics back to instance, since it 
                           needs instance variables 
      blivshit  06/28/04 - move hidden metrics to database.xmlp so rac can see 
                           them 
      jstone    06/11/04 - composite key for db_FeatureUsage (3669601) 
      jochen    05/26/04 - Add 10gR2 
      sbadrina  05/24/04 - comment out cfsize for 10gR1 
      sbadrina  05/06/04 - add db_controlfiles_size and used col to db_tablespaces
      jochen    04/30/04 - Add minSegSize to wastedSpace
      ysun      04/29/04 - ysun_metadata_split
      ysun      04/26/04 - creation
-->

	<!--
  ======================================================================
  == Category:         Tablespaces Full - 9i and earlier
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="problemTbsp" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="pre8;8i;8iR2;9i;9iR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="problemTbsp">Tablespaces Full</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="tbspName">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="pctUsed" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="pctUsed">Tablespace Space Used (%)</Label>
 					<Unit NLSID="em__sys__standard_percent">%</Unit>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="bytesFree" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="bytesFree">Tablespace Free Space (MB)</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
        %perlBin%/perl %scriptsDir%/fullTbsp.pl
      </Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_TABLESPACE_CONDITION_CLAUSE" SCOPE="USER" OPTIONAL="TRUE">targetTbspCondition</Property>
			<Property NAME="ENVEM_TARGET_SEGMENT_CONDITION_CLAUSE" SCOPE="USER" OPTIONAL="TRUE">targetSegCondition</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Tablespaces Full - 10i - locally managed
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="problemTbsp" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="problemTbsp">Tablespaces Full</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="tbspName">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="pctUsed" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="pctUsed">Tablespace Space Used (%)</Label>
 					<Unit NLSID="em__sys__standard_percent">%</Unit>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="10gR1"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT tablespace_name, used_percent FROM sys.dba_tablespace_usage_metrics, v$parameter p
       WHERE p.name='statistics_level' and p.value!='BASIC'
			]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
			<Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
			<Property NAME="KeyColumn" SCOPE="GLOBAL">name</Property>
		</PushDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Tablespaces Full By Size and % - 10gR2 - locally managed
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  == Added by rreilly on 16-Jun-2004
  ======================================================================
    -->
	<Metric NAME="problemTbsp" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="problemTbsp">Tablespaces Full</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="tbspName">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="pctUsed" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="pctUsed">Tablespace Space Used (%)</Label>
 					<Unit NLSID="em__sys__standard_percent">%</Unit>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="bytesFree" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="bytesFree">Tablespace Free Space (MB)</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT m.tablespace_name,
       m.used_percent,  
       (m.tablespace_size - m.used_space)*t.block_size/1024/1024 mb_free
 FROM  dba_tablespace_usage_metrics m, dba_tablespaces t, v$parameter p
 WHERE p.name='statistics_level' and p.value!='BASIC'
   AND t.tablespace_name = m.tablespace_name
			]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
			<Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
			<Property NAME="KeyColumn" SCOPE="GLOBAL">name</Property>
		</PushDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Tablespaces Full - 10i - dictionary managed
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="problemTbsp10iDct" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="problemTbsp10iDct">Tablespaces Full (dictionary managed)</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="tbspName">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="pctUsed" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="pctUsed10iDct">Tablespace Space Used (%) (dictionary managed)</Label>
 					<Unit NLSID="em__sys__standard_percent">%</Unit>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="bytesFree" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="bytesFree10iDct">Tablespace Free Space (MB) (dictionary managed)</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
        %perlBin%/perl %scriptsDir%/fullTbsp.pl
      </Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_TABLESPACE_CONDITION_CLAUSE" SCOPE="USER" OPTIONAL="TRUE">targetTbspCondition</Property>
			<Property NAME="ENVEM_TARGET_SEGMENT_CONDITION_CLAUSE" SCOPE="USER" OPTIONAL="TRUE">targetSegCondition</Property>
			<Property NAME="ENVEM_TARGET_EXTENT_MGMT_CONDITION_CLAUSE" SCOPE="GLOBAL">='DICTIONARY'</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Tablespaces With Problem Segments
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="problemSegTbsp" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="problemSegTbsp">Tablespaces With Problem Segments</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="tbspName">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="segsChunkSmlCnt" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="segsChunkSmlCnt">Segments Not Able to Extend Count</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="segsChunkSmlMessage" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="segsChunkSmlMessage">Segments Not Able to Extend</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="segsMaxExtsCnt" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="segsMaxExtsCnt">Segments Approaching Maximum Extents Count</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="segsMaxExtsMessage" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="segsMaxExtsMessage">Segments Approaching Maximum Extents</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
        %perlBin%/perl %scriptsDir%/problemTbsp.pl
      </Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_TABLESPACE_CONDITION_CLAUSE" SCOPE="USER" OPTIONAL="TRUE">targetTbspCondition</Property>
			<Property NAME="ENVEM_TARGET_SEGMENT_CONDITION_CLAUSE" SCOPE="USER" OPTIONAL="TRUE">targetSegCondition</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Recommended User Settings
  == Collection Level: Recommended
  == Purpose:          Storage Advisor
  ======================================================================
  -->
	<Metric NAME="db_recUserSettings" TYPE="RAW" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<TableDescriptor TABLE_NAME="mgmt_db_recUserSettings_ecm">
			<ColumnDescriptor NAME="name" COLUMN_NAME="user_name" TYPE="STRING" IS_KEY="TRUE"/>
			<ColumnDescriptor NAME="problem" COLUMN_NAME="problem_code" TYPE="NUMBER" IS_KEY="TRUE">
    <!-- Numeric values correspond to specific problems and recommendations:        -->
    <!--   1    User uses permanent tablespace as a temporary tablespace            -->
    <!--   2    Non-system user uses system tablespace as a default tablespace      -->
			</ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace" COLUMN_NAME="tablespace" TYPE="STRING" IS_KEY="FALSE"/>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT username, 1, temporary_tablespace
  FROM dba_users u, dba_tablespaces t
  WHERE u.temporary_tablespace = t.tablespace_name and t.contents != 'TEMPORARY'
  AND u.account_status = 'OPEN'
UNION ALL
SELECT username, 2, default_tablespace
  FROM dba_users
  WHERE username NOT IN ('MGMT_VIEW','OUTLN','ANONYMOUS','DMSYS','LBACSYS','WKPROXY','TRACESVR','SCOTT','ADAMS','BLAKE','CLARK','JONES','HR','PM','OE','SH','IX')
    AND username NOT IN ('CTXSYS','DMSYS','MDSYS','OLAPSYS','ORDPLUGINS','ORDSYS','PERFSTAT','SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM','WKSYS','WMSYS','XDB')
    AND username NOT LIKE 'FLOWS!_%' escape '!'
    AND account_status = 'OPEN'
    AND default_tablespace in ('SYSTEM', 'SYSAUX')
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Recommended Tablespace Settings
  == Collection Level: Recommended
  == Purpose:          Storage Advisor
  ======================================================================
  -->
	<Metric NAME="db_recTablespaceSettings" TYPE="RAW" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<TableDescriptor TABLE_NAME="mgmt_db_recTSSettings_ecm">
			<ColumnDescriptor NAME="tablespace" COLUMN_NAME="tablespace" TYPE="STRING" IS_KEY="TRUE"/>
			<ColumnDescriptor NAME="problem" COLUMN_NAME="problem_code" TYPE="NUMBER" IS_KEY="TRUE">
    <!-- Numeric values correspond to specific problems and recommendations:        -->
    <!--   1    Permanent locally managed tablespace using MANUAL seg-space mgmt    -->
    <!--   2    Tablespace is dictionary-managed                                    -->
    <!--   3    Tablespace contains both rollback and data segments                 -->
    <!--        NOTE: Overlaps with Config check for rollback segs in SYSTEM        -->
    <!--   4    Tablespace has non-zero PctIncrease value                           -->
    <!--   5    Tablespace's NextExtent not a multiple of InitialExtent             -->
    <!--   6    Default Temporary Tablespace is set to a system tablespace          -->
    <!--   7    Default Permanent Tablespace is set to a system tablespace          -->
			</ColumnDescriptor>
			<ColumnDescriptor NAME="value1" COLUMN_NAME="value1" TYPE="NUMBER" IS_KEY="FALSE"/>
			<ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="NUMBER" IS_KEY="FALSE"/>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT tablespace_name, 
       decode(extent_management, 'LOCAL', 1, 
                                 'DICTIONARY', 2),
       0, 0
  FROM dba_tablespaces
 WHERE tablespace_name NOT IN ('SYSTEM', 'SYSAUX')
   AND (extent_management='DICTIONARY'
        AND contents='PERMANENT')
    OR (extent_management='LOCAL'
        AND contents='PERMANENT'
        AND segment_space_management='MANUAL')
UNION ALL
SELECT distinct(property_value),
       decode(property_name, 'DEFAULT_TEMP_TABLESPACE', 6,
                             'DEFAULT_PERMANENT_TABLESPACE', 7),
       0,0
  FROM database_properties
 WHERE (property_name='DEFAULT_TEMP_TABLESPACE' 
        OR  property_name='DEFAULT_PERMANENT_TABLESPACE')
   AND (property_value in('SYSTEM','SYSAUX') OR property_value IS NULL)
UNION ALL
SELECT * FROM (
  SELECT tablespace, 3, count(rbs) "RBS_COUNT", count(ds) "DS_COUNT" FROM (
    SELECT t.name "TABLESPACE",
           decode(s.type#, 1, un.name, null) "RBS",
           decode(s.type#, 1, null, s.file#*s.block#) "DS"
    FROM sys.ts$ t, sys.undo$ un, sys.seg$ s
    WHERE t.ts# = s.ts#
      AND un.file#(+) = s.file#
      AND un.block#(+) = s.block#
      AND un.name(+) != 'SYSTEM'
      AND s.type# != 10)
    GROUP BY tablespace)
WHERE rbs_count > 0 AND ds_count > 0
UNION ALL
SELECT tablespace_name, 4, 0, 0
  FROM dba_tablespaces
  WHERE pct_increase != 0 AND extent_management = 'DICTIONARY'
UNION ALL
SELECT tablespace_name, 5, 0, 0
  FROM dba_tablespaces
  WHERE extent_management = 'DICTIONARY'
  AND initial_extent > 0
  AND MOD(next_extent, initial_extent) != 0
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Recommended Segment Settings - Extent Growth Policy Violation
  == Collection Level: Recommended
  == Purpose:          Storage Advisor
  ======================================================================
  -->
	<Metric NAME="db_recSegmentSettings" TYPE="RAW" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<TableDescriptor TABLE_NAME="mgmt_db_recSegmentSettings_ecm">
			<ColumnDescriptor NAME="obj_type" COLUMN_NAME="obj_type" TYPE="NUMBER" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_type">Object Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_owner" COLUMN_NAME="obj_owner" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_owner">Object Owner</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_name" COLUMN_NAME="obj_name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_name">Object Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_partition" COLUMN_NAME="obj_partition" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_partition">Partition</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_lob_col" COLUMN_NAME="obj_lob_col" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_lob_col">LOB Column</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="seg_type" COLUMN_NAME="segment_type" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_segment_type">Segment Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace" COLUMN_NAME="tablespace" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_recSegmentSettings_tablespace">Tablespace</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="recommendation" COLUMN_NAME="problem_code" TYPE="NUMBER" IS_KEY="TRUE">
				<!-- Numeric value is bitwise OR of specific problems:            -->
				<!--   1    PCTINCREASE is not 0                                  -->
				<!--   2    NEXT not multiple of INITIAL                          -->
				<Display>
					<Label NLSID="db_recSegmentSettings_problem_code">Problem</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
                <!--
Query to get segments with settings that violate best-practices
recommendations.  Result columns are:
1. Object type ::=
      1 (Table) | 2 (Index) | 3 (Cluster)
2. Object schema
3. Object name
4. Partition name or ' ' if not partitioned
5. LOB Column name or ' ' if not a LOB column
6. Segment type (Number):
   1       TABLE
   2       INDEX
   3       TABLE PARTITION
   4       INDEX PARTITION
   5       IOT OVERFLOW
   6       LOB INDEX (not used)
   7       LOB COLUMN
   8       LOB PARTITION
   9       TABLE SUBPARTITION
   10      INDEX SUBPARTITION
   11      LOB SUBPARTITION (not used, but should be)
   12      CLUSTER
   13      IOT OVERFLOW PARTITION
7. Name of tablespace containing the segment (String)
8. Violations (Number) - Bitwise OR of problem codes:
   1       PCTINCREASE not 0
   2       NEXTEXTENT not multiple of INITIALEXTENT

Index of Queries in the Union
1. Obj type=1, seg type=1, no ptn or LOB column:
   Nonpartitioned tables.
2. Obj type=2, seg type=2, no ptn or LOB column:
   Nonpartitioned indexes
3. Obj type=3, seg type=12, no ptn or LOB column:
   Clusters
4. Obj type=1, seg type=1, no ptn or LOB column:
   Non-partitioned IOTs (returned as type TABLE)
5. Obj type=1, seg type=3, ptn, no LOB column:
   Table partitions
6. Obj type=2, seg type=4, ptn, no LOB column:
   Index partitions (no LOB or IOT partitions)
7. Obj type=1, seg type=5, no ptn or LOB column:
   IOT overflow segments
8. Obj type=1, seg type=8, no ptn, LOB column:
   Unpartitioned LOB columns
9. Obj type=1, seg type=3, ptn, no LOB column:
   IOT Partitions (returned as type TABLE PARTITION)
10. Obj type=1, seg type=13, ptn, no LOB column:
    IOT Overflow partitions
11. Obj type=1, seg type=8, ptn, LOB column:
    LOB column partitions (The Final Frontier)
12. Obj type=1, seg type=9, ptn, no LOB column:
    Table subpartitions
13. Obj type=2, seg type=10, ptn, no LOB column:
    Index subpartitions
                -->
		<QueryDescriptor FETCHLET_ID="SQL">
                 <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1"/>
	         </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT * FROM (
SELECT /*+ ordered */  1 "OBJECT_TYPE", u.name "USER_NAME", o.name "OBJECT_NAME", ' ' "PARTITION",
  ' ' "LOB_COLUMN", 1 "SEG_TYPE", tts.name "TABLESPACE",
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2) "PROBLEM"
FROM
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tab$ t, sys.seg$ s, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = t.obj#
  AND t.ts# = tts.ts#
  AND t.file# = s.file#
  AND t.block# = s.block#
  AND t.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
  AND decode (bitand (t.property, 1), 1, 1, 0) = 0
  AND decode (bitand (t.property, 32), 32, 1, 0) = 0
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 0
  AND decode (bitand (t.property, 1024), 1024, 1, 0) = 0
UNION ALL
SELECT  /*+ ordered */ 2, u.name, o.name, ' ', ' ', 2, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM  
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.ind$ i, sys.seg$ s,sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = i.obj#
  AND i.ts# = tts.ts#
  AND i.file# = s.file#
  AND i.block# = s.block#
  AND i.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
  AND decode (bitand (i.property, 2), 2, 1, 0) = 0
  AND i.type# not in (4, 8)
UNION ALL
SELECT /*+ ordered */  3, u.name, o.name, ' ', ' ', 12, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.clu$ c, sys.seg$ s, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = c.obj#
  AND c.ts# = tts.ts#
  AND c.file# = s.file#
  AND c.block# = s.block#
  AND c.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tn.name, ' ', ' ', 1, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.ind$ i, sys.seg$ s, sys.tab$ t, sys.obj$ tn,sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = i.obj#
  AND i.ts# = tts.ts#
  AND i.file# = s.file#
  AND i.block# = s.block#
  AND i.ts# = s.ts#
  AND i.bo# = tn.obj#
  AND tn.obj# = t.obj#
  AND decode (bitand (i.property, 2), 2, 1, 0) = 0
  AND i.type# = 4
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */  1, u.name, o.name, o.subname, ' ', 3, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tabpart$ tp, sys.seg$ s, sys.tab$ t, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = tp.obj#
  AND tp.ts# = tts.ts#
  AND tp.file# = s.file#
  AND tp.block# = s.block#
  AND tp.ts# = s.ts#
  AND t.obj# = tp.bo#
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 0
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 2, u.name, o.name, o.subname, ' ', 4, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.indpart$ ip, sys.seg$ s, sys.ind$ i, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = ip.obj#
  AND ip.ts# = tts.ts#
  AND ip.file# = s.file#
  AND ip.block# = s.block#
  AND ip.ts# = s.ts#
  AND i.obj# = ip.bo#
  AND decode (bitand (i.property, 2), 2, 1, 0) = 1
  AND i.type# not in (4, 8)
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tn.name, ' ', ' ', 5, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tab$ t, sys.seg$ s, sys.tab$ iot,sys.obj$ tn, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = t.obj#
  AND t.ts# = tts.ts#
  AND t.file# = s.file#
  AND t.block# = s.block#
  AND t.ts# = s.ts#
  AND tn.obj# = t.bobj#
  AND tn.obj# = iot.obj#
  AND decode (bitand (t.property, 32), 32, 1, 0) = 0
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 1
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */  1, u.name, tn.name, ' ',
  decode(bitand(c.property, 1), 1, substr(ac.name,0,500), c.name), 8, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM    
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.lob$ l, sys.seg$ s, sys.col$ c, sys.attrcol$ ac, sys.obj$ tn, sys.user$ u
WHERE tn.owner# = u.user#
  AND tn.obj# = c.obj#
  AND c.obj# = l.obj#
  AND c.intcol# = l.intcol#
  AND l.ts# = tts.ts#
  AND l.file# = s.file#
  AND l.block# = s.block#
  AND l.ts# = s.ts#
  AND c.obj# = ac.obj#(+)
  AND c.intcol# = ac.intcol#(+)
  AND bitand(c.property,32768) != 32768
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tn.name, o.subname, ' ', 3, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.indpart$ ip, sys.seg$ s, sys.ind$ i, sys.obj$ tn, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = ip.obj#
  AND ip.ts# = tts.ts#
  AND ip.file# = s.file#
  AND ip.block# = s.block#
  AND ip.ts# = s.ts#
  AND i.obj# = ip.bo#
  AND decode (bitand (i.property, 2), 2, 1, 0) = 1
  AND i.type# = 4
  AND i.bo# = tn.obj#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tbo.name, o.subname, ' ', 13, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM  
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tabpart$ tp, sys.seg$ s, sys.tab$ t, sys.obj$ tbo, sys.obj$ o, sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = tp.obj#
  AND tp.ts# = tts.ts#
  AND tp.file# = s.file#
  AND tp.block# = s.block#
  AND tp.ts# = s.ts#
  AND t.obj# = tp.bo#
  AND decode (bitand (t.property, 32), 32, 1, 0) = 1
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 1
  AND tbo.obj# = t.bobj#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */ 1, u.name, tbo.name, po.subname,
    decode(bitand(c.property, 1), 1, substr(a.name,0,500), c.name), 8,  tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.lobfrag$ lf, sys.seg$ s, sys.lob$ l, sys.partobj$ pobj,
  sys.obj$ po, sys.obj$ tbo, sys.attrcol$ a, sys.col$ c, sys.user$ u
WHERE tbo.owner# = u.user#
  AND pobj.obj# = tbo.obj#
  AND lf.ts# = tts.ts#
  AND lf.file# = s.file#
  AND lf.block# = s.block#
  AND lf.ts# = s.ts#
  AND mod(pobj.spare2, 256) = 0
  AND tbo.obj# = c.obj#
  AND c.obj# = l.obj#
  AND c.intcol# = l.intcol#
  AND l.lobj# = lf.parentobj#
  AND lf.tabfragobj# = po.obj#
  AND bitand(c.property,32768) != 32768
  AND c.obj# = a.obj#(+)
  AND c.intcol# = a.intcol#(+)
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */ 1, u.name, bo.name, o.subname, ' ', 9, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tabsubpart$ tsp,sys.seg$ s, sys.obj$ bo,sys.obj$ o,sys.user$ u
WHERE o.owner# = u.user#
  AND o.obj# = tsp.obj#
  AND bo.owner# = o.owner#
  AND bo.name = o.name
  AND bo.type# = 2
  AND tsp.ts# = tts.ts#
  AND tsp.file# = s.file#
  AND tsp.block# = s.block#
  AND tsp.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */ 2, u.name, bo.name, o.subname, ' ', 10, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM  
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.indsubpart$ isp, sys.seg$ s, sys.user$ u,  sys.obj$ o, sys.obj$ bo
WHERE o.owner# = u.user#
  AND o.obj# = isp.obj#
  AND bo.owner# = o.owner#
  AND bo.name = o.name
  AND bo.type# = 1
  AND isp.ts# = tts.ts#
  AND isp.file# = s.file#
  AND isp.block# = s.block#
  AND isp.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
) 
where USER_NAME NOT IN ('MGMT_VIEW','OUTLN','ANONYMOUS','DMSYS','LBACSYS','WKPROXY','TRACESVR','SCOTT','ADAMS','BLAKE','CLARK','JONES','HR','PM','OE','SH','IX')
  AND USER_NAME NOT IN ('CTXSYS','DMSYS','MDSYS','OLAPSYS','ORDPLUGINS','ORDSYS','PERFSTAT','SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM','WKSYS','WMSYS','XDB')
  AND USER_NAME NOT LIKE 'FLOWS!_%' escape '!'
  AND rownum < 201
  AND LENGTH(lob_column) <= 30
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
		<ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
		</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT * FROM (
SELECT /*+ ordered */  1 "OBJECT_TYPE", u.name "USER_NAME", o.name "OBJECT_NAME", ' ' "PARTITION",
  ' ' "LOB_COLUMN", 1 "SEG_TYPE", tts.name "TABLESPACE",
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2) "PROBLEM"
FROM
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tab$ t, sys.seg$ s, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = t.obj#
  AND t.ts# = tts.ts#
    AND t.file# = s.file#
    AND t.block# = s.block#
    AND t.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
    AND decode (bitand (t.property, 1), 1, 1, 0) = 0
    AND decode (bitand (t.property, 32), 32, 1, 0) = 0
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 0
    AND decode (bitand (t.property, 1024), 1024, 1, 0) = 0
 UNION ALL
SELECT  /*+ ordered */ 2, u.name, o.name, ' ', ' ', 2, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM  
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.ind$ i, sys.seg$ s,sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = i.obj#
  AND i.ts# = tts.ts#
    AND i.file# = s.file#
    AND i.block# = s.block#
    AND i.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
    AND decode (bitand (i.property, 2), 2, 1, 0) = 0
    AND i.type# not in (4, 8)
 UNION ALL
SELECT /*+ ordered */  3, u.name, o.name, ' ', ' ', 12, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.clu$ c, sys.seg$ s, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = c.obj#
  AND c.ts# = tts.ts#
    AND c.file# = s.file#
    AND c.block# = s.block#
    AND c.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
 UNION ALL
SELECT  /*+ ordered */ 1, u.name, tn.name, ' ', ' ', 1, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.ind$ i, sys.seg$ s, sys.tab$ t, sys."_CURRENT_EDITION_OBJ" tn,sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = i.obj#
  AND i.ts# = tts.ts#
    AND i.file# = s.file#
    AND i.block# = s.block#
    AND i.ts# = s.ts#
    AND i.bo# = tn.obj#
    AND tn.obj# = t.obj#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 0
    AND i.type# = 4
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
 UNION ALL
SELECT /*+ ordered */  1, u.name, o.name, o.subname, ' ', 3, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tabpart$ tp, sys.seg$ s, sys.tab$ t, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = tp.obj#
  AND tp.ts# = tts.ts#
  AND tp.file# = s.file#
  AND tp.block# = s.block#
  AND tp.ts# = s.ts#
  AND t.obj# = tp.bo#
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 0
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 2, u.name, o.name, o.subname, ' ', 4, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.indpart$ ip, sys.seg$ s, sys.ind$ i, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = ip.obj#
  AND ip.ts# = tts.ts#
  AND ip.file# = s.file#
  AND ip.block# = s.block#
  AND ip.ts# = s.ts#
  AND i.obj# = ip.bo#
  AND decode (bitand (i.property, 2), 2, 1, 0) = 1
  AND i.type# not in (4, 8)
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tn.name, ' ', ' ', 5, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tab$ t, sys.seg$ s, sys.tab$ iot,sys."_CURRENT_EDITION_OBJ" tn, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = t.obj#
  AND t.ts# = tts.ts#
  AND t.file# = s.file#
  AND t.block# = s.block#
  AND t.ts# = s.ts#
  AND tn.obj# = t.bobj#
  AND tn.obj# = iot.obj#
  AND decode (bitand (t.property, 32), 32, 1, 0) = 0
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 1
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */  1, u.name, tn.name, ' ',
  decode(bitand(c.property, 1), 1, substr(ac.name,0,500), c.name), 8, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM    
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.lob$ l, sys.seg$ s, sys.col$ c, sys.attrcol$ ac, sys."_CURRENT_EDITION_OBJ" tn, sys.user$ u
WHERE tn.owner# = u.user#
  AND u.type# !=2
  AND tn.obj# = c.obj#
  AND c.obj# = l.obj#
  AND c.intcol# = l.intcol#
  AND l.ts# = tts.ts#
  AND l.file# = s.file#
  AND l.block# = s.block#
  AND l.ts# = s.ts#
  AND c.obj# = ac.obj#(+)
  AND c.intcol# = ac.intcol#(+)
  AND bitand(c.property,32768) != 32768
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tn.name, o.subname, ' ', 3, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.indpart$ ip, sys.seg$ s, sys.ind$ i, sys."_CURRENT_EDITION_OBJ" tn, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = ip.obj#
  AND ip.ts# = tts.ts#
  AND ip.file# = s.file#
  AND ip.block# = s.block#
  AND ip.ts# = s.ts#
  AND i.obj# = ip.bo#
  AND decode (bitand (i.property, 2), 2, 1, 0) = 1
  AND i.type# = 4
  AND i.bo# = tn.obj#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT  /*+ ordered */ 1, u.name, tbo.name, o.subname, ' ', 13, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM  
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tabpart$ tp, sys.seg$ s, sys.tab$ t, sys."_CURRENT_EDITION_OBJ" tbo, sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = tp.obj#
  AND tp.ts# = tts.ts#
  AND tp.file# = s.file#
  AND tp.block# = s.block#
  AND tp.ts# = s.ts#
  AND t.obj# = tp.bo#
  AND decode (bitand (t.property, 32), 32, 1, 0) = 1
  AND decode (bitand (t.property, 64), 64, 1, 0) = 0
  AND decode (bitand (t.property, 512), 512, 1, 0) = 1
  AND tbo.obj# = t.bobj#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */ 1, u.name, tbo.name, po.subname,
    decode(bitand(c.property, 1), 1, substr(a.name,0,500), c.name), 8,  tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.lobfrag$ lf, sys.seg$ s, sys.lob$ l, sys.partobj$ pobj,
  sys."_CURRENT_EDITION_OBJ" po, sys."_CURRENT_EDITION_OBJ" tbo, sys.attrcol$ a, sys.col$ c, sys.user$ u
WHERE tbo.owner# = u.user#
  AND u.type# !=2
  AND pobj.obj# = tbo.obj#
  AND lf.ts# = tts.ts#
  AND lf.file# = s.file#
  AND lf.block# = s.block#
  AND lf.ts# = s.ts#
  AND mod(pobj.spare2, 256) = 0
  AND tbo.obj# = c.obj#
  AND c.obj# = l.obj#
  AND c.intcol# = l.intcol#
  AND l.lobj# = lf.parentobj#
  AND lf.tabfragobj# = po.obj#
  AND bitand(c.property,32768) != 32768
  AND c.obj# = a.obj#(+)
  AND c.intcol# = a.intcol#(+)
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */ 1, u.name, bo.name, o.subname, ' ', 9, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM 
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.tabsubpart$ tsp,sys.seg$ s, sys."_CURRENT_EDITION_OBJ" bo,sys."_CURRENT_EDITION_OBJ" o,sys.user$ u
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = tsp.obj#
  AND bo.owner# = o.owner#
  AND bo.name = o.name
  AND bo.type# = 2
  AND tsp.ts# = tts.ts#
  AND tsp.file# = s.file#
  AND tsp.block# = s.block#
  AND tsp.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
UNION ALL
SELECT /*+ ordered */ 2, u.name, bo.name, o.subname, ' ', 10, tts.name,
  decode (s.extpct, 0, 0, 1) + decode(mod(s.extsize, s.iniexts), 0, 0, 2)
FROM  
  (SELECT ts#,name
    FROM sys.ts$
    WHERE (bitmapped = 0 OR (bitmapped != 0 AND bitand(flags,3)=0))
      AND bitand(flags,2048) != 2048
      AND online$ != 3
      AND name != 'SYSTEM' AND name != 'SYSAUX'
      AND dflextpct = 0
      AND (dflinit = 0 OR MOD(dflincr, dflinit) = 0)) tts,
  sys.indsubpart$ isp, sys.seg$ s, sys.user$ u,  sys."_CURRENT_EDITION_OBJ" o, sys."_CURRENT_EDITION_OBJ" bo
WHERE o.owner# = u.user#
  AND u.type# !=2
  AND o.obj# = isp.obj#
  AND bo.owner# = o.owner#
  AND bo.name = o.name
  AND bo.type# = 1
  AND isp.ts# = tts.ts#
  AND isp.file# = s.file#
  AND isp.block# = s.block#
  AND isp.ts# = s.ts#
  AND (s.extpct > 0 OR (s.iniexts > 0 AND (mod(s.extsize, s.iniexts) != 0) ) )
) where rownum < 201 AND LENGTH(lob_column) <= 30]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>

	<!--
  ======================================================================
  == Category:         Recommended Segment Settings - Non-Sys Segs in Sys TS
  == Collection Level: Recommended
  == Purpose:          Storage Advisor
  == Notes:            BEWARE!  Very similar to db_recSegmentSettings (for extent growth policy)
  ======================================================================
  -->
	<Metric NAME="db_recSegmentSettings_sysseg" TYPE="RAW" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<TableDescriptor TABLE_NAME="mgmt_db_recSegmentSettings_ecm">
			<ColumnDescriptor NAME="obj_type" COLUMN_NAME="obj_type" TYPE="NUMBER" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_type">Object Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_owner" COLUMN_NAME="obj_owner" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_owner">Object Owner</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_name" COLUMN_NAME="obj_name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_name">Object Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_partition" COLUMN_NAME="obj_partition" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_partition">Partition</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="obj_lob_col" COLUMN_NAME="obj_lob_col" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_lob_col">LOB Column</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="seg_type" COLUMN_NAME="segment_type" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_recSegmentSettings_segment_type">Segment Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace" COLUMN_NAME="tablespace" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_recSegmentSettings_tablespace">Tablespace</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="recommendation" COLUMN_NAME="problem_code" TYPE="NUMBER" IS_KEY="TRUE">
				<!-- Numeric value is bitwise OR of specific problems:            -->
				<!--   4    Non-system segment in system tablespace               -->
				<Display>
					<Label NLSID="db_recSegmentSettings_problem_code">Problem</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
                <!--
Query to get segments with settings that violate best-practices
recommendations.  Result columns are:
1. Object type ::=
      1 (Table) | 2 (Index) | 3 (Cluster)
2. Object schema
3. Object name
4. Partition name or ' ' if not partitioned
5. LOB Column name or ' ' if not a LOB column
6. Segment type (Number):
   1       TABLE
   2       INDEX
   3       TABLE PARTITION
   4       INDEX PARTITION
   5       IOT OVERFLOW
   6       LOB INDEX (not used)
   7       LOB COLUMN
   8       LOB PARTITION
   9       TABLE SUBPARTITION
   10      INDEX SUBPARTITION
   11      LOB SUBPARTITION (not used, but should be)
   12      CLUSTER
   13      IOT OVERFLOW PARTITION
7. Name of tablespace containing the segment (String)
8. Violations (Number) - Bitwise OR of problem codes:
   4       Non-system segment in system tablespace

Index of Queries in the Union
1. Obj type=1, seg type=1, no ptn or LOB column:
   Nonpartitioned tables.
2. Obj type=2, seg type=2, no ptn or LOB column:
   Nonpartitioned indexes
3. Obj type=3, seg type=12, no ptn or LOB column:
   Clusters
4. Obj type=1, seg type=1, no ptn or LOB column:
   Non-partitioned IOTs (returned as type TABLE)
5. Obj type=1, seg type=3, ptn, no LOB column:
   Table partitions
6. Obj type=2, seg type=4, ptn, no LOB column:
   Index partitions (no LOB or IOT partitions)
7. Obj type=1, seg type=5, no ptn or LOB column:
   IOT overflow segments
8. Obj type=1, seg type=8, no ptn, LOB column:
   Unpartitioned LOB columns
9. Obj type=1, seg type=3, ptn, no LOB column:
   IOT Partitions (returned as type TABLE PARTITION)
10. Obj type=1, seg type=13, ptn, no LOB column:
    IOT Overflow partitions
11. Obj type=1, seg type=8, ptn, LOB column:
    LOB column partitions (The Final Frontier)
12. Obj type=1, seg type=9, ptn, no LOB column:
    Table subpartitions
13. Obj type=2, seg type=10, ptn, no LOB column:
    Index subpartitions
                -->
		<QueryDescriptor FETCHLET_ID="SQL">
                  <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1"/>
	          </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT /*+ INDEX(ts) */
   o.object_type, u.name, o.object_name, o.partition, o.lob_column, o.seg_type, ts.name, 4
FROM (
  SELECT 1 "OBJECT_TYPE", o.owner# "USER_NAME#", o.name "OBJECT_NAME", ' ' "PARTITION", ' ' "LOB_COLUMN", 1 "SEG_TYPE", t.ts#
"TABLESPACE#"
  FROM sys.obj$ o, sys.tab$ t, sys.seg$ s
  WHERE o.obj# = t.obj#
    AND t.ts# in (:1,:2)
    AND t.file# = s.file#
    AND t.block# = s.block#
    AND t.ts# = s.ts#
    AND decode (bitand (t.property, 1), 1, 1, 0) = 0
    AND decode (bitand (t.property, 32), 32, 1, 0) = 0
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 0
    AND decode (bitand (t.property, 1024), 1024, 1, 0) = 0
 UNION ALL
 SELECT 2, o.owner#, o.name, ' ', ' ', 2, i.ts#
  FROM sys.obj$ o, sys.ind$ i, sys.seg$ s
  WHERE o.obj# = i.obj#
    AND i.ts# in (:1,:2)
    AND i.file# = s.file#
    AND i.block# = s.block#
    AND i.ts# = s.ts#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 0
    AND i.type# not in (4, 8)
 UNION ALL
 SELECT 3, o.owner#, o.name, ' ', ' ', 12, c.ts#
  FROM sys.obj$ o, sys.clu$ c, sys.seg$ s
  WHERE o.obj# = c.obj#
    AND c.ts# IN (:1,:2)
    AND c.file# = s.file#
    AND c.block# = s.block#
    AND c.ts# = s.ts#
 UNION ALL
  SELECT 1, o.owner#, tn.name, ' ', ' ', 1, i.ts#
  FROM sys.obj$ o, sys.seg$ s, sys.tab$ t, sys.obj$ tn, sys.ind$ i
  WHERE o.obj# = i.obj#
    AND i.ts# IN (:1,:2)
    AND i.file# = s.file#
    AND i.block# = s.block#
    AND i.ts# = s.ts#
    AND i.bo# = tn.obj#
    AND tn.obj# = t.obj#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 0
    AND i.type# = 4
 UNION ALL
  SELECT 1, o.owner#, o.name, o.subname, ' ', 3, tp.ts#
  FROM sys.obj$ o, sys.seg$ s, sys.tab$ t, sys.tabpart$ tp
  WHERE o.obj# = tp.obj#
    AND tp.ts# IN (:1,:2)
    AND tp.file# = s.file#
    AND tp.block# = s.block#
    AND tp.ts# = s.ts#
    AND t.obj# = tp.bo#
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 0
 UNION ALL
  SELECT 2, o.owner#, o.name, o.subname, ' ', 4, ip.ts#
  FROM sys.obj$ o, sys.seg$ s, sys.ind$ i, sys.indpart$ ip
  WHERE o.obj# = ip.obj#
    AND ip.ts# IN (:1,:2)
    AND ip.file# = s.file#
    AND ip.block# = s.block#
    AND ip.ts# = s.ts#
    AND i.obj# = ip.bo#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 1
    AND i.type# not in (4, 8)
 UNION ALL
  SELECT 1, o.owner#, tn.name, ' ', ' ', 5, t.ts#
  FROM sys.obj$ o, sys.seg$ s, sys.tab$ t, sys.obj$ tn, sys.tab$ iot
  WHERE o.obj# = t.obj#
    AND t.ts# IN (:1,:2)
    AND t.file# = s.file#
    AND t.block# = s.block#
    AND t.ts# = s.ts#
    AND tn.obj# = t.bobj#
    AND tn.obj# = iot.obj#
    AND decode (bitand (t.property, 32), 32, 1, 0) = 0
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 1
 UNION ALL
  SELECT 1, tn.owner#, tn.name, ' ', decode(bitand(c.property, 1), 1, substr(ac.name,0,500), c.name), 8, l.ts#
  FROM sys.seg$ s, sys.obj$ tn, sys.attrcol$ ac,  sys.col$ c, sys.lob$ l
  WHERE tn.obj# = c.obj#
    AND c.obj# = l.obj#
    AND c.intcol# = l.intcol#
    AND l.ts# IN (:1,:2)
    AND l.file# = s.file#
    AND l.block# = s.block#
    AND l.ts# = s.ts#
    AND c.obj# = ac.obj#(+)
    AND c.intcol# = ac.intcol#(+)
    AND bitand(c.property,32768) != 32768
 UNION ALL
  SELECT 1, o.owner#, tn.name, o.subname, ' ', 3, ip.ts#
  FROM sys.seg$ s, sys.obj$ o, sys.ind$ i, sys.obj$ tn, sys.indpart$ ip
  WHERE o.obj# = ip.obj#
    AND ip.ts# IN (:1,:2)
    AND ip.file# = s.file#
    AND ip.block# = s.block#
    AND ip.ts# = s.ts#
    AND i.obj# = ip.bo#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 1
    AND i.type# = 4
    AND i.bo# = tn.obj#
 UNION ALL
  SELECT 1, o.owner#, tbo.name, o.subname, ' ', 13, tp.ts#
  FROM sys.seg$ s, sys.obj$ o, sys.obj$ tbo, sys.tab$ t, sys.tabpart$ tp
  WHERE o.obj# = tp.obj#
    AND tp.ts# IN (:1,:2)
    AND tp.file# = s.file#
    AND tp.block# = s.block#
    AND tp.ts# = s.ts#
    AND t.obj# = tp.bo#
    AND decode (bitand (t.property, 32), 32, 1, 0) = 1
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 1
    AND tbo.obj# = t.bobj#
 UNION ALL
  SELECT 1, tbo.owner#, tbo.name, po.subname, decode(bitand(c.property, 1), 1, substr(a.name,0,500), c.name), 8, lf.ts#
  FROM  sys.seg$ s, sys.obj$ tbo, sys.attrcol$ a, sys.col$ c, sys.lob$ l, sys.obj$ po, sys.partobj$ pobj, sys.lobfrag$ lf
  WHERE pobj.obj# = tbo.obj#
    AND lf.ts# IN (:1,:2)
    AND lf.file# = s.file#
    AND lf.block# = s.block#
    AND lf.ts# = s.ts#
    AND mod(pobj.spare2, 256) = 0
    AND tbo.obj# = c.obj#
    AND c.obj# = l.obj#
    AND c.intcol# = l.intcol#
    AND l.lobj# = lf.parentobj#
    AND lf.tabfragobj# = po.obj#
    AND bitand(c.property,32768) != 32768
    AND c.obj# = a.obj#(+)
    AND c.intcol# = a.intcol#(+)
 UNION ALL
  SELECT 1, o.owner#, bo.name, o.subname, ' ', 9, tsp.ts#
  FROM sys.seg$ s, sys.obj$ o, sys.obj$ bo, sys.tabsubpart$ tsp
  WHERE o.obj# = tsp.obj#
    AND bo.owner# = o.owner#
    AND bo.name = o.name
    AND bo.type# = 2
    AND tsp.file# = s.file#
    AND tsp.block# = s.block#
    AND tsp.ts# IN (:1,:2)
 UNION ALL
  SELECT 2, o.owner#, bo.name, o.subname, ' ', 10, isp.ts#
  FROM sys.seg$ s, sys.obj$ o, sys.obj$ bo, sys.indsubpart$ isp
  WHERE o.obj# = isp.obj#
    AND bo.owner# = o.owner#
    AND bo.name = o.name
    AND bo.type# = 1
    AND isp.file# = s.file#
    AND isp.block# = s.block#
    AND isp.ts# IN (:1,:2)
) o, sys.ts$ ts, sys.user$ u
WHERE o.USER_NAME# = u.user#
  AND u.name NOT IN ('MGMT_VIEW','OUTLN','ANONYMOUS','DMSYS','LBACSYS','WKPROXY','TRACESVR','SCOTT','ADAMS','BLAKE','CLARK','JONES','HR','PM','OE','SH','IX')
  AND u.name NOT IN ('CTXSYS','DMSYS','MDSYS','OLAPSYS','ORDPLUGINS','ORDSYS','PERFSTAT','SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM','WKSYS','WMSYS','XDB')
  AND u.name NOT LIKE 'FLOWS!_%' escape '!'
  AND o.TABLESPACE# = ts.ts#
  AND ts.ts# IN (:1,:2)
  AND rownum < 201
]]></Property>
			<Property NAME="SQLINPARAM1" SCOPE="INSTANCE">SystemTs#</Property>
			<Property NAME="SQLINPARAM2" SCOPE="INSTANCE">SysauxTs#</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
                  <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
	          </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT /*+ INDEX(ts) */
   o.object_type, u.name, o.object_name, o.partition, o.lob_column, o.seg_type, ts.name, 4
FROM (
  SELECT 1 "OBJECT_TYPE", o.owner# "USER_NAME#", o.name "OBJECT_NAME", ' ' "PARTITION", ' ' "LOB_COLUMN", 1 "SEG_TYPE", t.ts#
"TABLESPACE#"
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.tab$ t, sys.seg$ s
  WHERE o.obj# = t.obj#
    AND t.ts# in (:1,:2)
    AND t.file# = s.file#
    AND t.block# = s.block#
    AND t.ts# = s.ts#
    AND decode (bitand (t.property, 1), 1, 1, 0) = 0
    AND decode (bitand (t.property, 32), 32, 1, 0) = 0
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 0
    AND decode (bitand (t.property, 1024), 1024, 1, 0) = 0
 UNION ALL
 SELECT 2, o.owner#, o.name, ' ', ' ', 2, i.ts#
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.ind$ i, sys.seg$ s
  WHERE o.obj# = i.obj#
    AND i.ts# in (:1,:2)
    AND i.file# = s.file#
    AND i.block# = s.block#
    AND i.ts# = s.ts#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 0
    AND i.type# not in (4, 8)
 UNION ALL
 SELECT 3, o.owner#, o.name, ' ', ' ', 12, c.ts#
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.clu$ c, sys.seg$ s
  WHERE o.obj# = c.obj#
    AND c.ts# IN (:1,:2)
    AND c.file# = s.file#
    AND c.block# = s.block#
    AND c.ts# = s.ts#
 UNION ALL
  SELECT 1, o.owner#, tn.name, ' ', ' ', 1, i.ts#
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.seg$ s, sys.tab$ t, sys."_CURRENT_EDITION_OBJ" tn, sys.ind$ i
  WHERE o.obj# = i.obj#
    AND i.ts# IN (:1,:2)
    AND i.file# = s.file#
    AND i.block# = s.block#
    AND i.ts# = s.ts#
    AND i.bo# = tn.obj#
    AND tn.obj# = t.obj#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 0
    AND i.type# = 4
 UNION ALL
  SELECT 1, o.owner#, o.name, o.subname, ' ', 3, tp.ts#
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.seg$ s, sys.tab$ t, sys.tabpart$ tp
  WHERE o.obj# = tp.obj#
    AND tp.ts# IN (:1,:2)
    AND tp.file# = s.file#
    AND tp.block# = s.block#
    AND tp.ts# = s.ts#
    AND t.obj# = tp.bo#
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 0
 UNION ALL
  SELECT 2, o.owner#, o.name, o.subname, ' ', 4, ip.ts#
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.seg$ s, sys.ind$ i, sys.indpart$ ip
  WHERE o.obj# = ip.obj#
    AND ip.ts# IN (:1,:2)
    AND ip.file# = s.file#
    AND ip.block# = s.block#
    AND ip.ts# = s.ts#
    AND i.obj# = ip.bo#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 1
    AND i.type# not in (4, 8)
 UNION ALL
  SELECT 1, o.owner#, tn.name, ' ', ' ', 5, t.ts#
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.seg$ s, sys.tab$ t, sys."_CURRENT_EDITION_OBJ" tn, sys.tab$ iot
  WHERE o.obj# = t.obj#
    AND t.ts# IN (:1,:2)
    AND t.file# = s.file#
    AND t.block# = s.block#
    AND t.ts# = s.ts#
    AND tn.obj# = t.bobj#
    AND tn.obj# = iot.obj#
    AND decode (bitand (t.property, 32), 32, 1, 0) = 0
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 1
 UNION ALL
  SELECT 1, tn.owner#, tn.name, ' ', decode(bitand(c.property, 1), 1, substr(ac.name,0,500), c.name), 8, l.ts#
  FROM sys.seg$ s, sys."_CURRENT_EDITION_OBJ" tn, sys.attrcol$ ac,  sys.col$ c, sys.lob$ l
  WHERE tn.obj# = c.obj#
    AND c.obj# = l.obj#
    AND c.intcol# = l.intcol#
    AND l.ts# IN (:1,:2)
    AND l.file# = s.file#
    AND l.block# = s.block#
    AND l.ts# = s.ts#
    AND c.obj# = ac.obj#(+)
    AND c.intcol# = ac.intcol#(+)
    AND bitand(c.property,32768) != 32768
 UNION ALL
  SELECT 1, o.owner#, tn.name, o.subname, ' ', 3, ip.ts#
  FROM sys.seg$ s, sys."_CURRENT_EDITION_OBJ" o, sys.ind$ i, sys."_CURRENT_EDITION_OBJ" tn, sys.indpart$ ip
  WHERE o.obj# = ip.obj#
    AND ip.ts# IN (:1,:2)
    AND ip.file# = s.file#
    AND ip.block# = s.block#
    AND ip.ts# = s.ts#
    AND i.obj# = ip.bo#
    AND decode (bitand (i.property, 2), 2, 1, 0) = 1
    AND i.type# = 4
    AND i.bo# = tn.obj#
 UNION ALL
  SELECT 1, o.owner#, tbo.name, o.subname, ' ', 13, tp.ts#
  FROM sys.seg$ s, sys."_CURRENT_EDITION_OBJ" o, sys."_CURRENT_EDITION_OBJ" tbo, sys.tab$ t, sys.tabpart$ tp
  WHERE o.obj# = tp.obj#
    AND tp.ts# IN (:1,:2)
    AND tp.file# = s.file#
    AND tp.block# = s.block#
    AND tp.ts# = s.ts#
    AND t.obj# = tp.bo#
    AND decode (bitand (t.property, 32), 32, 1, 0) = 1
    AND decode (bitand (t.property, 64), 64, 1, 0) = 0
    AND decode (bitand (t.property, 512), 512, 1, 0) = 1
    AND tbo.obj# = t.bobj#
 UNION ALL
  SELECT 1, tbo.owner#, tbo.name, po.subname, decode(bitand(c.property, 1), 1, substr(a.name,0,500), c.name), 8, lf.ts#
  FROM  sys.seg$ s, sys."_CURRENT_EDITION_OBJ" tbo, sys.attrcol$ a, sys.col$ c, sys.lob$ l, sys."_CURRENT_EDITION_OBJ" po, sys.partobj$ pobj, sys.lobfrag$ lf
  WHERE pobj.obj# = tbo.obj#
    AND lf.ts# IN (:1,:2)
    AND lf.file# = s.file#
    AND lf.block# = s.block#
    AND lf.ts# = s.ts#
    AND mod(pobj.spare2, 256) = 0
    AND tbo.obj# = c.obj#
    AND c.obj# = l.obj#
    AND c.intcol# = l.intcol#
    AND l.lobj# = lf.parentobj#
    AND lf.tabfragobj# = po.obj#
    AND bitand(c.property,32768) != 32768
    AND c.obj# = a.obj#(+)
    AND c.intcol# = a.intcol#(+)
 UNION ALL
  SELECT 1, o.owner#, bo.name, o.subname, ' ', 9, tsp.ts#
  FROM sys.seg$ s, sys."_CURRENT_EDITION_OBJ" o, sys."_CURRENT_EDITION_OBJ" bo, sys.tabsubpart$ tsp
  WHERE o.obj# = tsp.obj#
    AND bo.owner# = o.owner#
    AND bo.name = o.name
    AND bo.type# = 2
    AND tsp.file# = s.file#
    AND tsp.block# = s.block#
    AND tsp.ts# IN (:1,:2)
 UNION ALL
  SELECT 2, o.owner#, bo.name, o.subname, ' ', 10, isp.ts#
  FROM sys.seg$ s, sys."_CURRENT_EDITION_OBJ" o, sys."_CURRENT_EDITION_OBJ" bo, sys.indsubpart$ isp
  WHERE o.obj# = isp.obj#
    AND bo.owner# = o.owner#
    AND bo.name = o.name
    AND bo.type# = 1
    AND isp.file# = s.file#
    AND isp.block# = s.block#
    AND isp.ts# IN (:1,:2)
) o, sys.ts$ ts, sys.user$ u
WHERE o.USER_NAME# = u.user#
  AND u.name NOT IN ('MGMT_VIEW','OUTLN','ANONYMOUS','DMSYS','LBACSYS','WKPROXY','TRACESVR','SCOTT','ADAMS','BLAKE','CLARK','JONES','HR','PM','OE','SH','IX')
  AND u.name NOT IN (SELECT DISTINCT schema_name FROM V$SYSAUX_OCCUPANTS)
  AND u.name NOT LIKE 'FLOWS!_%' escape '!'
  AND o.TABLESPACE# = ts.ts#
  AND u.type# !=2
  AND ts.ts# IN (:1,:2)
  AND rownum < 201
]]></Property>
			<Property NAME="SQLINPARAM1" SCOPE="INSTANCE">SystemTs#</Property>
			<Property NAME="SQLINPARAM2" SCOPE="INSTANCE">SysauxTs#</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>

	<!--
  ======================================================================
  == Category:         Recommended Settings Purge
  == Collection Level: Recommended
  == Purpose:          Storage Advisor
  == Note:             This metric fires after the recXxxSettingsRaw
  ==                   metrics to purge old records.
  ======================================================================
  -->
	<Metric NAME="recSettingsPurge" TYPE="RAW">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<TableDescriptor TABLE_NAME="mgmt_space_purge" SKIP_METRIC_COLUMN="TRUE" SKIP_COLLTIME_COLUMN="TRUE">
			<ColumnDescriptor NAME="mgmt_space_purge_metric_name" COLUMN_NAME="metric_name" TYPE="STRING" IS_KEY="FALSE"/>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="metricName" SCOPE="USER" OPTIONAL="FALSE">metricName</Property>
			<Property NAME="command" SCOPE="GLOBAL">
        %perlBin%/perl %scriptsDir%/spacePurge.pl %metricName%
      </Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		</QueryDescriptor>
	</Metric>
<!--
 ======================================================================
  == Category:         Data Guard Metrics
  ======================================================================
-->
	<Metric NAME="dataguard9" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="9iR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary"/>
		</ValidIf>
		<Display>
			<Label NLSID="dg">Data Guard</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="dg_name" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
				<Display>
					<Label NLSID="dg_name">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_dnr1" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_dnr1">Data Not Received (logs)</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_dna1" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_dna1">Data Not Applied (logs) </Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_status">Data Guard Status</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgDatabases.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>
	<Metric NAME="dataguard10" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary"/>
		</ValidIf>
		<Display>
			<Label NLSID="dg">Data Guard</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="dg_name" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
				<Display>
					<Label NLSID="dg_name">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_dnr1" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_dnr1">Data Not Received (logs)</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_dnr2" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_dnr2">Data Not Received (MB)</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_dna1" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_dna1">Data Not Applied (logs) </Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_dna2" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_dna2">Data Not Applied (MB) </Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_status">Data Guard Status</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="ConvertFromCharset" SCOPE="GLOBAL">AL32UTF8</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgDatabases.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>

	<Metric NAME="DGPrimaryDBName" TYPE="TABLE" USAGE_TYPE="COLLECT_UPLOAD" HELP="NO_HELP">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
 <CategoryProp NAME="DataGuardStatus" CHOICES="Physical Standby;Logical Standby;Snapshot Standby"/>
		</ValidIf>
		<TableDescriptor>
			<ColumnDescriptor NAME="db_name" TYPE="STRING" IS_KEY="FALSE" HELP="NO_HELP">
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgGetPrimary.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>

	<Metric NAME="dataguard" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary"/>
		</ValidIf>
		<Display>
			<Label NLSID="dg_status">Data Guard Status</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="dg_name" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
				<Display>
					<Label NLSID="dg_name">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_status">Data Guard Status</Label>
				</Display>
			</ColumnDescriptor>
 
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="ConvertFromCharset" SCOPE="GLOBAL">AL32UTF8</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgDatabases.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>


 <Metric NAME="observer" TYPE="TABLE">
    <ValidIf>
      <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203" /> 
  	  <CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary"/>
    </ValidIf>
    <Display>
      <Label NLSID="dg_observer">Data Guard Fast-Start Failover Observer</Label> 
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="ob_status" TYPE="STRING" IS_KEY="FALSE">
        <Display>
          <Label NLSID="dg_observer_status">Observer Status</Label> 
        </Display>
      </ColumnDescriptor>
     </TableDescriptor>
     <QueryDescriptor FETCHLET_ID="OSLineToken">
      <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
      <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
      <Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgObserverStatus.pl</Property>
      <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
      <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
      <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
      <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
      <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
      <Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
      </QueryDescriptor>
  </Metric>
  <Metric NAME="observer_11g" TYPE="TABLE">
	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		<CategoryProp NAME="DataGuardStatus" CHOICES="Primary"/>
	</ValidIf>
    	<Display>
      		<Label NLSID="dg_observer">Data Guard Fast-Start Failover Observer</Label> 
    	</Display>
	<TableDescriptor>
      		<ColumnDescriptor NAME="ob_status" TYPE="STRING"  IS_KEY="FALSE" >
			<Display FOR_SUMMARY_UI="TRUE">
				<Label NLSID="dg_observer_status">Observer Status</Label>
			</Display>
		</ColumnDescriptor>
	</TableDescriptor>
	<QueryDescriptor FETCHLET_ID="SQL">
		<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="11gR1;11gR2"/>
		</ValidIf>
		<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
declare
  l_valid_count number;
  l_sqlcmd varchar2(256);
  obs_status varchar2(256);
  v_db_version VARCHAR2(12);
  db_version_11 CONSTANT VARCHAR2(10) := '11.1.0.0.0';
  TYPE data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;
  l_observer_host varchar2(512);

begin
  l_valid_count := -1;
  select LPAD(version, 10, '0') into v_db_version from v$instance;
  if(v_db_version >= db_version_11) then
    select count(1) into l_valid_count from v$database where database_role='PRIMARY' and FS_FAILOVER_STATUS !='DISABLED';
    if l_valid_count > 0 then
       l_valid_count := sys.dbms_drs.get_property_obj(0, 'ObserverHB');
    else
      l_valid_count := -1;
    end if;
  end if;
    if l_valid_count = -1 then
    obs_status := 'Fast-start failover disabled';
  elsif l_valid_count = 0 then
    select fs_failover_observer_host into l_observer_host from v$database;
    obs_status := 'Observer is running normally on ' || l_observer_host;
  elsif l_valid_count > 0 then
    obs_status := 'Error Fast-Start Failover observer is no longer observing this database';
  else 
    obs_status := 'Error ' || l_valid_count;
  end if;

  open data_cursor for select obs_status from dual;
  :1 := data_cursor;
end;
]]>   </Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="TRUE">SID</Property>
		<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE">password</Property>
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>

	<Metric NAME="dataguard_pperf" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary"/>
		</ValidIf>
		<Display>
			<Label NLSID="dg_pperf">Data Guard Performance</Label>
		</Display>
		<TableDescriptor>
     <ColumnDescriptor NAME="dg_rg" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="TRUE" >
				<Display>
					<Label NLSID="dg_rg">Redo Generated</Label>
				</Display>
			</ColumnDescriptor>
    <ColumnDescriptor NAME="dg_redo_rate_KB" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(_dg_rg > dg_rg) ? (1/0) : ((dg_rg - _dg_rg)/__interval)" >
				<Display>
					<Label NLSID="dg_redo_rate_KB">Redo Generation Rate (KB/second)</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <ValidIf>
        <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
      </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select sum(s.value*512/1000) REDO from  gv$sysstat s  where s.name='redo blocks written'
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="TRUE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
	</Metric>
	<Metric NAME="dataguard_sperf" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Physical Standby;Logical Standby;Snapshot Standby"/>
		</ValidIf>
		<Display>
			<Label NLSID="dg_sperf">Data Guard Performance</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="dg_fot" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_fot">Estimated Failover Time (seconds)</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_lag" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_lag">Apply Lag (seconds)</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="dg_pdl" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="dg_pdl">Transport Lag (seconds)</Label>
				</Display>
			</ColumnDescriptor>
     <ColumnDescriptor NAME="dg_rda" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="TRUE"  >
				<Display>
					<Label NLSID="dg_rda">Redo Applied (blocks)</Label>
				</Display>
			</ColumnDescriptor>
    <ColumnDescriptor NAME="dg_redo_arate_KB" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(_dg_rda > dg_rda) ? (1/0) : ((dg_rda - _dg_rda)/__interval)" >
				<Display>
					<Label NLSID="dg_redo_arate_KB">Redo Apply Rate (KB/second)</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgPerf.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>
	<Metric NAME="dataguard_fsfo" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary;Physical Standby;Logical Standby"/>
		</ValidIf>
		<Display>
			<Label NLSID="dgfsfo_status">Data Guard Fast-Start Failover</Label>
		</Display>
		<TableDescriptor>
    <ColumnDescriptor NAME="dg_fs_scn" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="TRUE" >
				<Display>
					<Label NLSID="dg_fs_scn">New Fast-Start Failover SCN</Label>
				</Display>
			</ColumnDescriptor>
      <ColumnDescriptor NAME="dg_fs_time" TYPE="STRING" IS_DATE="TRUE" IS_KEY="FALSE" >
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="dg_fs_time">Fast-Start Failover Time</Label>
				</Display>
			</ColumnDescriptor>
      <ColumnDescriptor NAME="dg_fs_status" TYPE="STRING"  IS_KEY="FALSE" >
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="dg_fs_status_str">Fast-Start Failover Status</Label>
				</Display>
			</ColumnDescriptor>
      <ColumnDescriptor NAME="dg_fs_pscn" TYPE="NUMBER" IS_KEY="FALSE"  COMPUTE_EXPR="(_dg_fs_scn)" >
				<Display>
					<Label NLSID="dg_fs_pscn">Fast-Start Failover SCN</Label>
				</Display>
			</ColumnDescriptor>
     <ColumnDescriptor NAME="dg_fs" TYPE="NUMBER" IS_KEY="FALSE" 
                        COMPUTE_EXPR="((dg_fs_scn != 0) ? ((dg_fs_scn != _dg_fs_scn ) ? 1 : 0 ) : 0)">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="dg_fs">Fast-Start Failover Occurred</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <ValidIf>
        <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203"/>
      </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
DECLARE
  l_fsfo_time VARCHAR2(512);
  l_scn NUMBER;
  p_scn NUMBER;
  l_status VARCHAR2(21);
  l_role VARCHAR2(21);
  TYPE data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;
  
  v_db_version VARCHAR2(10);
  db_version_102 CONSTANT VARCHAR2(10) := '10.2.0.0.0';
BEGIN
  -- Database version
  SELECT LPAD(version, 10, '0') INTO v_db_version
  FROM v$instance;

  l_scn := 0;
  l_fsfo_time := '';
  
  IF (v_db_version >= db_version_102) THEN

    SELECT max(to_char(timestamp, 'YYYY-MM-DD HH24:MI:SS')) time INTO l_fsfo_time from v$dataguard_status where message='Switchover: Complete - Database mounted as primary';
    SELECT STANDBY_BECAME_PRIMARY_SCN,initcap(FS_FAILOVER_STATUS),database_role into p_scn,l_status,l_role from v$database;
    
    -- If FSFO status is reinstate required, then we know an FSFO occurred. 
    IF (l_role = 'PRIMARY' AND (instr(l_status,'Reinstate',1) != 0)) THEN

      -- An FSFO occurred, make sure there is a valid timestamp. If not (e.g. bounce required) use the startup time.      
      IF (l_fsfo_time IS NULL OR (length(l_fsfo_time) = 0)) THEN
        SELECT to_char(startup_time, 'YYYY-MM-DD HH24:MI:SS') time INTO l_fsfo_time from v$instance;
      END IF;      
      
      l_scn := p_scn;      
    END IF; 
  END IF;  	

  OPEN data_cursor FOR
  SELECT l_scn, l_fsfo_time, l_status from dual;
  :1 := data_cursor;
END;
]]>   </Property>
			<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
			<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="TRUE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
	</Metric>

	<Metric NAME="Availability" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary;Physical Standby;Logical Standby"/>
		</ValidIf>
		<Display>
			<Label NLSID="dg_failover_status">Data Guard Failover</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="Database_Down" TYPE="STRING" STATELESS_ALERTS="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="dg_failover_occurred">Failover Occurred</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
		</PushDescriptor>
	</Metric>
  <!-- Data Guard - Data Guard standby summary -->
	<Metric NAME="ha_dg_target_summary" TYPE="RAW">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="9iR2"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary;Physical Standby;Logical Standby"/>
		</ValidIf>
		<Display>
			<Label NLSID="ha_dg_target_summary">ha_dg_target_summary</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_ha_dg_target_summary" SKIP_COLLTIME_PK="TRUE" SKIP_METRIC_COLUMN="TRUE">
			<ColumnDescriptor NAME="SOURCE_TYPE" COLUMN_NAME="SOURCE_TYPE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="DB_ID">SOURCE_TYPE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="ROW_TYPE" COLUMN_NAME="ROW_TYPE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ROW_TYPE">ROW_TYPE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="USING_BROKER" COLUMN_NAME="USING_BROKER" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="USING_BROKER">USING_BROKER</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="ACTIVE_STBY" COLUMN_NAME="ACTIVE_STBY" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ACTIVE_STBY">ACTIVE_STBY</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="DB_UNIQUE_NAME" COLUMN_NAME="DB_UNIQUE_NAME" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="DB_UNIQUE_NAME">DB_UNIQUE_NAME</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="DB_ID" COLUMN_NAME="DB_ID" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="DB_ID">DB_ID</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="PRMY_DB_UNIQUE_NAME" COLUMN_NAME="PRMY_DB_UNIQUE_NAME" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="PRMY_DB_UNIQUE_NAME">PRMY_DB_UNIQUE_NAME</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="PRMY_DB_ID" COLUMN_NAME="PRMY_DB_ID" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="PRMY_DB_ID">PRMY_DB_ID</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="ROLE" COLUMN_NAME="ROLE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ROLE">ROLE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="STBY_LIST" COLUMN_NAME="STBY_LIST" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="STBY_LIST">ROW_TYPE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="PROTECTION_MODE" COLUMN_NAME="PROTECTION_MODE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="PROTECTION_MODE">PROTECTION_MODE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="FSFO_STATUS" COLUMN_NAME="FSFO_STATUS" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="FSFO_STATUS">FSFO_STATUS</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="STATUS" COLUMN_NAME="STATUS" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="STATUS">STATUS</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="TRANSPORT_LAG" COLUMN_NAME="TRANSPORT_LAG" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="TRANSPORT_LAG">TRANSPORT_LAG</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="APPLY_LAG" COLUMN_NAME="APPLY_LAG" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="APPLY_LAG">APPLY_LAG</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgCollector.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>

  <!-- Data Guard - Data Guard standby summary -->
	<Metric NAME="ha_dg_target_summary" TYPE="RAW">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
			<CategoryProp NAME="DataGuardStatus" CHOICES="Primary;Physical Standby;Logical Standby;Snapshot Standby"/>
		</ValidIf>
		<Display>
			<Label NLSID="ha_dg_target_summary">ha_dg_target_summary</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_ha_dg_target_summary" SKIP_COLLTIME_PK="TRUE" SKIP_METRIC_COLUMN="TRUE">
			<ColumnDescriptor NAME="SOURCE_TYPE" COLUMN_NAME="SOURCE_TYPE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="DB_ID">SOURCE_TYPE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="ROW_TYPE" COLUMN_NAME="ROW_TYPE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ROW_TYPE">ROW_TYPE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="USING_BROKER" COLUMN_NAME="USING_BROKER" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="USING_BROKER">USING_BROKER</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="ACTIVE_STBY" COLUMN_NAME="ACTIVE_STBY" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ACTIVE_STBY">ACTIVE_STBY</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="DB_UNIQUE_NAME" COLUMN_NAME="DB_UNIQUE_NAME" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="DB_UNIQUE_NAME">DB_UNIQUE_NAME</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="DB_ID" COLUMN_NAME="DB_ID" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="DB_ID">DB_ID</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="PRMY_DB_UNIQUE_NAME" COLUMN_NAME="PRMY_DB_UNIQUE_NAME" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="PRMY_DB_UNIQUE_NAME">PRMY_DB_UNIQUE_NAME</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="PRMY_DB_ID" COLUMN_NAME="PRMY_DB_ID" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="PRMY_DB_ID">PRMY_DB_ID</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="ROLE" COLUMN_NAME="ROLE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ROLE">ROLE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="STBY_LIST" COLUMN_NAME="STBY_LIST" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="STBY_LIST">ROW_TYPE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="PROTECTION_MODE" COLUMN_NAME="PROTECTION_MODE" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="PROTECTION_MODE">PROTECTION_MODE</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="FSFO_STATUS" COLUMN_NAME="FSFO_STATUS" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="FSFO_STATUS">FSFO_STATUS</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="STATUS" COLUMN_NAME="STATUS" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="STATUS">STATUS</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="TRANSPORT_LAG" COLUMN_NAME="TRANSPORT_LAG" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="TRANSPORT_LAG">TRANSPORT_LAG</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="APPLY_LAG" COLUMN_NAME="APPLY_LAG" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="APPLY_LAG">APPLY_LAG</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/db/dg/dgCollector.pl</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>

	<!--
  ======================================================================
  == Category:         Deferred Transactions
  == Collection Level: Recommended
  == Purpose:          Alerts
  ======================================================================
    -->
	<Metric NAME="DeferredTrans" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="deferredTrans_count">Deferred Transactions</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="errortrans_count" TYPE="NUMBER" IS_KEY="FALSE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="errortrans_error">Deferred Transaction Error Count</Label>

				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="deftrans_count" TYPE="NUMBER" IS_KEY="FALSE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="deftrans_count_name">Deferred Transaction Count</Label>

				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="transpose" SCOPE="GLOBAL">TRUE</Property>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT trans_count
  FROM (SELECT 'def_trans_err' name, COUNT(*) trans_count
          FROM sys.deferror
         UNION ALL
        SELECT 'def_trans_noerr' name, COUNT(*) trans_count
          FROM sys.deftran)
 ORDER BY name
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!-- ***************************************** -->
	<!-- Start Feature Usage Metric Definitions    -->
	<!-- ***************************************** -->
	<Metric NAME="db_FeatureUsage" TYPE="RAW">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="db_FeatureUsage">Feature Usage</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_db_featureusage" SKIP_COLLTIME_PK="TRUE" SKIP_METRIC_COLUMN="TRUE">
			<!-- DBID -->
			<ColumnDescriptor NAME="DBID" COLUMN_NAME="DBID" TYPE="NUMBER" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_FeatureUsage_database_name">DBID</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Feature Name -->
			<ColumnDescriptor NAME="name" COLUMN_NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_FeatureUsage_feature_name">Feature Name</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Currently Used -->
			<ColumnDescriptor NAME="currently_used" COLUMN_NAME="currently_used" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_currently_used">Currently Used</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Detected Usages -->
			<ColumnDescriptor NAME="detected_usages" COLUMN_NAME="detected_usages" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_detected_usages">Detected Usages</Label>
				</Display>
			</ColumnDescriptor>
			<!-- First Usage Date -->
			<ColumnDescriptor NAME="first_usage_date" COLUMN_NAME="first_usage_date" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_first_usage_date">First Usage Date</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Last Usage Date -->
			<ColumnDescriptor NAME="last_usage_date" COLUMN_NAME="last_usage_date" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_last_usage_date">Last Usage Date</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Version -->
			<ColumnDescriptor NAME="version" COLUMN_NAME="version" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_FeatureUsage_version">Version</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Last Sample Date -->
			<ColumnDescriptor NAME="last_sample_date" COLUMN_NAME="last_sample_date" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_last_sample_date">Last Sample Date</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Last Sample Period  -->
			<ColumnDescriptor NAME="last_sample_period" COLUMN_NAME="last_sample_period" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_last_sample_period">Last Sample Period</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Total Samples  -->
			<ColumnDescriptor NAME="total_samples" COLUMN_NAME="total_samples" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_total_samples">Total Samples</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Aux Count  -->
			<ColumnDescriptor NAME="aux_count" COLUMN_NAME="aux_count" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_aux_count">Count</Label>
				</Display>
			</ColumnDescriptor>
			<!-- Description -->
			<ColumnDescriptor NAME="description" COLUMN_NAME="description" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_FeatureUsage_description">Description</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
        SELECT
            s.dbid               ,
            s.name               ,
            s.currently_used     ,
            s.detected_usages    ,
            s.first_usage_date   ,
            s.last_usage_date    ,
            s.version            ,
            s.last_sample_date   ,
            s.last_sample_period ,
            s.total_samples      ,
            s.aux_count          ,
            s.description
        FROM
            dba_feature_usage_statistics s, v$parameter p
       WHERE p.name='statistics_level' and p.value!='BASIC'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!-- ***************************************** -->
	<!-- End of Feature Usage Metric Definitions   -->
	<!-- ***************************************** -->

	<!--
  ======================================================================
  == Category:         Invalid Objects (Policy Framework metric)
  == Collection Level: Recommended
  == Purpose:          Objects Policy - Invalid Objects
  == rreilly - Collection Removed on Aug 12, 2004 for bug 3264676
  ======================================================================
  -->


	<Metric NAME="db_invalidObjects" TYPE="RAW" KEYS_ONLY="TRUE" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<TableDescriptor TABLE_NAME="mgmt_db_invobjs_ecm">
			<ColumnDescriptor NAME="object_type" COLUMN_NAME="object_type" TYPE="NUMBER" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_invObjects_type">Object Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="object_owner" COLUMN_NAME="object_owner" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_invObjects_owner">Object Owner</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="object_name" COLUMN_NAME="object_name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_invObjects_name">Object Name</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
		  <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="pre8;8i;8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1"/>
                  </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
DECLARE
  javasnm_exists  NUMBER := 0;
  TYPE        data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;

BEGIN
  SELECT count(*) INTO javasnm_exists 
    FROM sys.all_views WHERE view_name='JAVASNM';

IF javasnm_exists >= 1 THEN

 OPEN data_cursor FOR
 'SELECT /*+ all_rows */ o.type# object_type, u.name object_owner, o.name object_name ' ||
 'FROM sys.obj$ o, sys.user$ u ' ||
 'WHERE u.user# = o.owner# AND o.status NOT IN (0,1) AND o.type# NOT IN (28,29,30) ' ||
   'AND ( ((u.name=''SYS'' or u.name=''PUBLIC'') ' ||
             'and (o.name NOT LIKE ''DBA_HIST_%'' and o.name != ''DBMS_SWRF_REPORT_INTERNAL'')) ' ||
         'or (u.name !=''SYS'' and u.name != ''PUBLIC'') ) ' ||
 'UNION ALL ' ||
 'SELECT * FROM ( ' ||
   'SELECT o.type# object_type, u.name object_owner, nvl(l.longname, o.name) object_name ' ||
   'FROM sys.obj$ o, javasnm l, sys.user$ u ' ||
   'WHERE o.name = l.short(+) AND o.type# IN (28,29,30) AND o.owner# = u.user# AND o.status NOT IN (0,1)) ' ||
   'WHERE LENGTH(object_name) <= 1000';

ELSE

 OPEN data_cursor FOR
 'SELECT /*+ all_rows */ o.type# object_type, u.name object_owner, o.name object_name ' ||
 'FROM sys.obj$ o, sys.user$ u ' ||
 'WHERE u.user# = o.owner# AND o.status NOT IN (0,1) ' ||
   'AND ( ((u.name=''SYS'' or u.name=''PUBLIC'') ' ||
             'and (o.name NOT LIKE ''DBA_HIST_%'' and o.name != ''DBMS_SWRF_REPORT_INTERNAL'')) ' ||
         'or (u.name !=''SYS'' and u.name != ''PUBLIC'') ) ';

END IF;

:1 := data_cursor;

END;
]]></Property>
			<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
			<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
		  <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
                  </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
DECLARE
  javasnm_exists  NUMBER := 0;
  TYPE        data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;

BEGIN
  SELECT count(*) INTO javasnm_exists 
    FROM sys.all_views WHERE view_name='JAVASNM';

IF javasnm_exists >= 1 THEN

 OPEN data_cursor FOR
 'SELECT /*+ all_rows */ o.type# object_type, u.name object_owner, o.name object_name ' ||
 'FROM sys."_CURRENT_EDITION_OBJ" o, sys.user$ u ' ||
 'WHERE u.user# = o.owner# AND o.status NOT IN (0,1) AND o.type# NOT IN (28,29,30) ' ||
   'AND u.type# !=2 ' ||
   'AND ( ((u.name=''SYS'' or u.name=''PUBLIC'') ' ||
             'and (o.name NOT LIKE ''DBA_HIST_%'' and o.name != ''DBMS_SWRF_REPORT_INTERNAL'')) ' ||
         'or (u.name !=''SYS'' and u.name != ''PUBLIC'') ) ' ||
 'UNION ALL ' ||
 'SELECT * FROM ( ' ||
   'SELECT o.type# object_type, u.name object_owner, nvl(l.longname, o.name) object_name ' ||
   'FROM sys."_CURRENT_EDITION_OBJ" o, javasnm l, sys.user$ u ' ||
   'WHERE o.name = l.short(+) AND o.type# IN (28,29,30) AND u.type# !=2 AND o.owner# = u.user# ' ||
   'AND o.status NOT IN (0,1)) ' ||
   'WHERE LENGTH(object_name) <= 1000';

ELSE

 OPEN data_cursor FOR
 'SELECT /*+ all_rows */ o.type# object_type, u.name object_owner, o.name object_name ' ||
 'FROM sys."_CURRENT_EDITION_OBJ" o, sys.user$ u ' ||
 'WHERE u.user# = o.owner# AND o.status NOT IN (0,1) ' ||
   'AND u.type# !=2 ' ||
   'AND ( ((u.name=''SYS'' or u.name=''PUBLIC'') ' ||
             'and (o.name NOT LIKE ''DBA_HIST_%'' and o.name != ''DBMS_SWRF_REPORT_INTERNAL'')) ' ||
         'or (u.name !=''SYS'' and u.name != ''PUBLIC'') ) ';

END IF;

:1 := data_cursor;

END;
]]></Property>
			<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
			<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>

	<!--
  ======================================================================
  == Category:         Invalid Objects by Schema
  == Collection Level: Recommended
  == Purpose:          Alerts
  == !!!! WARNING: If this SQL changes, then the SQL used by the 
  ==               Invalid objects page must also change.
  ======================================================================
    -->
	<Metric NAME="invalid_objects" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="invalid_objects">Invalid Objects by Schema</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="owner" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="invalid_objects_owner">Invalid Object Owner</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="count" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="invalid_objects_count">Owner's Invalid Object Count</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
		  <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="pre8;8i;8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1"/>
                  </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT /*+ all_rows */ u.name owner, count(1) invalid_count
  FROM sys.obj$ o, sys.user$ u
 WHERE u.user# = o.owner#
   AND o.status NOT IN (0,1)
   AND ( ((u.name='SYS' or u.name='PUBLIC')
             and (o.name NOT LIKE 'DBA_HIST_%' and o.name !='DBMS_SWRF_REPORT_INTERNAL'))
          or (u.name !='SYS' and u.name != 'PUBLIC') )
GROUP BY u.name
      ]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
		  <ValidIf>
                    <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
                  </ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT /*+ all_rows */ u.name owner, count(1) invalid_count
  FROM sys."_CURRENT_EDITION_OBJ" o, sys.user$ u
 WHERE u.user# = o.owner#
   AND o.status NOT IN (0,1)
   AND u.type# !=2 
   AND ( ((u.name='SYS' or u.name='PUBLIC')
             and (o.name NOT LIKE 'DBA_HIST_%' and o.name !='DBMS_SWRF_REPORT_INTERNAL'))
          or (u.name !='SYS' and u.name != 'PUBLIC') )
GROUP BY u.name
      ]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Invalid Objects
  == Collection Level: Recommended
  == Purpose:          Alerts
  ======================================================================
    -->
	<Metric NAME="all_invalid_objects" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="all_invalid_objects">Invalid Objects</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="total_count" TYPE="NUMBER" IS_KEY="FALSE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="all_invalid_objects_total_count">Total Invalid Object Count</Label>

				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<ExecutionDescriptor>
			<GetTable NAME="invalid_objects_per_schema" METRIC_NAME="invalid_objects" USE_CACHE="TRUE"/>
			<GroupBy NAME="all_invalid_objects" FROM_TABLE="invalid_objects_per_schema">
				<AggregateColumn NAME="total_count" COLUMN_NAME="count" OPERATOR="SUM"/>
			</GroupBy>
		</ExecutionDescriptor>
	</Metric>



	<!--
  ======================================================================
  == Category:         Database Job Status
  == Collection Level: Recommended
  == Purpose:          Alerts
  ======================================================================
    -->
	<Metric NAME="dbjob_status" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="dbjob_status">Database Job Status</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="broken" TYPE="NUMBER" IS_KEY="FALSE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="dbjob_status_broken">Broken Job Count</Label>

				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="failed" TYPE="NUMBER" IS_KEY="FALSE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="dbjob_status_failed">Failed Job Count</Label>

				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT SUM(broken), SUM(failed) 
  FROM (SELECT DECODE(STATE, 'BROKEN', 1, 0) broken,
               DECODE(STATE,'FAILED',1,0) failed      
            FROM DBA_SCHEDULER_JOBS
           )
	]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!--
  ============================================================================
  == Category:         Storage (Performance): Unused Space in Object
  == Collection Level: Complete
  == Purpose:          Storage Problems report
  == Description:      Determines % unused space in a segment
  == Usage Notes:      The tsNames and schema properties should be set to ";"
  ==                   if no tablespaces or schemas are to be checked.
  ==                   Otherwise, send a ; separated lists of tablespaces
  ==                   and a ; separated of schemas
  ==                   wasteMinValue - any segment with unused% less than
  ==                                   wasteMinValue is not reported at all.
  ==                   rcMinValue - any segment with row chain % less than
  ==                                rcMinValue is not reported at all.
  ==                   ckWasteSpc - 'true' to check wasted space
  ==                   ckRowChain - 'true' to check row chaining
  ==                   minSegSize - if seg space in MB under HWM is below
  ==                                this value, don't bother checking it
  ==                                for wasted space.
  ============================================================================
  -->
	<Metric NAME="wastedSpace" TYPE="RAW">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="stgPerf">Segment Findings</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_space_metrics">
			<ColumnDescriptor NAME="obj_type_schema_name" COLUMN_NAME="object" TYPE="STRING" IS_KEY="TRUE">
      </ColumnDescriptor>
			<ColumnDescriptor NAME="seg_type" COLUMN_NAME="segment_type" TYPE="NUMBER" IS_KEY="TRUE">
      </ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace" COLUMN_NAME="tablespace" TYPE="STRING" IS_KEY="FALSE">
      </ColumnDescriptor>
			<ColumnDescriptor NAME="problem" COLUMN_NAME="problem_code" TYPE="NUMBER" IS_KEY="TRUE">
				<!-- Numeric value is bitwise OR of specific problems:  -->
				<!--   1 = wasted space                                 -->
				<!--   2 = excess row chaining                          -->
			</ColumnDescriptor>
			<!-- Numeric value is bitwise OR of specific problems:  -->
			<!--   1 = shrink                                       -->
			<!--   2 = reorg                                        -->
			<ColumnDescriptor NAME="recommendations" COLUMN_NAME="recommendations" TYPE="NUMBER" IS_KEY="FALSE">
      </ColumnDescriptor>
			<!-- Value1 - Supporting data for problem (; separated)   -->
			<!-- Wasted Space problem values                          -->
			<!--      %unused space;#MB unused;#MB allocated          -->
			<ColumnDescriptor NAME="problemValue" COLUMN_NAME="value1" TYPE="STRING" IS_KEY="FALSE">
      </ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<!--
        Making the item properties optional="FALSE" causes problems because
        a collection without any item properties is initiated on demand
        when the metrics are viewed from the All Metrics page and no data
        is being collected.
      -->
			<Property NAME="tsNames" SCOPE="USER" OPTIONAL="TRUE">tsNames</Property>
			<Property NAME="schemas" SCOPE="USER" OPTIONAL="TRUE">schemas</Property>
			<Property NAME="wasteMinValue" SCOPE="USER" OPTIONAL="TRUE">wasteMinValue</Property>
			<Property NAME="rcMinValue" SCOPE="USER" OPTIONAL="TRUE">rcMinValue</Property>
			<Property NAME="ckWasteSpc" SCOPE="USER" OPTIONAL="TRUE">ckWasteSpc</Property>
			<Property NAME="ckRowChain" SCOPE="USER" OPTIONAL="TRUE">ckRowChain</Property>
			<Property NAME="minSegSize" SCOPE="USER" OPTIONAL="TRUE">minSegSize</Property>
			<Property NAME="command" SCOPE="GLOBAL">
        %perlBin%/perl %scriptsDir%/wastedSpace.pl %tsNames% %schemas% %wasteMinValue% %rcMinValue% %ckWasteSpc% %ckRowChain% %minSegSize%
      </Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>
	</Metric>

  <!--
  ======================================================================
  == Category:  Segment Findings Privilege check
  == Purpose:   Determine whether the monitor user has enough
  ==            privileges to perform the wastedSpace check.
  == Note:      This is only collected on-demand from the
  ==            segment findings configuration page to determine
  ==            whether the monitor user needs to be granted
  ==            more privileges.  It is not loaded in the repository.
  ======================================================================
    -->
  <Metric NAME="seg_find_privs" TYPE="TABLE" USAGE_TYPE="HIDDEN"
          HELP="NO_HELP">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
    <TableDescriptor>
      <ColumnDescriptor NAME="hasPriv" TYPE="NUMBER">
      </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
      <![CDATA[
        SELECT 1 hasPriv FROM session_privs
        WHERE privilege = 'ANALYZE ANY'
      ]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>
  <!--
  ======================================================================
  == Category:  Segment Findings Grant Privilege
  == Purpose:   Grant the ANALYZE ANY priv to the monitor user
  == Note:      This is only collected on-demand from the
  ==            segment findings configuration page to determine
  ==            whether the monitor user needs to be granted
  ==            more privileges.  It is not loaded in the repository.
  ==
  ==            We return a useless cursor since the metric must return
  ==            a result.
  ======================================================================
    -->
  <Metric NAME="seg_grant_privs" TYPE="TABLE" USAGE_TYPE="HIDDEN"
          HELP="NO_HELP">
		<ValidIf>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
    <TableDescriptor>
      <ColumnDescriptor NAME="dummy" TYPE="NUMBER">
      </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
      <![CDATA[
        DECLARE
            TYPE        data_cursor_type IS REF CURSOR;
            dummyCursor data_cursor_type;
        BEGIN
            EXECUTE IMMEDIATE 'GRANT ANALYZE ANY TO ' || :1;
            OPEN dummyCursor FOR
                SELECT 1 dummy from DUAL;
            :2 := dummyCursor;

        END;
      ]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="USER">UserName</Property>
      <Property NAME="password" SCOPE="USER">password</Property>
      <Property NAME="SQLINPARAM1" SCOPE="USER">monitorUser</Property>
      <Property NAME="Role" SCOPE="USER" OPTIONAL="TRUE">Role</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">2</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
    </QueryDescriptor>
  </Metric>  
	<!--
  ======================================================================
  == Category:         Non-threshold based alert Suspended_Session
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="Suspended_Session" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="Suspended_Session">Session Suspended</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="Object_Causing" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="Suspended_Session_Object_Causing">Object Causing</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Tablespace" TYPE="STRING" NON_THRESHOLDED_ALERTS="TRUE">
				<Display>
					<Label NLSID="Suspended_Session_Tablespace">Session Suspended by Tablespace Limitation</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Rollback_Segment" TYPE="STRING" NON_THRESHOLDED_ALERTS="TRUE">
				<Display>
					<Label NLSID="Suspended_Session_Rollback_Segment">Session Suspended by Rollback Segment Limitation</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Data_Object" TYPE="STRING" NON_THRESHOLDED_ALERTS="TRUE">
				<Display>
					<Label NLSID="Suspended_Session_Data_Object">Session Suspended by Data Object Limitation</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Quota" TYPE="STRING" NON_THRESHOLDED_ALERTS="TRUE">
				<Display>
					<Label NLSID="Suspended_Session_Quota">Session Suspended by Quota Limitation</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
			<Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
			<Property NAME="KeyColumn" SCOPE="GLOBAL">Object_Causing</Property>
		</PushDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Non-threshold based alert Recovery_Area
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="Recovery_Area" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="Recovery_Area">Recovery Area</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="Recovery_Area" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="Recovery_Area_Recovery_Area">Recovery Area</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Free_Space" TYPE="NUMBER" NON_THRESHOLDED_ALERTS="TRUE">
				<Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="Recovery_Area_Free_Space">Recovery Area Free Space (%)</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT 'RECOVERY AREA' recovery_area,
       CASE WHEN space_limit > 0 AND space_limit >= space_used AND space_used >= space_reclaimable
            THEN 100 * (space_limit - (space_used - space_reclaimable))/space_limit
            ELSE NULL END free_space
  FROM v$recovery_file_dest
 WHERE name IS NOT NULL
   AND rownum = 1
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
			<Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
			<Property NAME="KeyColumn" SCOPE="GLOBAL">Recovery_Area</Property>
		</PushDescriptor>
	</Metric>
	<!--
  ======================================================================
  == Category:         Non-threshold based alert Snap_Shot_Too_Old
  == Collection Level: Recommended
  == Purpose:          Alerts, Trending
  ======================================================================
    -->
	<Metric NAME="Snap_Shot_Too_Old" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="Snap_Shot_Too_Old">Snapshot Too Old</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="Object_Causing" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="Snap_Shot_Too_Old_Object_Causing">Object Causing</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Tablespace" TYPE="STRING" STATELESS_ALERTS="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
				<Display>
					<Label NLSID="Snap_Shot_Too_Old_Tablespace">Snapshot Too Old due to Tablespace Limit</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="Rollback_Segment" TYPE="STRING" STATELESS_ALERTS="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
				<Display>
					<Label NLSID="Snap_Shot_Too_Old_Rollback_Segment">Snapshot Too Old due to Rollback Segment Limit</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
			<Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
			<Property NAME="KeyColumn" SCOPE="GLOBAL">Object_Causing</Property>
		</PushDescriptor>
	</Metric>
<!--====================================Configuration Metrics ================-->

  <!--
  ======================================================================
  == Category:         Tablespace Allocation 
  == DB Versions:      pre-8 to 10gR2
  == Collection Level: Recommended
  == Purpose:          Historical Tablespace Size Reporting
  ==                   (by customer request)
  ======================================================================
  -->
  <Metric NAME="tbspAllocation" TYPE="TABLE">
	<ValidIf>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
  <Display>
    <Label NLSID="tbspAllocation">Tablespace Allocation</Label>
  </Display>
  <TableDescriptor>
      <ColumnDescriptor NAME="name" TYPE="STRING" IS_KEY="TRUE">
        <Display>
          <Label NLSID="tbspName">Tablespace Name</Label>
        </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="spaceAllocated" TYPE="NUMBER" IS_KEY="FALSE">
        <Display>
          <Label NLSID="spaceAllocated">Tablespace Allocated Space (MB)</Label>
        </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="spaceUsed" TYPE="NUMBER" IS_KEY="FALSE">
        <Display>
          <Label NLSID="spaceUsed">Tablespace Used Space (MB)</Label>
        </Display>
      </ColumnDescriptor>
  </TableDescriptor>
  <QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="pre8;8i;8iR2"/>
			</ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT
    d.tablespace_name, 
    NVL(a.bytes / 1024 / 1024, 0) allocated_space, 
    NVL(a.bytes - NVL(f.bytes, 0), 0)/1024/1024 used_space
  FROM
    sys.dba_tablespaces d,  
    (select tablespace_name, sum(bytes) bytes, count(file_id) count  
       from dba_data_files group by tablespace_name) a, 
    (select tablespace_name, sum(bytes) bytes  
       from dba_free_space group by tablespace_name) f
  WHERE 
    d.tablespace_name = a.tablespace_name(+) 
    AND d.tablespace_name = f.tablespace_name(+)
    AND NOT (d.extent_management like 'LOCAL' 
             AND d.contents like 'TEMPORARY') 
UNION ALL 
SELECT
    d.tablespace_name, 
    NVL(a.bytes / 1024 / 1024, 0) allocated_space, 
    NVL(t.bytes, 0)/1024/1024 used_space
  FROM 
    sys.dba_tablespaces d,  
    (select tablespace_name, sum(bytes) bytes, count(file_id) count
       from dba_temp_files group by tablespace_name) a, 
    (select  ss.tablespace_name , sum((ss.used_blocks*ts.blocksize))  bytes
        from gv$sort_segment ss, sys.ts$ ts where ss.tablespace_name = ts.name 
                 group by ss.tablespace_name) t
  WHERE 
    d.tablespace_name = a.tablespace_name(+)
    AND d.tablespace_name = t.tablespace_name(+) 
    AND d.extent_management like 'LOCAL'
    AND d.contents like 'TEMPORARY'
  ORDER BY 1
]]></Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
  </QueryDescriptor>
  <QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
			</ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
SELECT /*+first_rows */
    d.tablespace_name, 
    NVL(a.bytes / 1024 / 1024, 0) allocated_space,
    DECODE(d.contents,'UNDO', NVL(u.bytes, 0)/1024/1024, NVL(a.bytes - NVL(f.bytes, 0), 0)/1024/1024) used_space 
  FROM 
    sys.dba_tablespaces d,  
    (SELECT tablespace_name, SUM(bytes) bytes, COUNT(file_id) count  
       from dba_data_files GROUP BY tablespace_name) a, 
    (select tablespace_name, sum(bytes) bytes  
       from dba_free_space group by tablespace_name) f, 
    (SELECT tablespace_name, SUM(bytes) bytes 
     FROM  (SELECT tablespace_name,sum (bytes) bytes,status from dba_undo_extents 
     WHERE status ='ACTIVE' group by tablespace_name,status   
     UNION ALL 
     SELECT tablespace_name,sum(bytes) bytes,status from dba_undo_extents 
     WHERE  status ='UNEXPIRED' group by tablespace_name,status ) 
     group by  tablespace_name ) u 
  WHERE 
    d.tablespace_name = a.tablespace_name(+) 
    AND d.tablespace_name = f.tablespace_name(+) 
    AND d.tablespace_name = u.tablespace_name(+)
    AND NOT (d.extent_management = 'LOCAL' AND d.contents = 'TEMPORARY')
UNION ALL 
SELECT
    d.tablespace_name, 
    NVL(a.bytes / 1024 / 1024, 0) allocated_space, 
    NVL(t.bytes, 0)/1024/1024 used_space
  FROM 
    sys.dba_tablespaces d,  
    (select tablespace_name, sum(bytes) bytes, count(file_id) count
       from dba_temp_files group by tablespace_name) a, 
    (select  ss.tablespace_name , sum((ss.used_blocks*ts.blocksize))  bytes
        from gv$sort_segment ss, sys.ts$ ts where ss.tablespace_name = ts.name 
                 group by ss.tablespace_name) t
  WHERE 
    d.tablespace_name = a.tablespace_name(+)
    AND d.tablespace_name = t.tablespace_name(+) 
    AND d.extent_management like 'LOCAL'
    AND d.contents like 'TEMPORARY'
  ORDER BY 1
]]></Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
  </QueryDescriptor>
</Metric>


	<!-- ***************************************** -->
	<!-- Start db Configuration Metric Definitions -->
	<!-- Instance and Database Info -->
	<Metric NAME="db_dbNInstanceInfo" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_dbNInstanceInfo">mgmt_db_dbNInstanceInfo</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="database_name" COLUMN_NAME="database_name" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_database_name">DB Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="global_name" COLUMN_NAME="global_name" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_global_name">Global Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="banner" COLUMN_NAME="banner" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_banner">DB Version</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="host_name" COLUMN_NAME="host_name" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_host_name">Host Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="instance_name" COLUMN_NAME="instance_name" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_instance_name">Instance Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="startup_time" COLUMN_NAME="startup_time" TYPE="STRING" IS_DATE="TRUE" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_startup_time">Instance Startup Time</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="logins" COLUMN_NAME="logins" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_logins">Restricted Mode</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="log_mode" COLUMN_NAME="log_mode" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_log_mode">Log Mode</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="open_mode" COLUMN_NAME="open_mode" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_open_mode">Read Only Mode</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="characterset" COLUMN_NAME="characterset" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_characterset">Database Character Set</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="national_characterset" COLUMN_NAME="national_characterset" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_national_characterset">National Character Set</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="default_temp_tablespace" COLUMN_NAME="default_temp_tablespace" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_dbNInstanceInfo_default_temp_tablespace">Default Temporary Tablespace</Label>
				</Display>
			</ColumnDescriptor>
                         <ColumnDescriptor NAME="dv_status_code" COLUMN_NAME="dv_status_code" TYPE="NUMBER">
                        <Display>
                                <Label NLSID="dv_status_nlsid">Database Vault Status</Label>
                        </Display>
                        </ColumnDescriptor>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_dbNInstanceInfo_ecm"> 
   <ValidMidTierVersions END_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="database_name" REP_TABLE_COLUMN="database_name"/>
   <ColumnMapper METRIC_COLUMN="global_name" REP_TABLE_COLUMN="global_name"/>
   <ColumnMapper METRIC_COLUMN="banner" REP_TABLE_COLUMN="banner"/>
   <ColumnMapper METRIC_COLUMN="host_name" REP_TABLE_COLUMN="host_name"/>
   <ColumnMapper METRIC_COLUMN="instance_name" REP_TABLE_COLUMN="instance_name"/>
   <ColumnMapper METRIC_COLUMN="startup_time" REP_TABLE_COLUMN="startup_time"/>
   <ColumnMapper METRIC_COLUMN="logins" REP_TABLE_COLUMN="logins"/>
   <ColumnMapper METRIC_COLUMN="log_mode" REP_TABLE_COLUMN="log_mode"/>
   <ColumnMapper METRIC_COLUMN="open_mode" REP_TABLE_COLUMN="open_mode"/>
</CustomTableMapper>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_dbNInstanceInfo_ecm">
   <ValidMidTierVersions START_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="database_name" REP_TABLE_COLUMN="database_name"/>
   <ColumnMapper METRIC_COLUMN="global_name" REP_TABLE_COLUMN="global_name"/>
   <ColumnMapper METRIC_COLUMN="banner" REP_TABLE_COLUMN="banner"/>
   <ColumnMapper METRIC_COLUMN="host_name" REP_TABLE_COLUMN="host_name"/>
   <ColumnMapper METRIC_COLUMN="instance_name" REP_TABLE_COLUMN="instance_name"/>
   <ColumnMapper METRIC_COLUMN="startup_time" REP_TABLE_COLUMN="startup_time"/>
   <ColumnMapper METRIC_COLUMN="logins" REP_TABLE_COLUMN="logins"/>
   <ColumnMapper METRIC_COLUMN="log_mode" REP_TABLE_COLUMN="log_mode"/>
   <ColumnMapper METRIC_COLUMN="open_mode" REP_TABLE_COLUMN="open_mode"/>
   <ColumnMapper METRIC_COLUMN="characterset" REP_TABLE_COLUMN="characterset"/>
   <ColumnMapper METRIC_COLUMN="national_characterset" REP_TABLE_COLUMN="national_characterset"/>
   <ColumnMapper METRIC_COLUMN="default_temp_tablespace" REP_TABLE_COLUMN="default_temp_tablespace"/>
   <ColumnMapper METRIC_COLUMN="dv_status_code" REP_TABLE_COLUMN="dv_status_code"/>
</CustomTableMapper>
</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  a.name "DB Name",
            e.global_name "Global Name",
            b.banner "DB Version",
            c.host_name "Host Name",
            c.instance_name "Instance Name" ,
            to_char(c.startup_time,'YYYY-MM-DD HH24:MI:SS') "Instance Start Time",
            decode(c.logins,'RESTRICTED','YES','NO') "Restricted Mode",
            a.log_mode  "Archive Log Mode" ,
            decode(a.open_mode,'READ ONLY','YES','NO') "Read Only Mode",
            nlsp1.value,
            nlsp2.value
    FROM    v$database a,
            v$version b,
            v$instance c,
            global_name e,
            v$nls_parameters nlsp1,
            v$nls_parameters nlsp2
    WHERE   b.banner LIKE '%Oracle%' 
      AND   nlsp1.parameter = 'NLS_CHARACTERSET'
      AND   nlsp2.parameter = 'NLS_NCHAR_CHARACTERSET'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  a.name "DB Name",
            e.global_name "Global Name",
            b.banner "DB Version",
            c.host_name "Host Name",
            c.instance_name "Instance Name" ,
            to_char(c.startup_time,'YYYY-MM-DD HH24:MI:SS') "Instance Start Time",
            decode(c.logins,'RESTRICTED','YES','NO') "Restricted Mode",
            a.log_mode  "Archive Log Mode" ,
            decode(a.open_mode,'READ ONLY','YES','NO') "Read Only Mode",
            nlsp1.value,
            nlsp2.value,
            p.property_value,
            case when  (select count(*) from dba_users where username ='DVSYS' and user_id = 1279990)  > 0
                 then 
                        case when (select value from v$option where parameter ='Oracle Database Vault') ='TRUE'
                             then
                             1 -- Enabled
                             else
                             0 --Disabled 
                         end
                 when (select count(*) from dba_users where username ='DVSYS' and user_id = 1279990) = 0
                 then 
                        case when (select value from v$option where parameter ='Oracle Database Vault') = 'TRUE'
                             then
                             -1 -- Not Configured
                             else
                             -2 -- Not Installed
                         end
                 end
            dv_status_code
    FROM    v$database a,
            v$version b,
            v$instance c,
            global_name e,
            v$nls_parameters nlsp1,
            v$nls_parameters nlsp2,
            database_properties p
    WHERE   b.banner LIKE '%Oracle%' 
      AND   nlsp1.parameter = 'NLS_CHARACTERSET'
      AND   nlsp2.parameter = 'NLS_NCHAR_CHARACTERSET'
      AND   p.property_name = 'DEFAULT_TEMP_TABLESPACE'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<Metric NAME="db_init_params" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_init_params">mgmt_db_init_params</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_db_init_params_ecm">
			<ColumnDescriptor NAME="name" COLUMN_NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_init_params_name">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_init_params_value">Value</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="isdefault" COLUMN_NAME="isdefault" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_init_params_isdefault">Default</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  name,
            value,
            isdefault
    FROM    v$parameter
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!-- Modified / added fields -->
	<Metric NAME="db_redoLogs" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_redoLogs">mgmt_db_redoLogs</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="group_num" COLUMN_NAME="group_num" TYPE="NUMBER" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_redoLogs_group_num">Group</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="status" COLUMN_NAME="status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_redoLogs_status">Status</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="members" COLUMN_NAME="members" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_redoLogs_members">Members</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="file_name" COLUMN_NAME="file_name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_redoLogs_file_name">File Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="archived" COLUMN_NAME="Archived" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_redoLogs_archived">Archived</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="logsize" COLUMN_NAME="logsize" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_redoLogs_logsize">Log Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="sequence_num" COLUMN_NAME="sequence_num" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_redoLogs_sequence_num">Sequence Number</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="first_change_scn" COLUMN_NAME="first_change_scn" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_redoLogs_first_change">First Change</Label>
				</Display>
			</ColumnDescriptor>
                        <ColumnDescriptor NAME="os_storage_entity" COLUMN_NAME="os_storage_entity" TYPE="STRING" IS_KEY="FALSE">
				<Display>
                                	  <Label NLSID="db_redoLogs_os_storage_entity">Storage Entity</Label>
	                        </Display>
                        </ColumnDescriptor>
                        <ColumnDescriptor NAME="thread_num" COLUMN_NAME="thread_num" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
                                	  <Label NLSID="db_redoLogs_thread_num">Thread Num</Label>
	                        </Display>
                        </ColumnDescriptor>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_redoLogs_ecm"> 
   <ValidMidTierVersions END_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="group_num" REP_TABLE_COLUMN="group_num"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="members" REP_TABLE_COLUMN="members"/>
   <ColumnMapper METRIC_COLUMN="file_name" REP_TABLE_COLUMN="file_name"/>
   <ColumnMapper METRIC_COLUMN="archived" REP_TABLE_COLUMN="archived"/>
   <ColumnMapper METRIC_COLUMN="logsize" REP_TABLE_COLUMN="logsize"/>
   <ColumnMapper METRIC_COLUMN="sequence_num" REP_TABLE_COLUMN="sequence_num"/>
   <ColumnMapper METRIC_COLUMN="first_change_scn" REP_TABLE_COLUMN="first_change_scn"/>
</CustomTableMapper>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_redoLogs_ecm">
   <ValidMidTierVersions START_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="group_num" REP_TABLE_COLUMN="group_num"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="members" REP_TABLE_COLUMN="members"/>
   <ColumnMapper METRIC_COLUMN="file_name" REP_TABLE_COLUMN="file_name"/>
   <ColumnMapper METRIC_COLUMN="archived" REP_TABLE_COLUMN="archived"/>
   <ColumnMapper METRIC_COLUMN="logsize" REP_TABLE_COLUMN="logsize"/>
   <ColumnMapper METRIC_COLUMN="sequence_num" REP_TABLE_COLUMN="sequence_num"/>
   <ColumnMapper METRIC_COLUMN="first_change_scn" REP_TABLE_COLUMN="first_change_scn"/>
   <ColumnMapper METRIC_COLUMN="os_storage_entity" REP_TABLE_COLUMN="os_storage_entity"/>
   <ColumnMapper METRIC_COLUMN="thread_num" REP_TABLE_COLUMN="thread_num"/>
</CustomTableMapper>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">%perlBin%/perl %scriptsDir%/oracle_db_files.pl db_redologs</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
                        <Property NAME="ENVEM_AGENT_STATE" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
		</QueryDescriptor>
	</Metric>
	<!-- Modified / added fields -->
	<!-- Data files -->

 <!-- Datafile -->
 <!-- Collection Removed as part of VP request from April 28, 2004 -->
	<Metric NAME="db_datafiles" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_datafiles">mgmt_db_datafiles</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="file_name" 
                        COLUMN_NAME="file_name" 
                        TYPE="STRING" 
                        IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_datafiles_name">Datafile Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="status" 
                        COLUMN_NAME="status" 
                        TYPE="STRING" 
                        IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_datafiles_status">Status</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace_name" 
                        COLUMN_NAME="tablespace_name" 
                        TYPE="STRING" 
                        IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_datafiles_tablespace_name">Tablespace</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="file_size" 
                        COLUMN_NAME="file_size" 
                        TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_datafiles_file_size">File Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="autoextensible" 
                        COLUMN_NAME="autoextensible" 
                        TYPE="STRING" 
                        IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_datafiles_autoextensible">Autoextensible</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="increment_by" 
                        COLUMN_NAME="increment_by" 
                        TYPE="NUMBER" 
                        IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_datafiles_increment_by">Increment By</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="max_file_size" 
                        COLUMN_NAME="max_file_size" 
                        TYPE="NUMBER" 
                        IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_datafiles_max_file_size">Max File Size</Label>
				</Display>
			</ColumnDescriptor>
                        <ColumnDescriptor NAME="os_storage_entity" COLUMN_NAME="os_storage_entity" TYPE="STRING" IS_KEY="FALSE">
				<Display>
                                	  <Label NLSID="db_datafiles_os_storage_entity">Storage Entity</Label>
	                        </Display>
                        </ColumnDescriptor>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_datafiles_ecm"> 
   <ValidMidTierVersions END_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="file_name" REP_TABLE_COLUMN="file_name"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="tablespace_name" REP_TABLE_COLUMN="tablespace_name"/>
   <ColumnMapper METRIC_COLUMN="file_size" REP_TABLE_COLUMN="file_size"/>
   <ColumnMapper METRIC_COLUMN="autoextensible" REP_TABLE_COLUMN="autoextensible"/>
   <ColumnMapper METRIC_COLUMN="increment_by" REP_TABLE_COLUMN="increment_by"/>
   <ColumnMapper METRIC_COLUMN="max_file_size" REP_TABLE_COLUMN="max_file_size"/>
</CustomTableMapper>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_datafiles_ecm">
   <ValidMidTierVersions START_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="file_name" REP_TABLE_COLUMN="file_name"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="tablespace_name" REP_TABLE_COLUMN="tablespace_name"/>
   <ColumnMapper METRIC_COLUMN="file_size" REP_TABLE_COLUMN="file_size"/>
   <ColumnMapper METRIC_COLUMN="autoextensible" REP_TABLE_COLUMN="autoextensible"/>
   <ColumnMapper METRIC_COLUMN="increment_by" REP_TABLE_COLUMN="increment_by"/>
   <ColumnMapper METRIC_COLUMN="max_file_size" REP_TABLE_COLUMN="max_file_size"/>
   <ColumnMapper METRIC_COLUMN="os_storage_entity" REP_TABLE_COLUMN="os_storage_entity"/>
</CustomTableMapper>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2;9i;9iR2;10gR1"/>
</ValidIf>
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">%perlBin%/perl %scriptsDir%/oracle_db_files.pl db_datafiles</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
                        <Property NAME="ENVEM_AGENT_STATE" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1"/>
</ValidIf>
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">%perlBin%/perl %scriptsDir%/oracle_db_files.pl db_datafiles_10gR2</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
                        <Property NAME="ENVEM_AGENT_STATE" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
</ValidIf>
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">%perlBin%/perl %scriptsDir%/oracle_db_files.pl db_datafiles_11gR2</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
                        <Property NAME="ENVEM_AGENT_STATE" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
		</QueryDescriptor>
	</Metric>

	<!-- Modified / added fields -->
	<!-- Table Spaces -->
	<Metric NAME="db_tablespaces" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_tablespaces">mgmt_db_tablespaces</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="tablespace_name" COLUMN_NAME="tablespace_name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_tablespaces_name">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="status" COLUMN_NAME="status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_status">Status</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="contents" COLUMN_NAME="contents" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_contents">Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="extent_management" COLUMN_NAME="extent_management" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_extent_management">Extent Management</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="allocation_type" COLUMN_NAME="allocation_type" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_allocation_type">Allocation Type</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="logging" COLUMN_NAME="logging" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_logging">Logging</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace_size" COLUMN_NAME="tablespace_size" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_tablespace_size">Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="initial_ext_size" COLUMN_NAME="initial_ext_size" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_initial_ext_size">Initial Ext Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="next_extent" COLUMN_NAME="next_extent" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_next_extent">Next Extent</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="increment_by" COLUMN_NAME="increment_by" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_increment_by">Increment By</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="max_extents" COLUMN_NAME="max_extents" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_max_extents">Max Extents</Label>
				</Display>
			</ColumnDescriptor>
   <ColumnDescriptor NAME="tablespace_used_size" COLUMN_NAME="tablespace_used_size" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_tablespaces_tablespace_used_size">Used Size(B)</Label>
				</Display>
			</ColumnDescriptor>
   <ColumnDescriptor NAME="min_extents" COLUMN_NAME="min_extents" TYPE="NUMBER" IS_KEY="FALSE">
  			<Display>
    			<Label NLSID="db_tablespaces_min_extents">Minimum Extents</Label>
 				</Display>
			</ColumnDescriptor>
   <ColumnDescriptor NAME="min_extlen" COLUMN_NAME="min_extlen" TYPE="NUMBER" IS_KEY="FALSE">
  			<Display>
    			<Label NLSID="db_tablespaces_min_extlen">Minimum Extent Size</Label>
 				</Display>
			</ColumnDescriptor>
   <ColumnDescriptor NAME="segment_space_management" COLUMN_NAME="segment_space_management" TYPE="STRING" IS_KEY="FALSE">
  			<Display>
    			<Label NLSID="db_tablespaces_tablespace_seg_mgmt">Segment Space Management</Label>
 				</Display>
			</ColumnDescriptor>
   <ColumnDescriptor NAME="block_size" COLUMN_NAME="block_size" TYPE="NUMBER" IS_KEY="FALSE">
  			<Display>
    			<Label NLSID="db_tablespaces_block_size">Block Size</Label>
 				</Display>
			</ColumnDescriptor>
   <ColumnDescriptor NAME="bigfile" COLUMN_NAME="bigfile" TYPE="STRING" IS_KEY="FALSE">
  			<Display>
    			<Label NLSID="db_tablespaces_bigfile">Big File</Label>
 				</Display>
			</ColumnDescriptor>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_tablespaces_ecm"> 
   <ValidMidTierVersions END_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="tablespace_name" REP_TABLE_COLUMN="tablespace_name"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="contents" REP_TABLE_COLUMN="contents"/>
   <ColumnMapper METRIC_COLUMN="extent_management" REP_TABLE_COLUMN="extent_management"/>
   <ColumnMapper METRIC_COLUMN="allocation_type" REP_TABLE_COLUMN="allocation_type"/>
   <ColumnMapper METRIC_COLUMN="logging" REP_TABLE_COLUMN="logging"/>
   <ColumnMapper METRIC_COLUMN="tablespace_size" REP_TABLE_COLUMN="tablespace_size"/>
   <ColumnMapper METRIC_COLUMN="initial_ext_size" REP_TABLE_COLUMN="initial_ext_size"/>
   <ColumnMapper METRIC_COLUMN="next_extent" REP_TABLE_COLUMN="next_extent"/>
   <ColumnMapper METRIC_COLUMN="increment_by" REP_TABLE_COLUMN="increment_by"/>
   <ColumnMapper METRIC_COLUMN="max_extents" REP_TABLE_COLUMN="max_extents"/>
</CustomTableMapper>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_tablespaces_ecm">
   <ValidMidTierVersions START_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="tablespace_name" REP_TABLE_COLUMN="tablespace_name"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="contents" REP_TABLE_COLUMN="contents"/>
   <ColumnMapper METRIC_COLUMN="extent_management" REP_TABLE_COLUMN="extent_management"/>
   <ColumnMapper METRIC_COLUMN="allocation_type" REP_TABLE_COLUMN="allocation_type"/>
   <ColumnMapper METRIC_COLUMN="logging" REP_TABLE_COLUMN="logging"/>
   <ColumnMapper METRIC_COLUMN="tablespace_size" REP_TABLE_COLUMN="tablespace_size"/>
   <ColumnMapper METRIC_COLUMN="initial_ext_size" REP_TABLE_COLUMN="initial_ext_size"/>
   <ColumnMapper METRIC_COLUMN="next_extent" REP_TABLE_COLUMN="next_extent"/>
   <ColumnMapper METRIC_COLUMN="increment_by" REP_TABLE_COLUMN="increment_by"/>
   <ColumnMapper METRIC_COLUMN="max_extents" REP_TABLE_COLUMN="max_extents"/>
   <ColumnMapper METRIC_COLUMN="tablespace_used_size" REP_TABLE_COLUMN="tablespace_used_size"/>
   <ColumnMapper METRIC_COLUMN="min_extents" REP_TABLE_COLUMN="min_extents"/>
   <ColumnMapper METRIC_COLUMN="min_extlen" REP_TABLE_COLUMN="min_extlen"/>
   <ColumnMapper METRIC_COLUMN="segment_space_management" REP_TABLE_COLUMN="segment_space_management"/>
   <ColumnMapper METRIC_COLUMN="block_size" REP_TABLE_COLUMN="block_size"/>
   <ColumnMapper METRIC_COLUMN="bigfile" REP_TABLE_COLUMN="bigfile"/>
</CustomTableMapper>
		</TableDescriptor>
 		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  dtp.tablespace_name "TABLESPACE_NAME",
            dtp.status "STATUS",
            dtp.contents "CONTENTS",
            dtp.extent_management "EXTENT MANAGEMENT",
            dtp.allocation_type "ALLOCATION TYPE",
            dtp.logging "LOGGING",
            NVL(ts.bytes, 0) "SIZE (M)",
            dtp.initial_extent "INITIAL EXT SIZE (K)",
            dtp.next_extent "Next Extent",
            dtp.pct_increase "INCREMENT PCT",
            dtp.max_extents "MAX EXTENTS",
            NVL(ts.bytes - NVL(f.bytes,0),0) "USED BYTES",
            dtp.min_extents,
            dtp.min_extlen
    FROM    sys.dba_tablespaces dtp,
            (SELECT 	tablespace_name,
                        sum(bytes) bytes
             FROM	dba_data_files
             GROUP BY	tablespace_name) ts,
             (SELECT tablespace_name,sum(bytes) bytes from dba_free_space GROUP BY tablespace_name) f 
    WHERE   dtp.tablespace_name = ts.tablespace_name (+) AND 
            dtp.tablespace_name = f.tablespace_name (+) AND 
            NOT (dtp.extent_management LIKE 'LOCAL' AND
                 dtp.contents LIKE 'TEMPORARY')
    UNION ALL
    SELECT  dtp.tablespace_name "TABLESPACE_NAME",
            dtp.status "STATUS",
            dtp.contents "CONTENTS",
            dtp.extent_management "EXTENT MANAGEMENT",
            dtp.allocation_type "ALLOCATION TYPE",
            dtp.logging "LOGGING",
            NVL(a.bytes, 0) "SIZE (M)",
            dtp.initial_extent "INITIAL EXT SIZE (K)",
            dtp.next_extent "Next Extent",
            dtp.pct_increase "INCREMENT PCT",
            dtp.max_extents "MAX EXTENTS",
            NVL(t.bytes,0) "USED BYTES",
            dtp.min_extents,
            dtp.min_extlen
    FROM    sys.dba_tablespaces dtp,
            (SELECT 	tablespace_name,
                        sum(bytes) bytes
             FROM		  dba_temp_files
             GROUP BY	tablespace_name) a,
             (select  ss.tablespace_name , sum((ss.used_blocks*ts.blocksize))  bytes
                from gv$sort_segment ss, sys.ts$ ts where ss.tablespace_name = ts.name 
                group by ss.tablespace_name) t
    WHERE   dtp.tablespace_name = a.tablespace_name (+) AND 
            dtp.tablespace_name = t.tablespace_name (+) AND
            dtp.extent_management LIKE 'LOCAL' AND
            dtp.contents LIKE 'TEMPORARY'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
 		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  dtp.tablespace_name "TABLESPACE_NAME",
            dtp.status "STATUS",
            dtp.contents "CONTENTS",
            dtp.extent_management "EXTENT MANAGEMENT",
            dtp.allocation_type "ALLOCATION TYPE",
            dtp.logging "LOGGING",
            NVL(ts.bytes, 0) "SIZE (M)",
            dtp.initial_extent "INITIAL EXT SIZE (K)",
            dtp.next_extent "Next Extent",
            dtp.pct_increase "INCREMENT PCT",
            dtp.max_extents "MAX EXTENTS",
            NVL(ts.bytes - NVL(f.bytes,0),0) "USED BYTES",
            dtp.min_extents,
            dtp.min_extlen,
            dtp.segment_space_management "SEGMENT SPACE MANAGEMENT",
            dtp.block_size
    FROM    sys.dba_tablespaces dtp,
            (SELECT 	tablespace_name,
                        sum(bytes) bytes
             FROM	dba_data_files
             GROUP BY	tablespace_name) ts,
             (SELECT tablespace_name,sum(bytes) bytes from dba_free_space GROUP BY tablespace_name) f 
    WHERE   dtp.tablespace_name = ts.tablespace_name (+) AND 
            dtp.tablespace_name = f.tablespace_name (+) AND 
            NOT (dtp.extent_management LIKE 'LOCAL' AND
                 dtp.contents LIKE 'TEMPORARY')
    UNION ALL
    SELECT  dtp.tablespace_name "TABLESPACE_NAME",
            dtp.status "STATUS",
            dtp.contents "CONTENTS",
            dtp.extent_management "EXTENT MANAGEMENT",
            dtp.allocation_type "ALLOCATION TYPE",
            dtp.logging "LOGGING",
            NVL(a.bytes, 0) "SIZE (M)",
            dtp.initial_extent "INITIAL EXT SIZE (K)",
            dtp.next_extent "Next Extent",
            dtp.pct_increase "INCREMENT PCT",
            dtp.max_extents "MAX EXTENTS",
            NVL(t.bytes,0) "USED BYTES",
            dtp.min_extents,
            dtp.min_extlen,
            dtp.segment_space_management "SEGMENT SPACE MANAGEMENT",
            dtp.block_size
    FROM    sys.dba_tablespaces dtp,
            (SELECT 	tablespace_name,
                        sum(bytes) bytes
             FROM		  dba_temp_files
             GROUP BY	tablespace_name) a,
             (select  ss.tablespace_name , sum((ss.used_blocks*ts.blocksize))  bytes
                from gv$sort_segment ss, sys.ts$ ts where ss.tablespace_name = ts.name 
                group by ss.tablespace_name) t
    WHERE   dtp.tablespace_name = a.tablespace_name (+) AND 
            dtp.tablespace_name = t.tablespace_name (+) AND
            dtp.extent_management LIKE 'LOCAL' AND
            dtp.contents LIKE 'TEMPORARY'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2" />
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  dtp.tablespace_name "TABLESPACE_NAME",
            dtp.status "STATUS",
            dtp.contents "CONTENTS",
            dtp.extent_management "EXTENT MANAGEMENT",
            dtp.allocation_type "ALLOCATION TYPE",
            dtp.logging "LOGGING",
            NVL(ts.bytes, 0) "SIZE (M)",
            dtp.initial_extent "INITIAL EXT SIZE (K)",
            dtp.next_extent "Next Extent",
            dtp.pct_increase "INCREMENT PCT",
            dtp.max_extents "MAX EXTENTS",
            NVL(ts.bytes - NVL(f.bytes,0),0) "USED BYTES",
            dtp.min_extents,
            dtp.min_extlen,
            dtp.segment_space_management "SEGMENT SPACE MANAGEMENT",
            dtp.block_size,
            dtp.bigfile 
    FROM    sys.dba_tablespaces dtp,
            (SELECT 	tablespace_name,
                        sum(bytes) bytes
             FROM	dba_data_files
             GROUP BY	tablespace_name) ts,
             (SELECT tablespace_name,sum(bytes) bytes from dba_free_space GROUP BY tablespace_name) f 
    WHERE   dtp.tablespace_name = ts.tablespace_name (+) AND 
            dtp.tablespace_name = f.tablespace_name (+) AND 
            NOT (dtp.extent_management LIKE 'LOCAL' AND
                 dtp.contents LIKE 'TEMPORARY')
    UNION ALL
    SELECT  dtp.tablespace_name "TABLESPACE_NAME",
            dtp.status "STATUS",
            dtp.contents "CONTENTS",
            dtp.extent_management "EXTENT MANAGEMENT",
            dtp.allocation_type "ALLOCATION TYPE",
            dtp.logging "LOGGING",
            NVL(a.bytes, 0) "SIZE (M)",
            dtp.initial_extent "INITIAL EXT SIZE (K)",
            dtp.next_extent "Next Extent",
            dtp.pct_increase "INCREMENT PCT",
            dtp.max_extents "MAX EXTENTS",
            NVL(t.bytes,0) "USED BYTES",
            dtp.min_extents,
            dtp.min_extlen,
            dtp.segment_space_management "SEGMENT SPACE MANAGEMENT",
            dtp.block_size,
            dtp.bigfile 
    FROM    sys.dba_tablespaces dtp,
            (SELECT 	tablespace_name,
                        sum(bytes) bytes
             FROM		  dba_temp_files
             GROUP BY	tablespace_name) a,
             (select  ss.tablespace_name , sum((ss.used_blocks*ts.blocksize))  bytes
                from gv$sort_segment ss, sys.ts$ ts where ss.tablespace_name = ts.name 
                group by ss.tablespace_name) t
    WHERE   dtp.tablespace_name = a.tablespace_name (+) AND 
            dtp.tablespace_name = t.tablespace_name (+) AND
            dtp.extent_management LIKE 'LOCAL' AND
            dtp.contents LIKE 'TEMPORARY'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!-- Added new Metrics -->
	<!-- Control files -->
	<Metric NAME="db_controlfiles" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_controlfiles">mgmt_db_controlfiles</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="file_name" COLUMN_NAME="file_name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_controlfiles_file_name">File Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="status" COLUMN_NAME="status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_controlfiles_status">Status</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="creation_date" COLUMN_NAME="creation_date" TYPE="STRING" IS_DATE="TRUE" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_controlfiles_creation_date">Creation Date</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="sequence_num" COLUMN_NAME="sequence_num" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_controlfiles_sequence_num">Sequence Number</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="change_num" COLUMN_NAME="change_num" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_controlfiles_change_num">Change Number</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="mod_date" COLUMN_NAME="mod_date" TYPE="STRING" IS_DATE="TRUE" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_controlfiles_mod_date">Modification Date</Label>
				</Display>
			</ColumnDescriptor>
                        <ColumnDescriptor NAME="os_storage_entity" COLUMN_NAME="os_storage_entity" TYPE="STRING" IS_KEY="FALSE">
				<Display>
                                	  <Label NLSID="db_controlfiles_os_storage_entity">Storage Entity</Label>
	                        </Display>
                        </ColumnDescriptor>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_controlfiles_ecm"> 
   <ValidMidTierVersions END_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="file_name" REP_TABLE_COLUMN="file_name"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="creation_date" REP_TABLE_COLUMN="creation_date"/>
   <ColumnMapper METRIC_COLUMN="sequence_num" REP_TABLE_COLUMN="sequence_num"/>
   <ColumnMapper METRIC_COLUMN="change_num" REP_TABLE_COLUMN="change_num"/>
   <ColumnMapper METRIC_COLUMN="mod_date" REP_TABLE_COLUMN="mod_date"/>
</CustomTableMapper>
<CustomTableMapper REP_TABLE_NAME="mgmt_db_controlfiles_ecm">
   <ValidMidTierVersions START_VER="10.2.0.0.0"/>
   <ColumnMapper METRIC_COLUMN="file_name" REP_TABLE_COLUMN="file_name"/>
   <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
   <ColumnMapper METRIC_COLUMN="creation_date" REP_TABLE_COLUMN="creation_date"/>
   <ColumnMapper METRIC_COLUMN="sequence_num" REP_TABLE_COLUMN="sequence_num"/>
   <ColumnMapper METRIC_COLUMN="change_num" REP_TABLE_COLUMN="change_num"/>
   <ColumnMapper METRIC_COLUMN="mod_date" REP_TABLE_COLUMN="mod_date"/>
   <ColumnMapper METRIC_COLUMN="os_storage_entity" REP_TABLE_COLUMN="os_storage_entity"/>
</CustomTableMapper>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken">
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">%perlBin%/perl %scriptsDir%/oracle_db_files.pl db_controlfiles</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
                        <Property NAME="ENVEM_AGENT_STATE" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
		</QueryDescriptor>
	</Metric>
  
	<!-- Rollback Segments -->
	<Metric NAME="db_rollback_segs" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_rollback_segs">mgmt_db_rollback_segs</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_db_rollback_segs_ecm">
			<ColumnDescriptor NAME="rollname" COLUMN_NAME="rollname" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_rollback_segs_rollname">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="status" COLUMN_NAME="status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_status">Status</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="tablespace_name" COLUMN_NAME="tablespace_name" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_tablespace_name">Tablespace Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="extents" COLUMN_NAME="extents" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_extents">Extents</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="rollsize" COLUMN_NAME="rollsize" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_rollsize">Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="initial_size" COLUMN_NAME="initial_size" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_initial_size">Initial Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="next_size" COLUMN_NAME="next_size" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_next_size">Next Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="maximum_extents" COLUMN_NAME="maximum_extents" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_maximum_size">Maximum Size</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="minimum_extents" COLUMN_NAME="minimum_extents" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_minimum_extents">Minimum Extents</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="pct_increase" COLUMN_NAME="pct_increase" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_pct_increase">Pct Increase</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="optsize" COLUMN_NAME="optsize" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_optsize">Optsize</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="aveactive" COLUMN_NAME="aveactive" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_aveactive">Aveactive</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="wraps" COLUMN_NAME="wraps" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_wraps">Wraps</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="shrinks" COLUMN_NAME="shrinks" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_shrinks">Shrinks</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="aveshrink" COLUMN_NAME="aveshrink" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_aveshrink">Aveshrink</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="hwmsize" COLUMN_NAME="hwmsize" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_rollback_segs_hwmsize">Hwmsize</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
      SELECT  drs.segment_name "NAME",
              drs.status "STATUS",
              drs.tablespace_name "TABLESPACE",
              rs.extents "EXTENTS",
              rs.rssize "SIZE (M)",
              drs.initial_extent "INITIAL SIZE (K)",
              drs.next_extent "NEXT SIZE (K)",
              drs.max_extents "MAXIMUM EXTENTS",
              drs.min_extents "MINIMUM EXTENTS",
              drs.pct_increase "PCT INCREASE",
              rs.optsize "OPTSIZE",
              rs.aveactive "AVEACTIVE",
              rs.wraps "WRAPS",
              rs.shrinks "SHRINKS",
              rs.aveshrink "AVESHRINK",
              rs.hwmsize "HWMSIZE"
      FROM    sys.dba_rollback_segs drs,
              v$rollstat rs
      WHERE   drs.segment_id   = rs.usn (+)
              and substr(drs.segment_name,1,7) != '_SYSSMU'
  ]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!-- SGA Info -->
	<Metric NAME="db_sga" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_sga">mgmt_db_sga</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_db_sga_ecm">
			<ColumnDescriptor NAME="sganame" COLUMN_NAME="sganame" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_sga_sganame">SGA Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="sgasize" COLUMN_NAME="sgasize" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_sga_sgasize">Size</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
(SELECT 	'Shared Pool (MB)' "NAME",
          ROUND(NVL(sum(bytes)/1024/1024,0)) "SIZE"
 FROM 		v$sgastat
 WHERE		pool = 'shared pool')
UNION
(SELECT		'Buffered Cache (MB)' "NAME",
          ROUND(NVL(bytes/1024/1024,0)) "SIZE"
 FROM		  v$sgastat
 WHERE	( name = 'db_block_buffers'  AND pool IS NULL ) OR name = 'buffer_cache' )
UNION
(SELECT 	'Large Pool (KB)' "NAME",
          ROUND(NVL(sum(bytes)/1024,0)) "SIZE"
 FROM		  v$sgastat
 WHERE		pool = 'large pool')
UNION
(SELECT 	'Java Pool (MB)' "NAME",
          ROUND(NVL(sum(bytes)/1024/1024,0)) "SIZE"
 FROM		  v$sgastat
 WHERE		pool = 'java pool')
UNION
 (SELECT        'Fixed SGA (KB)' "NAME",
          ROUND(NVL(value/1024,0)) "SIZE"
  FROM           v$sga
  WHERE            name='Fixed Size')
UNION
 (SELECT        'Variable SGA (MB)' "NAME",
          ROUND(NVL(value/1024/1024,0)) "SIZE"
  FROM           v$sga
  WHERE            name='Variable Size')
UNION
 (SELECT        'Redo Buffers (KB)' "NAME",
          ROUND(NVL(value/1024,0)) "SIZE"
  FROM           v$sga
  WHERE            name='Redo Buffers')
UNION
 (SELECT 	'Total SGA (MB)' "NAME",
          ROUND(NVL(sum(bytes)/1024/1024,0)) "SIZE"
 FROM 		v$sgastat)
UNION
 (SELECT 	'Maximum SGA (MB)' "NAME",
          ROUND(NVL(sum(value)/1024/1024,0)) "SIZE"
 FROM 		v$sga)
ORDER BY	"SIZE"
  ]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
	<!-- Add License Info Metric -->
	<Metric NAME="db_license" TYPE="RAW" CONFIG="TRUE">
		<Display>
			<Label NLSID="db_license">mgmt_db_license</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_db_license_ecm">
			<ColumnDescriptor NAME="sessions_max" COLUMN_NAME="sessions_max" TYPE="NUMBER" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_license_sessions_max">Maximum Sessions</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="sessions_warning" COLUMN_NAME="sessions_warning" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_license_sessions_warning">Warning Sessions</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="sessions_current" COLUMN_NAME="sessions_current" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_license_sessions_current">Current Sessions</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="sessions_highwater" COLUMN_NAME="sessions_highwater" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_license_sessions_highwater">Highwater Sessions</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="users_max" COLUMN_NAME="users_max" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_license_users_max">Maximum Users</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
	SELECT  sessions_max "Maximum Sessions",
		sessions_warning "Warning Sessions",
		sessions_current "Current Sessions",
		sessions_highwater "Highwater Sessions",
		users_max "Maximum Users"
	FROM    v$license
  ]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>

	<Metric NAME="db_options" TYPE="RAW" CONFIG="TRUE">
                <ValidMidTierVersions START_VER="10.2.0.0.0"/>
		<Display>
			<Label NLSID="db_options">mgmt_db_options</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_db_options_ecm">
			<ColumnDescriptor NAME="name" COLUMN_NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="db_options_name">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="selected" COLUMN_NAME="selected" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_options_selected">Selected</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="pre8;8i;8iR2;9i"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
select 'INTER_MEDIA' as name, decode((select username from dba_users where username='ORDSYS'), 'ORDSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'SPATIAL' as name, decode((select username from dba_users where username='MDSYS'), 'MDSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'OLAP' as name, decode((select username from dba_users where username='OLAPSYS'), 'OLAPSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'ORACLE_TEXT' as name, decode((select username from dba_users where username='CTXSYS'), 'CTXSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'ULTRA_SEARCH' as name, decode((select username from dba_users where username='WKSYS'), 'WKSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'LABEL_SECURITY' as name, decode((select username from dba_users where username='LBACSYS'), 'LBACSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'SAMPLE_SCHEMA' as name, decode((select count(*) from dba_users where username IN('HR','PM','QS','SH','OE')), 0, 'FALSE', 'TRUE') as selected 
from dual
union
select 'JSERVER' as name, decode((select count(*) from sys.obj$ where type#=29), 0, 'FALSE', 'TRUE') as selected 
from dual
union
select 'ORACLE_DATA_MINING' as name, 'FALSE' as selected 
from dual
union
select 'XDB' as name, decode((select username from dba_users where username='XDB'), 'XDB', 'TRUE', 'FALSE') as selected 
from dual
union
select 'EM_REPOSITORY' as name, decode((select username from dba_users where username='SYSMAN'), 'SYSMAN', 'TRUE', 'FALSE') as selected 
from dual
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
select 'INTER_MEDIA' as name, decode((select username from dba_users where username='ORDSYS'), 'ORDSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'SPATIAL' as name, decode((select username from dba_users where username='MDSYS'), 'MDSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'OLAP' as name, decode((select username from dba_users where username='OLAPSYS'), 'OLAPSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'ORACLE_TEXT' as name, decode((select username from dba_users where username='CTXSYS'), 'CTXSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'ULTRA_SEARCH' as name, decode((select username from dba_users where username='WKSYS'), 'WKSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'LABEL_SECURITY' as name, decode((select username from dba_users where username='LBACSYS'), 'LBACSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'SAMPLE_SCHEMA' as name, decode((select count(*) from dba_users where username IN('HR','PM','QS','SH','OE')), 0, 'FALSE', 'TRUE') as selected 
from dual
union
select 'JSERVER' as name, decode((select count(*) from sys.obj$ where type#=29), 0, 'FALSE', 'TRUE') as selected 
from dual
union
select 'ORACLE_DATA_MINING' as name, decode((select status from dba_registry where comp_id='ODM'), 'VALID', 'TRUE', 'FALSE') as selected 
from dual
union
select 'XDB' as name, decode((select username from dba_users where username='XDB'), 'XDB', 'TRUE', 'FALSE') as selected 
from dual
union
select 'EM_REPOSITORY' as name, decode((select username from dba_users where username='SYSMAN'), 'SYSMAN', 'TRUE', 'FALSE') as selected 
from dual
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
<ValidIf>
  <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
select 'INTER_MEDIA' as name, decode((select username from dba_users where username='ORDSYS'), 'ORDSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'SPATIAL' as name, decode((select username from dba_users where username='MDSYS'), 'MDSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'OLAP' as name, decode((select username from dba_users where username='OLAPSYS'), 'OLAPSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'ORACLE_TEXT' as name, decode((select username from dba_users where username='CTXSYS'), 'CTXSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'ULTRA_SEARCH' as name, decode((select username from dba_users where username='WKSYS'), 'WKSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'LABEL_SECURITY' as name, decode((select username from dba_users where username='LBACSYS'), 'LBACSYS', 'TRUE', 'FALSE') as selected 
from dual
union
select 'SAMPLE_SCHEMA' as name, decode((select count(*) from dba_users where username IN('HR','PM','QS','SH','OE')), 0, 'FALSE', 'TRUE') as selected 
from dual
union
select 'JSERVER' as name, decode((select count(*) from sys."_CURRENT_EDITION_OBJ" where type#=29), 0, 'FALSE', 'TRUE') as selected 
from dual
union
select 'ORACLE_DATA_MINING' as name, decode((select status from dba_registry where comp_id='ODM'), 'VALID', 'TRUE', 'FALSE') as selected 
from dual
union
select 'XDB' as name, decode((select username from dba_users where username='XDB'), 'XDB', 'TRUE', 'FALSE') as selected 
from dual
union
select 'EM_REPOSITORY' as name, decode((select username from dba_users where username='SYSMAN'), 'SYSMAN', 'TRUE', 'FALSE') as selected 
from dual
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>

	<!-- End of db configuration metric definitions -->
	<!-- ****************************************** -->
	<!-- High Availability - Data Guard (DG) -->
	<Metric NAME="ha_info" TYPE="RAW" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		</ValidIf>
		<Display>
			<Label NLSID="ha_info">mgmt_ha_info</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_ha_info_ecm">
			<ColumnDescriptor NAME="dbid" COLUMN_NAME="dbid" TYPE="NUMBER" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_ha_dbid">Database ID</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="log_mode" COLUMN_NAME="log_mode" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_ha_log_mode">Log Mode</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="force_logging" COLUMN_NAME="force_logging" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_ha_force_logging">Force Logging</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="database_role" COLUMN_NAME="database_role" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_ha_database_role">Database Role</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="flashback_on" COLUMN_NAME="flashback_on" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="db_ha_flashback_on">Flashback On</Label>
				</Display>
			</ColumnDescriptor>
                        <ColumnDescriptor NAME="supplemental_logging" COLUMN_NAME="supplemental_logging" TYPE="STRING" IS_KEY="FALSE">
                                <Display>
                                        <Label NLSID="db_ha_supplemental_logging">Supplemental Logging</Label> 
                                </Display>
                        </ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2;9i"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  dbid "Database ID",
            log_mode "Log Mode"
    FROM    v$database
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="9iR2"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  dbid "Database ID",
            log_mode "Log Mode",
            force_logging "Force Logging",
            database_role "Database Role"
    FROM    v$database
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
    SELECT  dbid "Database ID",
            log_mode "Log Mode",
            force_logging "Force Logging",
            database_role "Database Role",
            flashback_on "Flashback On",
            supplemental_log_data_min "Supplemental Logging"
    FROM    v$database
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
<!--================================End of Configuration Metrics====================-->

	<!-- High Availability - RMAN Backup -->
	<Metric NAME="ha_backup" TYPE="RAW">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
             	<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="ha_backup">mgmt_ha_backup</Label>
		</Display>
		<TableDescriptor SKIP_COLLTIME_PK="TRUE" SKIP_METRIC_COLUMN="TRUE">
			<ColumnDescriptor NAME="end_time" COLUMN_NAME="end_time" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ha_backup_end_time">End Time</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="status" COLUMN_NAME="status" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ha_backup_status">Status</Label>
				</Display>
			</ColumnDescriptor>
    <ColumnDescriptor NAME="session_key" COLUMN_NAME="session_key" TYPE="NUMBER" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_session_key">Session Key</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="session_recid" COLUMN_NAME="session_recid" TYPE="NUMBER" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_session_recid">Session RECID</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="session_stamp" COLUMN_NAME="session_stamp" TYPE="NUMBER" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_session_stamp">Session Stamp</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="command_id" COLUMN_NAME="command_id" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_command_id">Command Id</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="start_time" COLUMN_NAME="start_time" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_start_time">Start Time</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="time_taken_display" COLUMN_NAME="time_taken_display" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_time_taken_display">Time Taken Display</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="input_type" COLUMN_NAME="input_type" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_input_type">Input Type</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="output_device_type" COLUMN_NAME="output_device_type" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_output_device_type">Output Device Type</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="input_bytes_display" COLUMN_NAME="input_bytes_display" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_input_bytes_display">Input Bytes Display</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="output_bytes_display" COLUMN_NAME="output_bytes_display" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_output_bytes_display">Output Bytes Display</Label>
            </Display>
    </ColumnDescriptor>
    <ColumnDescriptor NAME="output_bytes_per_sec_display" COLUMN_NAME="output_bytes_per_sec_display" TYPE="STRING" IS_KEY="FALSE">
            <Display>
                    <Label NLSID="ha_backup_output_bytes_per_sec_display">Output Bytes Display</Label>
            </Display>
    </ColumnDescriptor>
     <CustomTableMapper REP_TABLE_NAME="mgmt_ha_backup"> 
       <ValidMidTierVersions END_VER="10.2.0.0.0"/>
       <ColumnMapper METRIC_COLUMN="end_time" REP_TABLE_COLUMN="end_time"/>
       <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
     </CustomTableMapper>
     <CustomTableMapper REP_TABLE_NAME="mgmt_ha_backup">
       <ValidMidTierVersions START_VER="10.2.0.0.0"/>
       <ColumnMapper METRIC_COLUMN="end_time" REP_TABLE_COLUMN="end_time"/>
       <ColumnMapper METRIC_COLUMN="status" REP_TABLE_COLUMN="status"/>
       <ColumnMapper METRIC_COLUMN="session_key" REP_TABLE_COLUMN="session_key"/>
       <ColumnMapper METRIC_COLUMN="session_recid" REP_TABLE_COLUMN="session_recid"/>
       <ColumnMapper METRIC_COLUMN="session_stamp" REP_TABLE_COLUMN="session_stamp"/>
       <ColumnMapper METRIC_COLUMN="command_id" REP_TABLE_COLUMN="command_id"/>
       <ColumnMapper METRIC_COLUMN="start_time" REP_TABLE_COLUMN="start_time"/>
       <ColumnMapper METRIC_COLUMN="time_taken_display" REP_TABLE_COLUMN="time_taken_display"/>
       <ColumnMapper METRIC_COLUMN="input_type" REP_TABLE_COLUMN="input_type"/>
       <ColumnMapper METRIC_COLUMN="output_device_type" REP_TABLE_COLUMN="output_device_type"/>
       <ColumnMapper METRIC_COLUMN="input_bytes_display" REP_TABLE_COLUMN="input_bytes_display"/>
       <ColumnMapper METRIC_COLUMN="output_bytes_display" REP_TABLE_COLUMN="output_bytes_display"/>
       <ColumnMapper METRIC_COLUMN="output_bytes_per_sec_display" REP_TABLE_COLUMN="output_bytes_per_sec_display"/>
     </CustomTableMapper>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2;9i;9iR2"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
  SELECT MAX(completion_time)
  FROM
  (SELECT completion_time FROM v$backup_set
   UNION
   SELECT completion_time FROM v$datafile_copy)
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<ValidIf>
				<CategoryProp NAME="VersionCategory" CHOICES="10gR1"/>
			</ValidIf>
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
  SELECT  end_time,
          status
  FROM    v$rman_status
  WHERE   end_time = (select max(end_time) from v$rman_status where OPERATION='BACKUP')
  AND     operation='BACKUP'
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <ValidIf>
        <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
      </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
  SELECT end_time, status, session_key, session_recid, session_stamp, 
         command_id, start_time, time_taken_display, input_type, 
         output_device_type, input_bytes_display, 
         output_bytes_display, output_bytes_per_sec_display 
  FROM   (SELECT end_time, status, session_key, session_recid, 
                 session_stamp, command_id, start_time, 
                 time_taken_display, input_type, 
                 output_device_type, input_bytes_display, 
                 output_bytes_display, output_bytes_per_sec_display 
          FROM   v$rman_backup_job_details 
          ORDER BY end_time DESC) 
  WHERE   rownum = 1 
]]></Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
    
	</Metric>
	<!-- High Availability - RMAN Configuration -->
	<Metric NAME="ha_rman_config" TYPE="RAW" CONFIG="TRUE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		</ValidIf>
		<Display>
			<Label NLSID="ha_rman_config">mgmt_ha_rman_config</Label>
		</Display>
		<TableDescriptor TABLE_NAME="mgmt_ha_rman_config_ecm">
			<ColumnDescriptor NAME="name" COLUMN_NAME="name" TYPE="STRING" IS_KEY="TRUE">
				<Display>
					<Label NLSID="ha_rman_config_name">Name</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="FALSE">
				<Display>
					<Label NLSID="ha_rman_config_value">Value</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
(select 'CONTROLFILE AUTOBACKUP',
      nvl((select value from v$rman_configuration where name='CONTROLFILE AUTOBACKUP'),'') from dual)
UNION
(select name, value from v$rman_configuration where name='CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE' and value like 'DISK%')
]]></Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
	</Metric>
<!-- High Availability - Flash Recovery-->
   <Metric NAME="ha_flashrecovery" TYPE="TABLE">
       <ValidIf>
           <CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
   		   <CategoryProp NAME="MetricScope" CHOICES="DB"/>
       </ValidIf>
       <ValidMidTierVersions START_VER="10.2.0.0.0"/>
       <Display>
           <Label NLSID="ha_flashrecovery">Flash Recovery</Label>
       </Display>
       <TableDescriptor>
           <ColumnDescriptor NAME="log_mode" COLUMN_NAME="log_mode" TYPE="STRING" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_log_mode">Log Mode</Label>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="flash_recovery_area" COLUMN_NAME="flash_recovery_area" TYPE="STRING" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_flash_recovery_area">Flash Recovery Area</Label>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="usable_area" COLUMN_NAME="usable_area" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_usable_area">Usable Flash Recovery Area (%)</Label>
<Unit NLSID="em__sys__standard_percent">%</Unit>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="reclaimable_area" COLUMN_NAME="reclaimable_area" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_reclaimable_area">Reclaimable Flash Recovery Area (%)</Label>
                   <Unit NLSID="em__sys__standard_percent">%</Unit>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="nonreclaimable_area" COLUMN_NAME="nonreclaimable_area" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_nonreclaimable_area">Non-reclaimable Flash Recovery Area (%)</Label>
                   <Unit NLSID="em__sys__standard_percent">%</Unit>
               </Display> 
           </ColumnDescriptor>
           <ColumnDescriptor NAME="flashback_on" COLUMN_NAME="flashback_on" TYPE="STRING" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_flashback_on">Flashback On</Label>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="oldest_flashback_time" COLUMN_NAME="oldest_flashback_time" TYPE="STRING" IS_DATE="TRUE" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_oldest_flashback_time">Oldest Flashback Time</Label>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="flash_recovery_area_size" COLUMN_NAME="flash_recovery_area_size" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_flash_recovery_area_size">Flash Recovery Area Size</Label>
               </Display>
           </ColumnDescriptor>
       </TableDescriptor>
       <QueryDescriptor FETCHLET_ID="SQL">
           <ValidIf>
               <CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
           </ValidIf>
           <Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
DECLARE
  l_log_mode VARCHAR2(32);
  l_flashback_on VARCHAR2(32);
  l_flash_recovery_area VARCHAR2(512);
  l_flash_recovery_size NUMBER;
  l_usable_area NUMBER;
  l_space_used NUMBER;
  l_reclaimable_area NUMBER;
  l_nonreclaimable_area NUMBER;

  l_oldest_flashback_time VARCHAR2(512);
  TYPE data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;
  v_db_version VARCHAR2(10);
  db_version_102 CONSTANT VARCHAR2(10) := '10.2.0.0.0';
BEGIN
  -- Database version
  SELECT LPAD(version, 10, '0') INTO v_db_version
  FROM v$instance;

  -- Log Mode, Flashback On
  SELECT log_mode, flashback_on INTO l_log_mode, l_flashback_on
  FROM v$database;
  
  -- Flash Recovery Area/Size
  SELECT value INTO l_flash_recovery_area
  FROM v$parameter WHERE name='db_recovery_file_dest';

  SELECT value INTO l_flash_recovery_size
  FROM v$parameter WHERE name='db_recovery_file_dest_size';
  
  -- Usable Flash Recovery Area (10gR2)
  -- Reclaimable Flash Recovery Area (10gR2)
  -- Nonreclaimable Flash Recovery Area

  l_usable_area := NULL;
  l_reclaimable_area := NULL;
  l_nonreclaimable_area := NULL;
  l_space_used := NULL;

  IF (v_db_version >= db_version_102) THEN
    IF (length(l_flash_recovery_area) > 0) THEN
      EXECUTE IMMEDIATE
        'SELECT (CASE WHEN PERCENT_USED>  100 THEN 0 ELSE (100-PERCENT_USED) END) PERCENT_FREE
          FROM (SELECT (SUM(PERCENT_SPACE_USED)-SUM(PERCENT_SPACE_RECLAIMABLE)) PERCENT_USED FROM V$FLASH_RECOVERY_AREA_USAGE)'
        INTO l_usable_area;
     EXECUTE IMMEDIATE
        'SELECT SUM(PERCENT_SPACE_USED),SUM(PERCENT_SPACE_RECLAIMABLE) from v$flash_recovery_area_usage' INTO l_space_used, l_reclaimable_area;
      l_nonreclaimable_area := l_space_used - l_reclaimable_area;
    END IF;
  END IF;
  
  -- Oldest Flashback Time
  BEGIN
    SELECT to_char(oldest_flashback_time, 'YYYY-MM-DD HH24:MI:SS')
    INTO l_oldest_flashback_time FROM v$flashback_database_log;
  EXCEPTION
    WHEN OTHERS THEN l_oldest_flashback_time := '';
  END;
  
  OPEN data_cursor FOR
  SELECT l_log_mode, l_flash_recovery_area, l_usable_area, l_reclaimable_area, l_nonreclaimable_area, l_flashback_on, l_oldest_flashback_time, l_flash_recovery_size from dual;
  :1 := data_cursor;
END;
]]></Property>
           <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
           <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
           <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
           <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
           <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
           <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
           <Property NAME="password" SCOPE="INSTANCE">password</Property>
           <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
       </QueryDescriptor>
   </Metric>

 <!-- High Availability - Recovery-->
   <Metric NAME="ha_recovery" TYPE="TABLE">
       <ValidIf>
           <CategoryProp NAME="VersionCategory" CHOICES="8i;8iR2;9i;9iR2;10gR1;10gR2;10gR203"/>
           <CategoryProp NAME="MetricScope" CHOICES="DB"/>
       </ValidIf>
       <ValidMidTierVersions START_VER="10.2.0.0.0"/>
       <Display>
           <Label NLSID="ha_recovery">Recovery</Label>
       </Display>
       <TableDescriptor>
           <ColumnDescriptor NAME="missing_media_files" COLUMN_NAME="missing_media_files" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_missing_media_files">Missing Media File Count</Label>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="corrupt_data_blocks" COLUMN_NAME="corrupt_data_blocks" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_corrupt_data_blocks">Corrupt Data Block Count</Label>
               </Display>
           </ColumnDescriptor>
           <ColumnDescriptor NAME="datafiles_need_recovery" COLUMN_NAME="datafiles_need_recovery" TYPE="NUMBER" IS_KEY="FALSE">
               <Display>
                   <Label NLSID="ha_datafiles_need_recovery">Datafiles Need Media Recovery</Label>
               </Display>
           </ColumnDescriptor>
       </TableDescriptor>
       <QueryDescriptor FETCHLET_ID="SQL">
           <Property NAME="STATEMENT" SCOPE="GLOBAL"><![CDATA[
DECLARE
  l_missing_media_files NUMBER;
  l_corrupt_data_blocks NUMBER;
  l_datafiles_need_recovery NUMBER;
  TYPE data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;
  v_db_version VARCHAR2(10);
  db_version_92 CONSTANT VARCHAR2(10) := '09.2.0.0.0';
BEGIN
  -- Database version
  SELECT LPAD(version, 10, '0') INTO v_db_version
  FROM v$instance;

  -- Missing Media Files
  SELECT count(file#) INTO l_missing_media_files
  FROM v$datafile_header
  WHERE error is not null AND error != 'OFFLINE NORMAL';
  
  -- Datafiles Need Media Recovery
  SELECT count(file#) INTO l_datafiles_need_recovery
  FROM v$datafile_header
  WHERE recover ='YES';
  
  -- Corrupt Data Blocks (9iR2 or higher)
  l_corrupt_data_blocks := NULL;
  IF (v_db_version >= db_version_92) THEN
    EXECUTE IMMEDIATE
      'SELECT nvl(sum(blocks), 0) FROM v$database_block_corruption'
      INTO l_corrupt_data_blocks;
  END IF;
  
  OPEN data_cursor FOR
  SELECT l_missing_media_files, l_corrupt_data_blocks, l_datafiles_need_recovery from dual;
  :1 := data_cursor;
END;
]]></Property>
           <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
           <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
           <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
           <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
           <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
           <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
           <Property NAME="password" SCOPE="INSTANCE">password</Property>
           <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
       </QueryDescriptor>
   </Metric>

<!-- ESM database collection -->

<!--
  ======================================================================
  == Category:         Execute and other privileges for the same user on the directory object.
  == Collection Level: Config Metric
  == Purpose:          EM Security Policy
  ======================================================================
-->

<Metric NAME="esm_dirObjUsersWithExeAndOtherPrivs" 
        TYPE="RAW" 
        CONFIG="TRUE" 
        KEYS_ONLY="TRUE" 
        HELP="NO_HELP" >
        <ValidIf>
                <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
                <CategoryProp NAME="MetricScope" CHOICES="DB"/>
        </ValidIf>
        <Display>
               <Label NLSID="esm_dirObjUsersWithExeAndOtherPrivs">EXECUTE and READ/WRITE privileges for the same user on the directory object</Label>
        </Display>
        <TableDescriptor>
                <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
                <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
                <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
                <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
                        <ValidMidTierVersions END_VER="10.2.0.0.0"/>
                        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
                        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
                </CustomTableMapper>
                <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
                        <ValidMidTierVersions START_VER="10.2.0.0.0"/>
                        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
                        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
                        <ColumnMapper METRIC_COLUMN="value2" REP_TABLE_COLUMN="value2"/>
                </CustomTableMapper>
        </TableDescriptor>
        <QueryDescriptor FETCHLET_ID="SQL">
             <Property NAME="STATEMENT" SCOPE="GLOBAL">
               <![CDATA[
                        SELECT distinct 'esm_dirObjUsersWithExeAndOtherPrivs',
                            x.table_name, substr(dir.directory_path,0,60)
                        FROM dba_tab_privs x, dba_tab_privs o,
                             dba_directories dir, dba_objects
                        WHERE object_type='DIRECTORY'
                        AND x.table_name = object_name 
                        AND o.table_name = object_name 
                        AND dir.directory_name = x.table_name
                        AND x.privilege = 'EXECUTE' 
                        AND o.privilege <> 'EXECUTE'
                ]]>
                </Property>
                <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
                <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
                <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
                <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
                <Property NAME="password" SCOPE="INSTANCE">password</Property>
                <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
        </QueryDescriptor>
</Metric>

<!--
  ======================================================================
  == Category:         Execute privileges for PUBLIC on the directory object.
  == Collection Level: Config Metric
  == Purpose:          EM Security Policy
  ======================================================================
-->

<Metric NAME="esm_publicHavingExePrivOnDirObj" 
        TYPE="RAW" 
        CONFIG="TRUE" 
        KEYS_ONLY="TRUE" 
        HELP="NO_HELP" >
        <ValidIf>
                <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
                <CategoryProp NAME="MetricScope" CHOICES="DB"/>
        </ValidIf>
        <Display>
               <Label NLSID="esm_publicHavingExePrivOnDirObj">EXECUTE privileges for PUBLIC on the directory object</Label>
        </Display>

        <TableDescriptor>
                <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
                <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
                <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
                <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
                        <ValidMidTierVersions END_VER="10.2.0.0.0"/>
                        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
                        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
                </CustomTableMapper>
                <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
                        <ValidMidTierVersions START_VER="10.2.0.0.0"/>
                        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
                        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
                        <ColumnMapper METRIC_COLUMN="value2" REP_TABLE_COLUMN="value2"/>
                </CustomTableMapper>
        </TableDescriptor>
        <QueryDescriptor FETCHLET_ID="SQL">
            <Property NAME="STATEMENT" SCOPE="GLOBAL">
                <![CDATA[
                         SELECT 'esm_publicHavingExePrivOnDirObj', 
                               table_name, substr(directory_path,0,60)
                         FROM dba_tab_privs, dba_objects, dba_directories 
                         WHERE table_name = object_name 
                         AND directory_name = table_name
                         AND privilege = 'EXECUTE' 
                         AND object_type = 'DIRECTORY' 
                         AND dba_tab_privs.grantee = 'PUBLIC'
                ]]>
                </Property>
                <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
                <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
                <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
                <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
                <Property NAME="password" SCOPE="INSTANCE">password</Property>
                <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
        </QueryDescriptor>
</Metric>


  <Metric NAME="installAndDemoAcccounts" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE" HELP="NO_HELP" >
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
	<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="install_demo_accounts">Default Install and Demo Accounts</Label>
    </Display>
     <TableDescriptor >

      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>

      <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
        <ValidMidTierVersions END_VER="10.2.0.0.0"/>
        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
      </CustomTableMapper>
      <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
        <ValidMidTierVersions START_VER="10.2.0.0.0"/>
        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
        <ColumnMapper METRIC_COLUMN="value2" REP_TABLE_COLUMN="value2"/>
      </CustomTableMapper>

    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
  oms_ver_short VARCHAR2(5);
  max_row       NUMBER ; 
  oms_ver       VARCHAR2(30) ;
  sql_stmt1     VARCHAR2(600) ; 
  sql_stmt2     VARCHAR2(700) ; 
  TYPE         data_cursor_type IS REF CURSOR;
  data_cursor  data_cursor_type;

BEGIN

max_row := :1 ;
oms_ver := :2 ;
sql_stmt1 := ' from SYS.USER$ U, SYS.USER_ASTATUS_MAP M '||
' where U.name IN (
			''ADAMS'',
			''BLAKE'',
			''CLARK'',
			''CTXSYS'',
			''HR'',
			''JONES'',
			''LBACSYS'',
			''MDSYS'',
			''OE'',
			''OLAPDBA'',
			''OLAPSVR'',
			''OLAPSYS'',
			''ORDPLUGINS'',
			''ORDSYS'',
			''PM'',
			''QS'',
			''QS_ADM'',
			''QS_CB'',
			''QS_CBADM'',
			''QS_CS'',
			''QS_ES'',
			''QS_OS'',
			''QS_WS'',
			''SH'',
			''ANONYMOUS'',
			''ODM_MTR'',
			''ODM'',
			''OUTLN'',
			''WKPROXY'',
			''WKSYS'',
			''WMSYS'',
			''XDB'') '||
'AND U.astatus <> 9 ' ||
'AND U.astatus = M.status# ' ||
'AND U.type# = 1 ' ||
'AND rownum <= '||'decode( '||max_row||', ''-1'' , 2147483647, '||max_row||') ';
oms_ver_short := substr(oms_ver,1,4) ;
if oms_ver_short = '10.1' then
    sql_stmt2 :=  'select  ''default user account'', '||'U.name || ''('' || LOWER( M.status ) || '')'' '||sql_stmt1 ;
else
    sql_stmt2 := 'select ''default_user_account'', U.name, M.status '||sql_stmt1 ; 
end if ;

OPEN data_cursor FOR
sql_stmt2;

:3 := data_cursor;
END ;
]]>
     </Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">well_known_ac</Property>
      <Property NAME="SQLINPARAM2" SCOPE="SYSTEMGLOBAL">OMS_VERSION</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">3</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="defaultAccountPasswords" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE" HELP="NO_HELP" >
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
	<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="default_user_password">Default Users and Passwords</Label>
    </Display>
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="FILENAME" SCOPE="GLOBAL">%scriptsDir%/db/dfltAccPwd.sql</Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">default_pwd</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="systemPrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE" HELP="NO_HELP" >
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
	<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="system_privileges">System Privileges for Public Role</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
SELECT  DISTINCT 'PUBLIC has SYSTEM privilege', privilege
FROM	dba_sys_privs d,
	(	SELECT DISTINCT(granted_role)
		FROM dba_role_privs
		START WITH grantee = 'PUBLIC'
		CONNECT BY PRIOR granted_role = grantee
	UNION
		SELECT 'PUBLIC' AS granted_role FROM dual
	) r
WHERE r.granted_role = d.grantee
AND rownum <= decode(:1,'-1',2147483647,:1)
ORDER BY privilege
]]>
      </Property>
       <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">pub_sys_priv</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>

    </QueryDescriptor>
</Metric>



  <Metric NAME="executePrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE" HELP="NO_HELP" >
    <ValidIf>
    <CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
    <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="execute_privilege">Object Execute Privilege for Public Role</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
   
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
  oms_ver_short VARCHAR2(4) ;
  oms_ver       VARCHAR2(30) := :1;
  sql_stmt1     VARCHAR2(400) ; 
  sql_stmt21     VARCHAR2(400) ; 
  sql_stmt22     VARCHAR2(400) ; 
  sql_stmt23     VARCHAR2(400) ; 
  sql_stmt3     VARCHAR2(1000) ; 
  utl_max VARCHAR2(30) := :2;
  smtp_max VARCHAR2(30) := :3;
  http_max VARCHAR2(30) := :4;
  tcp_max VARCHAR2(30) := :5;
  TYPE         data_cursor_type IS REF CURSOR;
  data_cursor  data_cursor_type;
BEGIN
sql_stmt1 := 'SELECT DISTINCT ''PUBLIC can execute'', table_name '||
'FROM  dba_tab_privs WHERE owner = ''SYS'' ' ||
'AND ( 
        grantee = ''PUBLIC''
        OR
        grantee IN
        (SELECT granted_role
          FROM  dba_role_privs
          START WITH grantee = ''PUBLIC''
          CONNECT BY PRIOR granted_role = grantee)
  ) AND ' ; 
oms_ver_short := substr(oms_ver,1,4) ; 
if oms_ver_short = '10.1' then
    sql_stmt21 := sql_stmt1||'table_name = ''UTL_SMTP'' AND rownum <= decode('||smtp_max||',''-1'',2147483647,'||smtp_max||')';
    sql_stmt22 := sql_stmt1||'table_name = ''UTL_HTTP'' AND rownum <= decode('||http_max||',''-1'',2147483647,'||http_max||')';
    sql_stmt23 := sql_stmt1||'table_name = ''UTL_TCP'' AND rownum <= decode('||tcp_max||',''-1'',2147483647,'||tcp_max||')';
    sql_stmt3 := sql_stmt1||'table_name IN (''DBMS_RANDOM'',''UTL_FILE'') AND rownum <= decode('||utl_max||',''-1'',2147483647,'||utl_max||')';
else
    sql_stmt21 := sql_stmt1||'table_name = ''UTL_SMTP'' AND rownum <= decode('||smtp_max||',''-1'',2147483647,'||smtp_max||')';
    sql_stmt22 := sql_stmt1||'table_name = ''UTL_HTTP'' AND rownum <= decode('||http_max||',''-1'',2147483647,'||http_max||')';
    sql_stmt23 := sql_stmt1||'table_name = ''UTL_TCP'' AND rownum <= decode('||tcp_max||',''-1'',2147483647,'||tcp_max||')';
    sql_stmt3 := sql_stmt1||'table_name IN(''UTL_FILE'',''DBMS_SYS_SQL'',''DBMS_JOB'',''DBMS_LOB'') AND rownum <= decode('||utl_max||',''-1'',2147483647,'||utl_max||')';
end if ; 
OPEN data_cursor FOR 
sql_stmt21 || ' UNION ' || sql_stmt22 || ' UNION ' || sql_stmt23 || ' UNION ' || sql_stmt3;
:6 := data_cursor;
END ;
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="SYSTEMGLOBAL">OMS_VERSION</Property>
      <Property NAME="SQLINPARAM2" SCOPE="INSTANCE">public_execute_UTL_max</Property>
      <Property NAME="SQLINPARAM3" SCOPE="INSTANCE">public_execute_UTL_SMTP_max</Property>
      <Property NAME="SQLINPARAM4" SCOPE="INSTANCE">public_execute_UTL_HTTP_max</Property>
      <Property NAME="SQLINPARAM5" SCOPE="INSTANCE">public_execute_UTL_TCP_max</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">6</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="unlimitedFailedLoginAttempts" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE" HELP="NO_HELP" >
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
	<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="unlimited_login_attempts">Number of Failed Login Attempts</Label>
    </Display>
      <TableDescriptor>

      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP"/>

      <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
        <ValidMidTierVersions END_VER="10.2.0.0.0"/>
        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
      </CustomTableMapper>
      <CustomTableMapper REP_TABLE_NAME="esm_collection"> 
        <ValidMidTierVersions START_VER="10.2.0.0.0"/>
        <ColumnMapper METRIC_COLUMN="property" REP_TABLE_COLUMN="property"/>
        <ColumnMapper METRIC_COLUMN="value" REP_TABLE_COLUMN="value"/>
        <ColumnMapper METRIC_COLUMN="value2" REP_TABLE_COLUMN="value2"/>
      </CustomTableMapper>
      
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
    <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
  oms_ver_short VARCHAR2(40);
  max_row       NUMBER;
  oms_ver      VARCHAR2(30) ;
  sql_stmt     VARCHAR2(600) ; 
  TYPE         data_cursor_type IS REF CURSOR;
  data_cursor  data_cursor_type;
  
BEGIN
max_row := :1 ;
oms_ver := :2 ;
oms_ver_short := substr(oms_ver,1,4) ;
IF oms_ver_short = '10.1' then
 sql_stmt :=  'SELECT DISTINCT ''Unlimited login attempts'', u.username '||
 'FROM dba_users u, dba_profiles p '||
 'WHERE p.resource_name = ''FAILED_LOGIN_ATTEMPTS'' AND  u.profile = p.profile '||
 'AND p.limit = ''UNLIMITED'' AND  rownum <= '||'decode( '||max_row||', ''-1'' , 2147483647, '||max_row||') '|| 'ORDER BY u.username ' ;
ELSE
 sql_stmt := 'SELECT  DISTINCT ''Unlimited_login_attempts'',profile,limit
  FROM(
   SELECT ''Unlimited_login_attempts'',profile,limit
   FROM dba_profiles
   WHERE resource_name = ''FAILED_LOGIN_ATTEMPTS'' AND limit <>''DEFAULT''
   union
   SELECT ''Unlimited_login_attempts'',up.profile,def.limit
   FROM dba_profiles up,dba_profiles def
   where up.resource_name = ''FAILED_LOGIN_ATTEMPTS'' AND up.resource_name = def.resource_name
   AND up.limit=def.profile AND up.limit=''DEFAULT''
   ) '||
   'WHERE rownum <= '||'decode( '||max_row||', ''-1'' , 2147483647, '||max_row||') '||
   'ORDER BY profile' ;
END IF ;

OPEN data_cursor FOR
sql_stmt;

:4 := data_cursor;
END ;
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">failed_login_at</Property>
      <Property NAME="SQLINPARAM2" SCOPE="SYSTEMGLOBAL">OMS_VERSION</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">4</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>

    </QueryDescriptor>
  </Metric>


  <!-- 
  ======================================================================
  == Category:         Storage
  == Collection Level: Minimum
  == Purpose:          Count of segment advisor recommendations
  ======================================================================    
  --> 
 <Metric NAME="segment_advisor_count" TYPE="TABLE">
    <ValidIf>
      <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2" /> 
  	  <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="segment_advisor_count">Segment Advisor Recommendations</Label> 
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="recommendations" TYPE="NUMBER" IS_KEY="FALSE">
        <Display>
          <Label NLSID="database_stg_segAdv_count">Number of recommendations</Label> 
        </Display>
      </ColumnDescriptor>
     </TableDescriptor>
     <QueryDescriptor FETCHLET_ID="OSLineToken">
      <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
      <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
      <Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/segAdv.pl</Property>
      <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
      <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
      <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
      <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
      <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
      <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
      <Property NAME="ENVEM_AGENT_STATE_DIR" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
      <Property NAME="ENVEM_TARGET_GUID" SCOPE="INSTANCE">GUID</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
      <Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>

      </QueryDescriptor>
  </Metric>

<!-- ESA REPORT database collection start here-->
  <Metric NAME="privsWithAdminOption" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	 <CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
     <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="with_admin_option">Privileges granted with WITH ADMIN option</Label>
    </Display>
   
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
   select grantee,granted_role,'WITH_ADMIN'
   from dba_role_privs where admin_option='YES' AND rownum < 100
   union 
   select grantee,privilege,'WITH_ADMIN'
   from dba_sys_privs where admin_option='YES' AND rownum < 100
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="privsWithGrantOption" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <!-- database-specific -->
   <ValidMidTierVersions START_VER="10.2.0.0.0" />
   <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="with_grant_option">Privileges granted with WITH GRANT option</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
   select grantee,privilege,'WITH_GRANT'
   from dba_col_privs where grantable='YES' AND rownum < 100
   union 
   select grantee,privilege,'WITH_GRANT'
   from dba_tab_privs where grantable='YES' AND rownum < 100
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>
  <Metric NAME="exemptAccessPolicy" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
   <ValidMidTierVersions START_VER="10.2.0.0.0" />  
   <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
	      <Label NLSID="exempt_access_policy_privs">Users with EXEMPT ACCESS POLICY privileges</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl EXEMPT_ACCESS_POLICY
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<!--select grantee,privilege, 'EXEMPT_ACCESS_POLICY' from  dba_sys_privs where privilege = 'EXEMPT ACCESS POLICY'-->
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'EXEMPT_ACCESS_POLICY'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name = 'EXEMPT ACCESS POLICY'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="dbaRole" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
   <ValidMidTierVersions START_VER="10.2.0.0.0" />  
   <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="dba_role">Users with DBA roles</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl DBA_ROLE
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'DBA_ROLE'
from
  (
   select
      null   p,
      role   c
    from
      dba_roles
    where
      role in  ('DBA')
  union
    select
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
   </Metric>


  <Metric NAME="createPrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <!-- database-specific -->
  <ValidMidTierVersions START_VER="10.2.0.0.0" /> 
   <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="create_privs">Users with CREATE privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl CREATE_PRIVILEGE
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'CREATE_PRIVILEGE'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name like '%CREATE%'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="catalogRole" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="catalog_roles">Users with CATALOG roles</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl CATALOG_ROLE
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
	<QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select distinct
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'CATALOG_ROLE'
from
  (
   select
      null   p,
      role   c
    from
      dba_roles
    where
      role like '%_CATALOG_%'
  union
    select
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>

  </Metric>


  <Metric NAME="becomeUserPriv" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <!-- database-specific -->
   <ValidMidTierVersions START_VER="10.2.0.0.0" />
   <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="become_user_privs">Users with BECOME USER privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl BECOME_USER
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'BECOME_USER'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name = 'BECOME USER'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="auditSystemPriv" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="audit_sys_privs">Users with AUDIT SYSTEM privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl AUDIT_SYSTEM
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'AUDIT_SYSTEM'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name = 'AUDIT SYSTEM'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>


 <Metric NAME="anyDictionaryPriv" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="any_dictionary_privs">Users with ANY DICTIONARY privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl ANY_DICTIONARY
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'ANY_DICTIONARY'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name like '%ANY DICTIONARY%'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>
 
 <Metric NAME="directPrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" /> 
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
		<CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="users_with_direct_privs">Users with direct privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    
	<QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
     select grantee,privilege,'DIRECT_PRIVILEGES'
     from dba_sys_privs 
     where grantee not in(select role from dba_roles)
     and rownum < 200
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>
  <Metric NAME="sysPublicPackage" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="sys_public_package">System Public Package</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
    select distinct grantee ,table_name,'SYS_PUBLIC_PACKAGE'
    from dba_tab_privs
    where grantee = 'PUBLIC' 
    AND owner = 'SYS'

    AND privilege='EXECUTE' 
    AND table_name not in ('DBMS_LOB', 'DBMS_SQL', 'DBMS_SYS_SQL')
    AND rownum < 200
    union
	--need all the 3 rows for the report
	select distinct grantee ,table_name,'SYS_PUBLIC_PACKAGE'
    from dba_tab_privs
    where grantee = 'PUBLIC' 
    AND owner = 'SYS'
    AND privilege='EXECUTE'
    AND table_name in ('DBMS_LOB', 'DBMS_SQL', 'DBMS_SYS_SQL')
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="connectRole" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
   <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="connect_role">Connect Role</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl CONNECT_PRIVILEGE
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select distinct
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'CONNECT_PRIVILEGE'
from
  (
   select
      null   p,
      role   c
    from
      dba_roles
    where
      role in ('RESOURCE', 'CONNECT')
  union
    select
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>
 <Metric NAME="allPrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="all_privilege">ALL Privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl ALL_PRIVILEGES
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'ALL_PRIVILEGES'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name = 'GRANT ANY PRIVILEGE'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>
 <Metric NAME="anyPrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="any_privilege">ANY Privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl ANY_PRIVILEGE
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select * from (
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'ANY_PRIVILEGE'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name like '%ANY%'
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) 
start with p is null
connect by p = prior c )
where rownum < 200
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>
 <Metric NAME="powerPrivileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="power_privilege">Power Privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="8iR2"/>
        </ValidIf>
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/esaPrivReports.pl POWER_PRIVILEGE
        </Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		 <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
	</QueryDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
        <ValidIf>
    	<CategoryProp NAME="VersionCategory" CHOICES="9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
        </ValidIf>
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
select 
  substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c, 'POWER_PRIVILEGE'
from
  (
   select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name in ('ALTER SESSION','ALTER SYSTEM','CREATE PROCEDURE','CREATE LIBRARY')
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
  where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum < 200
start with p is null
connect by p = prior c
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>


<Metric NAME="dbaGroupAssign" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="dba_group">DBA Group Assignment</Label>
	</Display>
	<TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
		<ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
		</ColumnDescriptor>
		<ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
		</ColumnDescriptor>
		<ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
		</ColumnDescriptor>
	</TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%//db/dbaGroupAssign.pl</Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
	</QueryDescriptor>
</Metric>																								

<Metric NAME="tableSpaceOwners" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="tablespace_owners">List tablespaces and their owners</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
    select distinct ts.name , us.name, 'TABLESPACE_OWNERS'
    from sys.ts$ ts, sys.user$ us, sys.seg$ seg
    where seg.user# = us.user# and ts.ts# = seg.ts# and ts.name in ('SYSTEM', 'SYSAUX')
    and us.name not in ('SYS','SYSTEM')
    and rownum < 200
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>
  

<Metric NAME="sysPublicExePrivs" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="sys_public_execute_privs">List sys owned packages having public execute privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
	select 'PUBLIC', table_name, 'SYS_PUBLIC_EXECUTE'
	from sys.dba_tab_privs
	where grantee = 'PUBLIC'
	and table_name in (select object_name
			from dba_objects
			where owner='SYS' and object_type='PACKAGE')
	and privilege='EXECUTE'
	and not exists (select 'w'
		from sys.dba_roles
		where role=grantee)
        and rownum < 200
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>

 <Metric NAME="publicPermissions" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="public_permissions">List sys owned packages having public execute privileges</Label>
    </Display>
    <TableDescriptor TABLE_NAME="MGMT_ESA_REPORT">
      <ColumnDescriptor NAME="PRINCIPAL" COLUMN_NAME="PRINCIPAL" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="OBJECT_NAME" COLUMN_NAME="OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="REPORT_NAME" COLUMN_NAME="REPORT_NAME" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[	
select distinct 'SYSTEM' as principal, "PRIVILEGE" as object_name, 'PUBLIC_PRIVILEGE' as REPORT_NAME
from dba_sys_privs 
where grantee='PUBLIC' and rownum < 50
union
select distinct table_name as principal, "PRIVILEGE" as object_name, 'PUBLIC_PRIVILEGE' as REPORT_NAME
from dba_tab_privs 
where grantee ='PUBLIC' and rownum < 50
union
select distinct table_name as principal, "PRIVILEGE" as object_name, 'PUBLIC_PRIVILEGE' as REPORT_NAME
from dba_col_privs 
where grantee ='PUBLIC' and rownum < 50
union
select distinct GRANTED_ROLE as principal, 'ROLE' as object_name, 'PUBLIC_PRIVILEGE' as REPORT_NAME
from dba_role_privs 
where grantee ='PUBLIC' and rownum < 50
]]>
      </Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>



<!-- ESA REPORT database collection ends here-->

<!-- ESA database collection starts -->
  <Metric NAME="dbLinkUsage" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific, links common to all instances -->
   <ValidMidTierVersions START_VER="10.2.0.0.0" />
   <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
   </ValidIf>
   <Display>
      <Label NLSID="db_link_usage">DB Link Usage</Label>
    </Display>
         
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
      <![CDATA[
        SELECT 'db_link_with_password'"property",name,'NA' 
        FROM sys.link$ where password is not null
        AND rownum <= decode(:1,'-1',2147483647,:1)
        ORDER BY name
      ]]>
      </Property>
       <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">db_link_pwd</Property> 
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="tableSpaces" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="table_spaces">Temp and Default Table Spaces</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
      <![CDATA[
       select 'table_space_quotas', USERNAME, TABLESPACE_NAME
       from dba_ts_quotas
       where (max_bytes = -1 OR max_blocks = -1)  
       AND
       username not in ('SYS', 'SYSTEM', 'SYSMAN', 'CTXSYS', 'MDSYS', 'ORDSYS', 'ORDPLUGINS','OLAPSYS', 'DBSNMP', 'MGMT_VIEW', 'OUTLN', 'ANONYMOUS', 'DMSYS', 
'EXFSYS','LBACSYS', 'SI_INFORMTN_SCHEMA', 'SYSMAN', 'WKPROXY', 'WKSYS', 'WK_TEST','WMSYS', 'XDB', 'TRACESVR', 'SCOTT', 'ADAMS', 'BLAKE', 'CLARK', 'JONES', 'HR')            
       AND rownum <= decode(:1,'-1',2147483647,:1)
       ORDER BY USERNAME
      ]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">dba_ts_quotas</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>
 
 <Metric NAME="dbPasswordSetting" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
    <!-- database-specific, profiles common to all instances-->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="db_password_setting">DB Password Setting</Label>
    </Display>
         
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>		
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>		
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
 <![CDATA[
   with pwd  as (select :1 as life_time, :2 as reuse_max,:3 as reuse_time,:4 as lock_time,:5 as grace_time,:6 as pwd_cmplx_fn from dual)
    select 'password_life_time',limit,profile
    from (
        SELECT 'password_life_time',limit,profile
        FROM dba_profiles
        WHERE resource_name = 'PASSWORD_LIFE_TIME' AND limit <>'DEFAULT'
        union
        select 'password_life_time',def.limit,up.profile
        FROM dba_profiles up,dba_profiles def
        where up.resource_name = 'PASSWORD_LIFE_TIME' AND up.resource_name = def.resource_name
        AND up.limit=def.profile AND up.limit='DEFAULT'
      )
     where rownum <= decode((select life_time from pwd),'-1',2147483647,(select life_time from pwd))

     union
   select  'password_reuse_max',limit,profile
     from (
        SELECT 'password_reuse_max',limit,profile
        FROM dba_profiles
        WHERE resource_name = 'PASSWORD_REUSE_MAX' AND limit <>'DEFAULT'
        union
        select 'password_reuse_max',def.limit,up.profile
        FROM dba_profiles up,dba_profiles def
        where up.resource_name = 'PASSWORD_REUSE_MAX' AND up.resource_name = def.resource_name
        AND up.limit=def.profile AND up.limit='DEFAULT'
     )
     where rownum <= decode((select reuse_max from pwd),'-1',2147483647,(select reuse_max from pwd))

     union
     select 'password_reuse_time',limit,profile
     from(
        SELECT 'password_reuse_time',limit,profile
        FROM dba_profiles
        WHERE resource_name = 'PASSWORD_REUSE_TIME' AND limit <>'DEFAULT'
        union
        select 'password_reuse_time',def.limit,up.profile
        FROM dba_profiles up,dba_profiles def
        where up.resource_name = 'PASSWORD_REUSE_TIME' AND up.resource_name = def.resource_name
        AND up.limit=def.profile AND up.limit='DEFAULT'
     )
     where rownum <= decode((select reuse_time from pwd),'-1',2147483647,(select reuse_time from pwd))

     union
     select 'password_lock_time',limit,profile
     from (
        SELECT 'password_lock_time',limit,profile
        FROM dba_profiles
        WHERE resource_name = 'PASSWORD_LOCK_TIME' AND limit <>'DEFAULT'
        union
        select 'password_lock_time',def.limit,up.profile
        FROM dba_profiles up,dba_profiles def
        where up.resource_name = 'PASSWORD_LOCK_TIME' AND up.resource_name = def.resource_name
        AND up.limit=def.profile AND up.limit='DEFAULT'
     )
     where rownum <= decode((select lock_time from pwd),'-1',2147483647,(select lock_time from pwd))

     union
      SELECT 'password_grace_time',limit,profile
      from(
        SELECT 'password_grace_time',limit,profile
        FROM dba_profiles
        WHERE resource_name = 'PASSWORD_GRACE_TIME' AND limit <>'DEFAULT'
        union
        select 'password_grace_time',def.limit,up.profile
        FROM dba_profiles up,dba_profiles def
        where up.resource_name = 'PASSWORD_GRACE_TIME' AND up.resource_name = def.resource_name
        AND up.limit=def.profile AND up.limit='DEFAULT'
     )
     where rownum <= decode((select grace_time from pwd),'-1',2147483647,(select grace_time from pwd))
    
     union
     select 'password_complexity_fn',limit,profile
     from(
       SELECT 'password_complexity_fn',limit,profile
       FROM sys.dba_profiles
       WHERE resource_name = 'PASSWORD_VERIFY_FUNCTION' 
       AND limit <>'DEFAULT'
       UNION
       SELECT 'password_complexity_fn',def.limit,up.profile
       FROM dba_profiles up,dba_profiles def
       WHERE up.resource_name = 'PASSWORD_VERIFY_FUNCTION' 
       AND up.resource_name = def.resource_name
       AND up.limit=def.profile AND up.limit='DEFAULT'
)
where rownum <= decode((select pwd_cmplx_fn from pwd),'-1',2147483647,(select pwd_cmplx_fn from pwd))
]]>
      </Property>
       <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">password_life_time</Property>
      <Property NAME="SQLINPARAM2" SCOPE="INSTANCE">password_reuse_max</Property>
      <Property NAME="SQLINPARAM3" SCOPE="INSTANCE">password_reuse_time</Property>
      <Property NAME="SQLINPARAM4" SCOPE="INSTANCE">password_lock_time</Property>
      <Property NAME="SQLINPARAM5" SCOPE="INSTANCE">password_grace_time</Property>
      <Property NAME="SQLINPARAM6" SCOPE="INSTANCE">password_complexity_fn</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
 </Metric>
 <Metric NAME="dbDataFilesPerm" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
     <!-- database-specific, datafiles common to instances-->
    <ValidMidTierVersions START_VER="10.2.0.0.0" /> 
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="db_data_files_perm">DB Data Files Permissions</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>		
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>		
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/dbDataFilePerm.pl
        </Property>
        <Property NAME="ENVDMAXCOUNT" SCOPE="INSTANCE">db_data_perm</Property>
        <Property NAME="ENVNDMAXCOUNT" SCOPE="INSTANCE">nt_db_data_perm</Property>
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
	</QueryDescriptor>
 </Metric>
   <Metric NAME="dbControlFilesPerm" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
     <!-- database-specific, controlfiles common to instances-->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="db_control_files_perm">DB Control Files Permission</Label>
    </Display>
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>		
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>		
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/dbControlFilesPerm.pl
        </Property>
         <Property NAME="ENVCMAXCOUNT" SCOPE="INSTANCE">db_control</Property> 
         <Property NAME="ENVNCMAXCOUNT" SCOPE="INSTANCE">nt_db_control</Property> 
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
      </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
	</QueryDescriptor>
 </Metric>
 
 <Metric NAME="tableAccess" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
     <!-- database-specific, system tables common to instances-->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="access_to_tables_and_views">Access To Important Tables And Views</Label>
    </Display>
   
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
	<QueryDescriptor FETCHLET_ID="OSLineToken">
		<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
		<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
		<Property NAME="command" SCOPE="GLOBAL">
             %perlBin%/perl %scriptsDir%//db/tableAccess.pl
        </Property>
         <Property NAME="ENVAUDMAX" SCOPE="INSTANCE">access_aud_table_max</Property> 
         <Property NAME="ENVUHISTMAX" SCOPE="INSTANCE">access_user_history_max</Property> 
         <Property NAME="ENVSRCTABMAX" SCOPE="INSTANCE">access_source_table_max</Property> 
         <Property NAME="ENVLNKTABMAX" SCOPE="INSTANCE">access_link_table_max</Property> 
         <Property NAME="ENVUSRTABMAX" SCOPE="INSTANCE">access_user_table_max</Property> 
         <Property NAME="ENVSQLTXTMAX" SCOPE="INSTANCE">access_sql_text_max</Property> 
         <Property NAME="ENVSQLSUMMAX" SCOPE="INSTANCE">access_sql_summary_max</Property> 
         <Property NAME="ENVALLSRCMAX" SCOPE="INSTANCE">access_all_source_max</Property> 
         <Property NAME="ENVDBAROLMAX" SCOPE="INSTANCE">access_dba_roles_max</Property> 
         <Property NAME="ENVSYSPRIVMAX" SCOPE="INSTANCE">access_dba_sysprivs_max</Property> 
         <Property NAME="ENVROLPRIVMAX" SCOPE="INSTANCE">access_dba_roleprivs_max</Property> 
         <Property NAME="ENVTABPRIVMAX" SCOPE="INSTANCE">access_dba_tabprivs_max</Property> 
         <Property NAME="ENVDBAUSRMAX" SCOPE="INSTANCE">access_dba_users_max</Property> 
         <Property NAME="ENVROLROLMAX" SCOPE="INSTANCE">access_role_roleprivs_max</Property> 
         <Property NAME="ENVUSRTABPRMAX" SCOPE="INSTANCE">access_user_tabprivs_max</Property> 
         <Property NAME="ENVUSRROLPRMAX" SCOPE="INSTANCE">access_user_roleprivs_max</Property> 
		<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
		<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
		<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
		<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
		<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
		<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
		<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
                </Property>
		<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
	</QueryDescriptor>
 </Metric>


  <Metric NAME="insertFailure" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="insert_failure">Insert Failure</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
      <![CDATA[
select 'insert_failure', obj.owner || '.' || obj.object_name , 'NA' from dba_objects obj, DBA_OBJ_AUDIT_OPTS aud 
where aud.object_name=obj.object_name and 
  aud.owner = obj.owner and 
  obj.OBJECT_TYPE in ('VIEW', 'TABLE', 'MATERIALIZED VIEW') AND 
  AUD.INS not like '%/S' AND
  ROWNUM <= :1
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">insert_failure_max</Property> 
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>



 

 <!-- privileges -->

  <Metric NAME="privileges" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP"> 
    <!-- database instance-specific, initialization parameter -->
       <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
        <CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
    </ValidIf>
    <Display>
      <Label NLSID="grant_privileges">GRANT ANY/SELECT PRIVILEGES</Label>
    </Display>
     
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
       <![CDATA[
    with max1  as (select :1 as select_tab,:2 as select_priv from dual)
	select 'select_any_table',
 substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c
from
 (
  select
     null   p,
     name   c
   from
     system_privilege_map
   where
     name = 'SELECT ANY TABLE'
 union
   select
     granted_role  p,
     grantee       c
   from
     dba_role_privs
 union
   select
     privilege     p, grantee       c
   from
     dba_sys_privs
 )      where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum <= decode((select select_tab from max1),'-1',2147483647,(select select_tab from max1))
start with p is null                                                                                           
connect by p = prior c
union
select 'select_privilege',
 substr(SYS_CONNECT_BY_PATH(c, '->'),3,512)  path, c
from
 (
  select
     null   p,
     view_name   c
   from
     dba_views
   where
     view_name like 'DBA_%'
 union
   select
     granted_role  p,
     grantee       c
   from
     dba_role_privs
 union
   select
     table_name     p, grantee       c
   from
     dba_tab_privs where privilege = 'SELECT'
 )     where ((c = 'PUBLIC') or (exists (select 'w' from dba_users where username=c))) and rownum <= decode((select select_priv from max1),'-1',2147483647,(select select_priv from max1))
start with p is null  
connect by p = prior c
      ]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">select_table_max</Property>
      <Property NAME="SQLINPARAM2" SCOPE="INSTANCE">select_privilege_max</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>
  
  <!-- privileges end -->  


  <Metric NAME="proxyAccount" TYPE="RAW" CONFIG="TRUE" KEYS_ONLY="TRUE"  HELP="NO_HELP">
  <!-- database-specific -->
    <ValidMidTierVersions START_VER="10.2.0.0.0" />
    <ValidIf>
    <CategoryProp NAME="VersionCategory" CHOICES="8iR2;9i;9iR2;10gR1;10gR2;10gR203;11gR1;11gR2"/>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="proxy_account">Proxy Account</Label>
    </Display>
    
    <TableDescriptor TABLE_NAME="esm_collection">
      <ColumnDescriptor NAME="property" COLUMN_NAME="property" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value" COLUMN_NAME="value" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
      <ColumnDescriptor NAME="value2" COLUMN_NAME="value2" TYPE="STRING" IS_KEY="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
      <![CDATA[
select 'proxy_account', c, 'NA' from
  (select distinct  c
  from(
    select null p, name c
    from system_privilege_map
    where name <> 'CREATE SESSION'
   union
    select granted_role p, grantee c
    from dba_role_privs
   union
     select  privilege p, grantee c
     from dba_sys_privs
   )      where exists (select 'w' from proxy_users where proxy = c)
  start with p is null
  connect by p = prior c) where rownum <= :1 order by c
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="INSTANCE">proxy_account_max</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
    </QueryDescriptor>
  </Metric>

 
<!-- ESA database collection ends -->



<!-- START Security Audit Metrics -->

 <!--
  ======================================================================
  == Category:         Security:  Audit Failed Logins 
  == Collection Level: Recommended
  == Purpose:          Alerts
  == NOTE: This metric is a stateless metric, meaning alerts are not 
  ==       cleared by the agent.  To make this work, there are two 
  ==       timestamp columns. The first is used as the timestamp in
  ==       the repository, the second is used as a key column to ensure 
  ==       that each count is treated as a seperate alert and will not 
  ==       clear. Two time cols are used because a time col can't be 
  ==       used as the timestamp and as key column.
  ======================================================================
  -->

  <Metric NAME="audit_failed_logins" TYPE="TABLE">
    <ValidIf>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="audit_failed_logins">Failed Logins</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="time" TYPE="STRING" IS_TIMESTAMP="TRUE" TRANSIENT="TRUE" HELP="NO_HELP">
        <Display> <Label NLSID="time_series_time">Time</Label>  </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="key_col_time" TYPE="STRING" IS_KEY="TRUE">
        <Display> <Label NLSID="time_series_time">Time</Label> </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="failed_login_count" TYPE="NUMBER" IS_KEY="FALSE" STATELESS_ALERTS="TRUE">
        <Display> <Label NLSID="failed_login_count">Failed Login Count</Label> </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="failed_login_interval_min" TYPE="NUMBER" IS_KEY="FALSE" 
                        TRANSIENT="TRUE" HELP="NO_HELP">
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="OSLineToken">
      <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
      <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
      <Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/failedLogin.pl </Property>
      <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
      <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
      <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
      <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
      <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
      <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
      <Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
   			<Property NAME="ENVEM_CURRENT_INTERVAL_MIN" SCOPE="USER" OPTIONAL="TRUE">currentIntervalMin</Property>
    </QueryDescriptor>
  </Metric>


 <!--
  ======================================================================
  == Category:         Security:  Audit Failed Logins by Day
  == Collection Level: Recommended
  == Purpose:          Reports
  == NOTE: This metric is a is not intended for alerts. It is simply
  ==       intended to collect historical login information.
  ==       This metric relies on agent side state files to insure that
  ==       it does not collect duplicate data. If the state files are
  ==       deleted, then collection will start fresh for the day in 
  ==       which the state file was missing and the agent is up.
  ==       When state files are missing, it is possible to have days 
  ==       in which no data is collected.  This is preferrable
  ==       to collecting duplicate data, which we CANNOT do, and so 
  ==       this method has been approved.
  ======================================================================
  -->

  <Metric NAME="audit_failed_logins_historical" TYPE="TABLE" 
          USAGE_TYPE="COLLECT_UPLOAD" HELP="NO_HELP">
    <ValidIf>
      <CategoryProp NAME="MetricScope" CHOICES="DB"/>
    </ValidIf>
    <Display>
      <Label NLSID="audit_failed_logins_historical">Failed Logins (Historical)</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="time" TYPE="STRING" IS_TIMESTAMP="TRUE" TRANSIENT="TRUE" HELP="NO_HELP">
        <Display> <Label NLSID="time_series_time">Time</Label>  </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="key_col_time" TYPE="STRING" IS_KEY="TRUE">
        <Display> <Label NLSID="time_series_time">Time</Label> </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="failed_login_count" TYPE="NUMBER" IS_KEY="FALSE" >
        <Display> <Label NLSID="failed_login_count">Failed Login Count</Label> </Display>
      </ColumnDescriptor>
    </TableDescriptor>
    <QueryDescriptor FETCHLET_ID="OSLineToken">
      <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
      <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
      <Property NAME="command" SCOPE="GLOBAL"> %perlBin%/perl %scriptsDir%/failedLogin.pl </Property>
      <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
      <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
      <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
      <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
      <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
      <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
      <Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
      <Property NAME="ENVEM_AGENT_STATE_DIR" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
      <Property NAME="ENVEM_TARGET_GUID" SCOPE="INSTANCE">GUID</Property>
   			<Property NAME="ENVEM_TIMEPERIOD" SCOPE="GLOBAL">HISTORICAL</Property>
   			<Property NAME="ENVEM_UPDATE_STATEFILE" SCOPE="USER" OPTIONAL="TRUE">updateStateFile</Property>
    </QueryDescriptor>
  </Metric>

 <!-- END Security Audit Metrics -->

<!-- ************** SQLUDM metrics (Begin) ************** -->
  <!--
  ======================================================================
  == Category:         SQLUDM metrics
  == Comment:          Keep R1 SQLUDM definition for backward compatibility
  ======================================================================
  -->

  <Metric NAME="SQLUDM" TYPE="TABLE"
          KEYS_FROM_MULT_COLLS="TRUE"
          IS_TRANSPOSED="TRUE" >
    <Display>
      <Label NLSID="database_udm">User-Defined SQL Metrics</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="ID" TYPE="STRING" IS_KEY="TRUE">
        <Display >
          <Label NLSID="database_udm_id">Script</Label>
        </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="NumValue" TYPE="NUMBER" IS_KEY="FALSE" >
        <Display>
          <Label NLSID="database_udm_value">User-Defined Numeric Metric</Label>
        </Display>
      </ColumnDescriptor>

      <ColumnDescriptor NAME="StrValue" TYPE="STRING" IS_KEY="FALSE">
        <Display >
          <Label NLSID="database_udm_strvalue">User-Defined String Metric</Label>
        </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="Message" TYPE="STRING" IS_KEY="FALSE" TRANSIENT="TRUE">
        <Display>
          <Label NLSID="database_udm_message">Message</Label>
        </Display>
      </ColumnDescriptor>

    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
  udm_id                   VARCHAR2(64) := :1;
  value_type               VARCHAR2(16) := :2;
  sql_stmt                 VARCHAR2(32767) := :3;

  number_value             NUMBER;
  string_value             VARCHAR2(32767);
  err_msg                  VARCHAR2(130);
  ret_msg                  VARCHAR2(400);

  TYPE        data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;
  sql_cursor  data_cursor_type;

BEGIN

  sql_stmt := RTRIM(LTRIM(sql_stmt));

  WHILE SUBSTR(sql_stmt, length(sql_stmt)) = ';' LOOP
    sql_stmt := SUBSTR(sql_stmt, 0, length(sql_stmt)-1);
    sql_stmt := RTRIM(sql_stmt);
  END LOOP;

  IF upper(SUBSTR(sql_stmt, 1, 6)) != 'SELECT' THEN
    sql_stmt := 'SELECT ' || sql_stmt || ' FROM DUAL';
  END IF;
  
  -- dbms_output.put_line('sql_stmt : ' || sql_stmt);

  EXECUTE IMMEDIATE sql_stmt;

  IF value_type = 'NUMBER' THEN
  
    -- NUMBER TYPE
    -- open the cursor to return

    OPEN sql_cursor FOR  -- open cursor variable
      sql_stmt;
    FETCH sql_cursor INTO number_value;
    CLOSE sql_cursor;

    ret_msg := 'User Defined Metric ' || udm_id || ' returned a value of ' || number_value || '.';

    OPEN data_cursor FOR
      SELECT udm_id, number_value, null, ret_msg FROM DUAL;

  ELSIF value_type = 'STRING' THEN

    -- STRING TYPE
    -- open the cursor to return

    OPEN sql_cursor FOR  -- open cursor variable
      sql_stmt;
    FETCH sql_cursor INTO string_value;
    CLOSE sql_cursor;

    IF length(string_value) > 293 THEN
     ret_msg := 'User Defined Metric ' || udm_id || ' returned a value of ' || SUBSTR(string_value, 0, 292) || '.';
    ELSE
     ret_msg := 'User Defined Metric ' || udm_id || ' returned a value of ' || string_value || '.';
    END IF;

    OPEN data_cursor FOR
      SELECT udm_id, null, string_value, ret_msg FROM DUAL;

  ELSE
    -- WRONG TYPE
    err_msg := udm_id || ': Wrong type!';
    raise_application_error(-20101, err_msg);
  END IF;

  :4 := data_cursor;

END;
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="USER">ID</Property>
      <Property NAME="SQLINPARAM2" SCOPE="USER">valuetype</Property>
      <Property NAME="SQLINPARAM3" SCOPE="USER">sqlstmt</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">4</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="UserName" SCOPE="USER">UserName</Property>
      <Property NAME="password" SCOPE="USER">password</Property>
      <Property NAME="Role" SCOPE="USER" OPTIONAL="TRUE">Role</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
    </QueryDescriptor>
  </Metric>

  <!--
  ======================================================================
  == Category:         SQLUDM metrics
  == Comment:          R2 SQLUDM supports multiple data return
  ======================================================================
  -->

  <Metric NAME="SQLUDMSTR" TYPE="TABLE"
          KEYS_FROM_MULT_COLLS="TRUE"
          IS_TRANSPOSED="TRUE" >
    <Display>
      <Label NLSID="database_udm_str">User-Defined SQL Metrics</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="ID" TYPE="STRING" IS_KEY="TRUE">
       <Display >
          <Label NLSID="database_udm_str_id">Metric ID</Label>
        </Display>
       </ColumnDescriptor>

      <ColumnDescriptor NAME="Key" TYPE="STRING" IS_KEY="TRUE">
        <Display >
          <Label NLSID="database_udm_str_key">Key</Label>
        </Display>
       </ColumnDescriptor>

      <ColumnDescriptor NAME="StrValue" TYPE="STRING" IS_KEY="FALSE">
        <Display >
          <Label NLSID="database_udm_str_strvalue">User-Defined String Metric</Label>
        </Display>
       </ColumnDescriptor>

      <ColumnDescriptor NAME="NumValue" TYPE="NUMBER" IS_KEY="FALSE">
        <Display >
          <Label NLSID="database_udm_str_numvalue">User-Defined Numeric Metric</Label>
        </Display>
       </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
  udm_id                   VARCHAR2(64) := :1;
  sql_stmt                 VARCHAR2(32767) := :2;
  key_type                 VARCHAR2(16) := :3;

  TYPE        data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;

BEGIN

  sql_stmt := RTRIM(LTRIM(sql_stmt));

  WHILE SUBSTR(sql_stmt, length(sql_stmt)) = ';' LOOP
    sql_stmt := SUBSTR(sql_stmt, 0, length(sql_stmt)-1);
    sql_stmt := RTRIM(sql_stmt);
  END LOOP;

  IF upper(SUBSTR(sql_stmt, 1, 6)) != 'SELECT' 
    OR key_type = 'NULL' THEN
     sql_stmt := 'SELECT ''seudo_key'', (' || sql_stmt || ') FROM DUAL';
  END IF;
  
  -- dbms_output.put_line('sql_stmt : ' || sql_stmt);

  -- STRING TYPE
  sql_stmt := ' SELECT ''' || udm_id || ''', t.* from (' || sql_stmt || ') t';

  -- dbms_output.put_line('ret_stmt: ' || sql_stmt);

  OPEN data_cursor FOR
    sql_stmt;

  :4 := data_cursor;

END;
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="USER">ID</Property>
      <Property NAME="SQLINPARAM2" SCOPE="USER">sqlstmt</Property>
      <Property NAME="SQLINPARAM3" SCOPE="USER">keytype</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">4</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="UserName" SCOPE="USER">UserName</Property>
      <Property NAME="password" SCOPE="USER">password</Property>
      <Property NAME="Role" SCOPE="USER" OPTIONAL="TRUE">Role</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="valuetype" SCOPE="USER" OPTIONAL="TRUE">valuetype</Property>
    </QueryDescriptor>
  </Metric>

  <Metric NAME="SQLUDMNUM" TYPE="TABLE"
          KEYS_FROM_MULT_COLLS="TRUE"
          IS_TRANSPOSED="TRUE" >
    <Display>
      <Label NLSID="database_udm_num">User-Defined SQL Metrics</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="ID" TYPE="STRING" IS_KEY="TRUE">
       <Display >
          <Label NLSID="database_udm_num_id">Metric ID</Label>
        </Display>
       </ColumnDescriptor>

      <ColumnDescriptor NAME="Key" TYPE="STRING" IS_KEY="TRUE">
        <Display >
          <Label NLSID="database_udm_num_key">Key</Label>
        </Display>
       </ColumnDescriptor>

      <ColumnDescriptor NAME="NumValue" TYPE="NUMBER" IS_KEY="FALSE">
        <Display >
          <Label NLSID="database_udm_num_numvalue">User-Defined Numeric Metric</Label>
        </Display>
       </ColumnDescriptor>

      <ColumnDescriptor NAME="StrValue" TYPE="STRING" IS_KEY="FALSE">
        <Display >
          <Label NLSID="database_udm_num_strvalue">User-Defined String Metric</Label>
        </Display>
       </ColumnDescriptor>
    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
  udm_id                   VARCHAR2(64) := :1;
  sql_stmt                 VARCHAR2(32767) := :2;
  key_type                 VARCHAR2(16) := :3;

  TYPE        data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;

BEGIN

  sql_stmt := RTRIM(LTRIM(sql_stmt));

  WHILE SUBSTR(sql_stmt, length(sql_stmt)) = ';' LOOP
    sql_stmt := SUBSTR(sql_stmt, 0, length(sql_stmt)-1);
    sql_stmt := RTRIM(sql_stmt);
  END LOOP;

  IF upper(SUBSTR(sql_stmt, 1, 6)) != 'SELECT' 
    OR key_type = 'NULL' THEN
     sql_stmt := 'SELECT ''seudo_key'', (' || sql_stmt || ') FROM DUAL';
  END IF;
  
  -- dbms_output.put_line('sql_stmt : ' || sql_stmt);
  
  -- NUMBER TYPE
  sql_stmt := ' SELECT ''' || udm_id || ''', t.* from (' || sql_stmt || ') t';

  -- dbms_output.put_line('ret_stmt: ' || sql_stmt);

  OPEN data_cursor FOR
    sql_stmt;

  :4 := data_cursor;

END;
]]>
      </Property>
      <Property NAME="SQLINPARAM1" SCOPE="USER">ID</Property>
      <Property NAME="SQLINPARAM2" SCOPE="USER">sqlstmt</Property>
      <Property NAME="SQLINPARAM3" SCOPE="USER">keytype</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">4</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="UserName" SCOPE="USER">UserName</Property>
      <Property NAME="password" SCOPE="USER">password</Property>
      <Property NAME="Role" SCOPE="USER" OPTIONAL="TRUE">Role</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
      <Property NAME="valuetype" SCOPE="USER" OPTIONAL="TRUE">valuetype</Property>
    </QueryDescriptor>
  </Metric>

<!-- ************** SQLUDM metrics (End) ************** -->
     <!--
    ======================================================================
    == ADRViewer Metric
    == Collection Level: {Not Collected}
    == Purpose:          On-Demand
    ======================================================================
          <ValidIf>
            <CategoryProp NAME="VersionCategory" CHOICES="11gR1;11gR2"/>
          </ValidIf>
    -->
      <Metric NAME="adr_viewer" TYPE="TABLE" USAGE_TYPE="HIDDEN">
          <TableDescriptor>
          	<ColumnDescriptor NAME="dummy" TYPE="STRING" IS_KEY="FALSE"/>
          </TableDescriptor>
          <QueryDescriptor FETCHLET_ID="OS">
              <Property NAME="OracleHome" SCOPE="INSTANCE">OracleHome</Property>
              <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
              <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
              <Property NAME="ARG" SCOPE="USER" OPTIONAL="TRUE">ARG</Property>
              <Property NAME="ENVEM_TARGET_SWEEP" SCOPE="USER" OPTIONAL="TRUE">SWEEP</Property>
              <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
              <Property NAME="ENVEM_TARGET_ORACLE_SID" SCOPE="INSTANCE">SID</Property>
              <Property NAME="ENVEM_TARGET_ADR_BASE" SCOPE="INSTANCE">AdrBase</Property>
              <Property NAME="ENVEM_TARGET_ADR_HOME" SCOPE="INSTANCE">AdrHome</Property>
              <Property NAME="ENVEM_AGENT_STATE_DIR" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
              <Property NAME="command" SCOPE="GLOBAL">%perlBin%/perl -I %OracleHome%/lib %scriptsDir%/adrviewer.pl "%ARG%"</Property>
              <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
              <Property NAME="STDINARGLIST" SCOPE="USER" OPTIONAL="TRUE">ARGLIST</Property>
          </QueryDescriptor>
      </Metric>
  <Metric NAME="textIndexStats" TYPE="RAW" IS_METRIC_LONG_RUNNING="TRUE" >
  	<ValidIf>
                        <CategoryProp NAME="OTSchemaExists" CHOICES="1;" />
	          <CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2"/>
                  <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>



   <TableDescriptor TABLE_NAME="mgmt_text_index_stats" SKIP_METRIC_COLUMN="TRUE"> 

      <ColumnDescriptor NAME="INDEX_NAME" TYPE="STRING" IS_KEY="FALSE" COLUMN_NAME="INDEX_NAME" />
      <ColumnDescriptor NAME="PARTN_NAME" TYPE="STRING" IS_KEY="FALSE" COLUMN_NAME="PARTN_NAME" />
      <ColumnDescriptor NAME="STAT_DATA" TYPE="STRING" IS_KEY="FALSE" COLUMN_NAME="STAT_DATA" />
      <ColumnDescriptor NAME="SIZE_DATA" TYPE="STRING" IS_KEY="FALSE"  COLUMN_NAME="SIZE_DATA" />
      <ColumnDescriptor NAME="OBJECTS_DATA" TYPE="STRING" IS_KEY="FALSE"  COLUMN_NAME="OBJECTS_DATA" />


    </TableDescriptor>

    <QueryDescriptor FETCHLET_ID="SQL">
      <Property NAME="STATEMENT" SCOPE="GLOBAL">
<![CDATA[
DECLARE
   TYPE        data_cursor_type IS REF CURSOR;
  data_cursor data_cursor_type;
   x clob := null;
   pos1 INTEGER := 1;
   pos2 INTEGER := 4000;
   statData clob := null;
   sizeData clob := null;
   objectsData clob := null;
   tmp VARCHAR2(4000);
   partitionName VARCHAR2(4000);
   jobName VARCHAR2(500);
   idx_name VARCHAR2(4000);
   part_name VARCHAR2(4000);
   tmp_str VARCHAR2(4000);
   guid RAW(16);
   idx_guid RAW(16);
   cursor idx_cur IS
    select owner,job_name,comments
    from dba_scheduler_jobs where job_name like 'EM_IDX_STAT_JOB%' and
    upper(owner) = 'DBSNMP';

   idx_rec idx_cur%ROWTYPE;

   
 BEGIN

   OPEN idx_cur;
   FETCH idx_cur into idx_rec;

   guid := :1;
  IF idx_cur%FOUND THEN
    dbms_lob.createtemporary(statData,false);
    dbms_lob.createtemporary(sizeData,false);
    dbms_lob.createtemporary(objectsData,false);

    idx_name := substr(idx_rec.comments,1,instr(idx_rec.comments,'|')-1);
    tmp_str := substr(idx_rec.comments,instr(idx_rec.comments,'|')+1);
    part_name := substr(tmp_str,1,instr(tmp_str,'|')-1);
    idx_guid := substr(tmp_str,instr(tmp_str,'|')+1);

    if guid = idx_guid THEN
     if part_name != 'null' then
       partitionName := part_name;
     end if;

    ctx_report.index_stats(idx_name,x,partitionName,true,5);
    
    pos1 :=  dbms_lob.instr(x,'indexed documents:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;

    pos1 :=  dbms_lob.instr(x,'allocated docids:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;

    pos1 :=  dbms_lob.instr(x,'$I rows:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


    pos1 :=  dbms_lob.instr(x,'unique tokens:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


    pos1 :=  dbms_lob.instr(x,'average $I rows per token:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


    pos1 :=  dbms_lob.instr(x,'average size per token:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'average frequency per token:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


    pos1 :=  dbms_lob.instr(x,'token type:');
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


    pos1 :=  dbms_lob.instr(x,'unique tokens:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'total rows:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'average rows:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'total size:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'average size:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'average frequency:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


    
    pos1 :=  dbms_lob.instr(x,'total size of $I data:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;


     
    pos1 :=  dbms_lob.instr(x,'estimated row fragmentation:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'garbage docids:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(statData,pos2-pos1+1,tmp);
    END IF;



    pos1 :=  dbms_lob.instr(x,'estimated garbage size:',pos1);
    IF pos1 > 0 THEN
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    
    dbms_lob.writeappend(statData,pos2-pos1,tmp);
    END IF;

    /*dbms_lob.freetemporary(x); */

    /* Gather Index Objects Data */

       ctx_report.describe_index(idx_name,x);

     pos1 := 1;

     pos1 :=  dbms_lob.instr(x,'datastore:',pos1);

    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'filter:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'section group:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'lexer:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'wordlist:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'stemmer:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'fuzzy_match:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'stoplist:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

     pos1 :=  dbms_lob.instr(x,'storage:',pos1);
    IF pos1 > 0 THEN
     pos2 :=  dbms_lob.instr(x,chr(10),pos1);
     tmp := dbms_lob.substr(x,pos2-pos1,pos1);
     tmp := tmp || '|';
     dbms_lob.writeappend(objectsData,pos2-pos1+1,tmp);
    END IF;

    /* Gather Size Data */

     ctx_report.index_size(idx_name,x,partitionName);

   pos1 := 1;
   
   LOOP
    
    pos1 :=  dbms_lob.instr(x,'INDEX (',pos1);

    EXIT WHEN pos1 < 1;

    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);

    pos1 :=  dbms_lob.instr(x,'TABLE NAME:',pos1);
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);

    pos1 :=  dbms_lob.instr(x,'TABLESPACE NAME:',pos1);
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);

    
    pos1 :=  dbms_lob.instr(x,'BLOCKS ALLOCATED:',pos1);
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);

    
    pos1 :=  dbms_lob.instr(x,'BLOCKS USED:',pos1);
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);

 
    pos1 :=  dbms_lob.instr(x,'BYTES ALLOCATED:',pos1);
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);


    pos1 :=  dbms_lob.instr(x,'BYTES USED:',pos1);
    pos2 :=  dbms_lob.instr(x,chr(10),pos1);
    tmp := dbms_lob.substr(x,pos2-pos1,pos1);
    tmp := tmp || '|';
    dbms_lob.writeappend(sizeData,pos2-pos1+1,tmp);
   END LOOP;


     OPEN data_cursor FOR
      SELECT idx_name,partitionName,dbms_lob.substr(statData),dbms_lob.substr(sizeData),dbms_lob.substr(objectsData) FROM DUAL;
    

  :2 := data_cursor;
    jobName := idx_rec.owner || '.' || idx_rec.job_name;
    dbms_scheduler.drop_job(job_name => jobName,force => true); 
    dbms_lob.freetemporary(sizeData);
    dbms_lob.freetemporary(statData);
    dbms_lob.freetemporary(objectsData);
    dbms_lob.freetemporary(x);
   end if; 
 ELSE
      OPEN data_cursor FOR
            select 'dummy','dummy','dummy','dummy','dummy' from dual;
     :2 := data_cursor;
 END IF;
END;
]]>
      </Property>
	<Property NAME="SQLINPARAM1" SCOPE="INSTANCE">GUID</Property>
      <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">2</Property>
      <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
      <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
      <Property NAME="password" SCOPE="INSTANCE">password</Property>
      <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
      <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
      <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
      <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
    </QueryDescriptor>
</Metric>



		<!-- STREAMS AND AQ METRICS  BEGIN -->

<!--
  ======================================================================
  == Category:         Streams Processes
  == Collection Level: Minimum
  == Purpose:          Number of Streams Processes and their error count in the Database
  ======================================================================
-->

<Metric NAME="streams_processes_count" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
	  <CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2" />
	  <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>

	<Display>
		<Label NLSID="streams_proc_count">Streams Processes Count</Label>
	</Display>

	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
		 
		<ColumnDescriptor NAME="CAPTURE_COUNT" TYPE="NUMBER">
			<Display>
				<Label NLSID="capture_count">Number of Capture Processes</Label>
			</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="APPLY_COUNT" TYPE="NUMBER">
			<Display>
				<Label NLSID="apply_count">Number of Apply Processes</Label>
			</Display>
		 </ColumnDescriptor>
		 <ColumnDescriptor NAME="PROP_COUNT" TYPE="NUMBER">
			 <Display>
				<Label NLSID="propagation_count">Number of Propagation Jobs</Label>
			</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="CAPTURE_ERROR_COUNT" TYPE="NUMBER">
			<Display>
				<Label NLSID="capture_error_count">Number of Capture Processes Having Errors</Label>
			</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="APPLY_ERROR_COUNT" TYPE="NUMBER">
			<Display>
				<Label NLSID="apply_error_count">Number of Apply Processes Having Errors</Label>
			</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="PROP_ERROR_COUNT" TYPE="NUMBER">
			<Display>
				<Label NLSID="prop_error_count">Number of Propagations Having Errors</Label>
			</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="TOTAL_PROP_ERRORS" TYPE="NUMBER">
			<Display>
				<Label NLSID="propagation_errors_count">Total Number of Propagation Errors</Label>
			</Display>
		</ColumnDescriptor>		
		
	</TableDescriptor>


	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
	</ValidIf>

		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[
			declare 
			  TYPE data_cursor_type IS REF CURSOR;
			  data_cursor data_cursor_type;
			  cap_count number;
			  apply_count number;
			  propagation_count number;
			  cap_error_count number;
			  apply_error_count number;
			  prop_error_count number;
			  total_prop_errors number;
			  sqlstmt varchar2(32767);
			begin
			  SELECT COUNT(*) into cap_count FROM SYS.DBA_CAPTURE; 
			  SELECT COUNT(*) into apply_count FROM SYS.DBA_APPLY; 
			  SELECT COUNT(*) into propagation_count FROM SYS.DBA_PROPAGATION; 
			  SELECT COUNT(*) into cap_error_count FROM SYS.DBA_CAPTURE WHERE ERROR_NUMBER IS NOT NULL; 
			  SELECT COUNT(*) into apply_error_count FROM SYS.DBA_APPLY WHERE ERROR_NUMBER IS NOT NULL; 
			  SELECT COUNT(*) into prop_error_count FROM SYS.DBA_PROPAGATION WHERE ERROR_MESSAGE IS NOT NULL; 
			  SELECT NVL(SUM(FAILURES), 0) into total_prop_errors FROM SYS.DBA_QUEUE_SCHEDULES; 

			  sqlstmt := 'select '||cap_count||' CAPTURE_COUNT, '||apply_count||' APPLY_COUNT, '||propagation_count||' PROP_COUNT, '||cap_error_count||' CAPTURE_ERROR_COUNT, '||apply_error_count||' APPLY_ERROR_COUNT,'||prop_error_count||' PROP_ERROR_COUNT,'||total_prop_errors||' TOTAL_PROP_ERRORS from dual';
			  OPEN data_cursor FOR   sqlstmt;
			  :1  := data_cursor;
			end;
			
		]]> 
		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property> 
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property> 
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property> 
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property> 
	</QueryDescriptor>


	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR1"/>
	</ValidIf>

		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[
			declare 
			  TYPE data_cursor_type IS REF CURSOR;
			  data_cursor data_cursor_type;
			  cap_count number;
			  apply_count number;
			  propagation_count number;
			  cap_error_count number;
			  apply_error_count number;
			  prop_error_count number;
			  total_prop_errors number;
			  sqlstmt varchar2(32767);
			begin
			  SELECT COUNT(*) into cap_count FROM SYS.DBA_CAPTURE; 
			  SELECT COUNT(*) into apply_count FROM SYS.DBA_APPLY; 
			  SELECT COUNT(*) into propagation_count FROM SYS.DBA_PROPAGATION; 
			  SELECT COUNT(*) into cap_error_count FROM SYS.DBA_CAPTURE WHERE ERROR_NUMBER IS NOT NULL; 
			  SELECT COUNT(*) into apply_error_count FROM SYS.DBA_APPLY WHERE ERROR_NUMBER IS NOT NULL; 
			  select count(*) into prop_error_count from SYS.DBA_PROPAGATION p, sys.dba_queue_schedules q where p.SOURCE_QUEUE_OWNER=q.SCHEMA and p.SOURCE_QUEUE_NAME=q.QNAME and q.FAILURES > 0;
			  SELECT NVL(SUM(FAILURES), 0) into total_prop_errors FROM SYS.DBA_QUEUE_SCHEDULES; 

			  sqlstmt := 'select '||cap_count||' CAPTURE_COUNT, '||apply_count||' APPLY_COUNT, '||propagation_count||' PROP_COUNT, '||cap_error_count||' CAPTURE_ERROR_COUNT, '||apply_error_count||' APPLY_ERROR_COUNT,'||prop_error_count||' PROP_ERROR_COUNT,'||total_prop_errors||' TOTAL_PROP_ERRORS from dual';
			  OPEN data_cursor FOR   sqlstmt;
			  :1  := data_cursor;
			end;
			
		]]> 
		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property> 
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property> 
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property> 
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property> 
	</QueryDescriptor>

</Metric>

<!--
  ======================================================================
  == Category:         Streams Processes status
  == Collection Level: Minimum
  == Purpose:          Number of Streams Processes and their error count in the Database
  ======================================================================
-->

<Metric NAME="streams_processes_status" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
	  <CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2" />
	  <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>

	<Display>
		<Label NLSID="streams_proc_status">Streams Processes Status</Label>
	</Display>

	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
		 
		<ColumnDescriptor NAME="streams_process_name" TYPE="STRING" IS_KEY="TRUE" >
			<Display>
				<Label NLSID="streams_process_name">Streams Process Name</Label>
			</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="streams_process_status" TYPE="STRING">
			<Display>
				<Label NLSID="streams_process_status">Streams Process Status</Label>
			</Display>
		</ColumnDescriptor>
		 <ColumnDescriptor NAME="streams_process_type" TYPE="STRING" IS_KEY="TRUE" >
			<Display>
				<Label NLSID="streams_process_type">Streams Process Type</Label>
			</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="streams_process_errors" TYPE="NUMBER" IS_KEY="FALSE" >
			<Display>
				<Label NLSID="streams_process_errors">Streams Process Errors</Label>
			</Display>
		</ColumnDescriptor>
	</TableDescriptor>


	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	    <ValidIf>
                <CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
            </ValidIf>
		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[
			declare 
			  TYPE data_cursor_type IS REF CURSOR;
			  data_cursor data_cursor_type;	
			  sqlstmt varchar2(1000);
			begin
			sqlstmt :=   'select a.capture_name streams_process_name, a.status streams_process_status, ''CAPTURE'' streams_process_type, COUNT(a.error_message) from dba_capture a group by a.capture_name, a.status' ||
					  ' union all ' ||
					  'select a.propagation_name streams_process_name, a.status streams_process_status, ''PROPAGATION'' streams_process_type,COUNT(a.error_message) from dba_propagation a group by a.propagation_name, a.status' ||
					  ' union all ' ||
					  'select a.apply_name streams_process_name, a.status streams_process_status, ''APPLY'' streams_process_type, COUNT(a.error_message) from dba_apply a group by a.apply_name, a.status';
			  OPEN data_cursor FOR   sqlstmt;
			  :1  := data_cursor;
			end;			
		]]> 
		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property> 
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property> 
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property> 
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property> 
	</QueryDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
         <ValidIf>
                <CategoryProp NAME="VersionCategory" CHOICES="10gR1"/>
        </ValidIf>
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
                <![CDATA[
                        declare
                          TYPE data_cursor_type IS REF CURSOR;
                          data_cursor data_cursor_type;
                          sqlstmt varchar2(1500);
                        begin
                        sqlstmt :=   'select a.capture_name streams_process_name, a.status streams_process_status, ''CAPTURE'' streams_process_type, COUNT(a.error_message) from dba_capture a group by a.capture_name, a.status' ||
                                          ' union all ' ||
			'select distinct a.propagation_name streams_process_name, decode(b.schedule_disabled,''Y'', ''DISABLED'',''N'', ''ENABLED'') streams_process_status, ''PROPAGATION'' streams_process_type, NVL(SUM(b.FAILURES), 0) from dba_queue_schedules b,dba_propagation a where b.schema = a.source_queue_owner and b.qname = a.source_queue_name group by a.propagation_name, b.schedule_disabled' ||
                                          ' union all ' ||
                        'select a.apply_name streams_process_name, a.status streams_process_status, ''APPLY'' streams_process_type, COUNT(a.error_message) from dba_apply a group by a.apply_name, a.status';

                          OPEN data_cursor FOR   sqlstmt;
                          :1  := data_cursor;
                        end;
                ]]>
        </Property>
	<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
        <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
                <Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
        <Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
        <Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
        <Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
        <Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
        <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>

</Metric>

<!-- Streams topology collection ends -->

<!-- **********  Streams server generated alerts BEGIN **********  -->

 <!--
  ======================================================================
  == Category:         Streams Server-generated alert 
  == Collection Level: Recommended
  == Purpose:          Alert for Capture Aborted
  ======================================================================
    -->
  <Metric NAME="capture" TYPE="TABLE"  KEYS_ONLY="TRUE" >
    <ValidIf>
       <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
       <CategoryProp NAME="MetricScope" CHOICES="DB"/>       
    </ValidIf>

    <Display>
      <Label NLSID="capture">Streams Capture Aborted</Label>
    </Display>
    
    <TableDescriptor>
      <ColumnDescriptor NAME="capture_aborted" TYPE="STRING" IS_KEY="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
        <Display FOR_SUMMARY_UI="TRUE">
          <Label NLSID="capture_aborted">Streams Capture Process Aborted</Label>
        </Display>
      </ColumnDescriptor>
    </TableDescriptor>
    
    <PushDescriptor RECVLET_ID="AQMetrics">
       <Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
       <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
       <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
       <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
       <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
       <Property NAME="password" SCOPE="INSTANCE">password</Property>
       <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
       <Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
       <Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
       <Property NAME="KeyColumn" SCOPE="GLOBAL">capture_aborted</Property>
     </PushDescriptor>
  </Metric>

 <!--
  ======================================================================
  == Category:         Streams Server-generated alert 
  == Collection Level: Recommended
  == Purpose:          Alert for Apply Aborted
  ======================================================================
    -->
  <Metric NAME="apply" TYPE="TABLE" KEYS_ONLY="TRUE" >
    <ValidIf>
       <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
       <CategoryProp NAME="MetricScope" CHOICES="DB"/>       
    </ValidIf>

    <Display>
      <Label NLSID="apply">Streams Apply Aborted</Label>
    </Display>
    
    <TableDescriptor>
      <ColumnDescriptor NAME="apply_aborted" TYPE="STRING" IS_KEY="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
        <Display FOR_SUMMARY_UI="TRUE">
          <Label NLSID="apply_aborted">Streams Apply Process Aborted</Label>
        </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="apply_error_queue" TYPE="STRING" STATELESS_ALERTS="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
        <Display FOR_SUMMARY_UI="TRUE">
          <Label NLSID="apply_error_queue">Streams Apply Process Error</Label>
        </Display>
      </ColumnDescriptor>
    </TableDescriptor>
    
    <PushDescriptor RECVLET_ID="AQMetrics">
       <Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
       <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
       <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
       <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
       <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
       <Property NAME="password" SCOPE="INSTANCE">password</Property>
       <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
       <Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
       <Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
       <Property NAME="KeyColumn" SCOPE="GLOBAL">apply_aborted</Property>
     </PushDescriptor>
  </Metric>


 <!--
  ======================================================================
  == Category:         Streams Server-generated alert 
  == Collection Level: Recommended
  == Purpose:          Alert for Propagation Aborted
  ======================================================================
    -->
  <Metric NAME="propagation" TYPE="TABLE" KEYS_ONLY="TRUE" >
    <ValidIf>
       <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
       <CategoryProp NAME="MetricScope" CHOICES="DB"/>       
    </ValidIf>

    <Display>
      <Label NLSID="propagation">Streams Propagation Aborted</Label>
    </Display>
    
    <TableDescriptor>
      <ColumnDescriptor NAME="propagation_aborted" TYPE="STRING" IS_KEY="TRUE" NON_THRESHOLDED_ALERTS="TRUE">
        <Display FOR_SUMMARY_UI="TRUE">
          <Label NLSID="propagation_aborted">Streams Propagation Process Aborted</Label>
        </Display>
      </ColumnDescriptor>
    </TableDescriptor>
    
    <PushDescriptor RECVLET_ID="AQMetrics">
       <Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
       <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
       <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
       <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
       <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
       <Property NAME="password" SCOPE="INSTANCE">password</Property>
       <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
       <Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
       <Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
       <Property NAME="KeyColumn" SCOPE="GLOBAL">propagation_aborted</Property>
     </PushDescriptor>
  </Metric>

<!-- **********  Streams server generated alerts END **********  -->


	<!-- **********  AQ MONITORING ALERTS BEGIN **********  -->

	<!--
	======================================================================
	== Category:         AQ MONITORING
	== Collection Level: Minimum
	== Purpose:          Alerts
	== Detials:	     Monitor the messages per queue
	======================================================================
	-->


	<Metric NAME="aq_msgs_per_queue" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
	  <CategoryProp NAME="VersionCategory" CHOICES="11gR2" />
	  <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>

	<Display>
		<Label NLSID="aq_msgs_per_queue">Messages per queue</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">

		<ColumnDescriptor NAME="schema" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="schema">Schema Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="queue_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="queue_name">Queue Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="average_msg_age" TYPE="NUMBER" >
		<Display>
			<Label NLSID="average_msg_age">Average age of messages per queue (seconds)</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="totalProcessed" TYPE="NUMBER" >
		<Display>
			<Label NLSID="totalProcessed">Total number of messages processed</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="totalReceived" TYPE="NUMBER" >
		<Display>
			<Label NLSID="totalReceived">Total number of messages received</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="proc_perc" TYPE="NUMBER" >
		<Display>
			<Label NLSID="proc_perc">Messages processed per queue (%) </Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="totalProcessed_interval" TYPE="NUMBER" IS_KEY="FALSE"  
			COMPUTE_EXPR="(totalProcessed > _totalProcessed) ? ( (totalProcessed - _totalProcessed)/__interval ) : ( (_totalProcessed - totalProcessed)/__interval )" >
		<Display>
			<Label NLSID="totalProcessed_interval">Total messages processed per minute in the last interval</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="totalReceived_interval" TYPE="NUMBER" IS_KEY="FALSE"  
			COMPUTE_EXPR="(totalReceived > _totalReceived) ? ( (totalReceived - _totalReceived)/__interval ) : ( (_totalReceived - totalReceived)/__interval )" >
		<Display>
			<Label NLSID="totalReceived_interval">Total messages received per minute in the last interval</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="proc_perc_interval" TYPE="NUMBER" IS_KEY="FALSE"  
			COMPUTE_EXPR="(proc_perc > _proc_perc) ? ( (proc_perc - _proc_perc)/__interval ) : ( (_proc_perc - proc_perc)/__interval )" >
		<Display>
			<Label NLSID="proc_perc_interval">Messages processed per queue (%) per minute in the last interval</Label>
		</Display>
		</ColumnDescriptor>


	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[

			declare
				lv_sql_stmt varchar2(10000);
				finalQry varchar2(2048);
				fromClause varchar2(512);
				lc_var1 varchar2(1000);
				lc_var2 number;
                                lc_var3 number;
				fullQName varchar2(512);
                                avg_msg_age number;
				TYPE data_cursor_type IS REF CURSOR;
				data_cursor data_cursor_type;  
				test_cursor sys_refcursor;
				v_error_code number;
				v_error_message varchar2(255);

				receivedB number := 0;
				processedB number := 0;
				receivedP number := 0;
				processedP number := 0;
				totalReceived number := 0;
				totalProcessed number := 0;
				finalPerc number := 0;
			  
			begin
				begin
				    begin
				      EXECUTE IMMEDIATE 'SELECT * FROM AQ_MNTR_MSGS_QUEUE where rownum <=1';
				    exception
					WHEN OTHERS THEN 
					  v_error_code := SQLCODE; 
					  v_error_message := SQLERRM; 
					  DBMS_OUTPUT.PUT_LINE(v_error_code); 
					  DBMS_OUTPUT.PUT_LINE(v_error_message);
					  -- If table does not exist before then create it
					  IF v_error_code = -942 THEN  -- ORA-00942: table or view does not exist
					      EXECUTE IMMEDIATE 'CREATE TABLE AQ_MNTR_MSGS_QUEUE (FULL_QUEUE_NAME varchar2(256) NOT NULL PRIMARY KEY, schema varchar2(256), queue_name varchar2(256), average_msg_age number, totalProcessed number, totalReceived number,  proc_perc number)'; 
					  END IF;              
				    end;  

				    --If no exception means table exists already. Clean it up before reusing
				    EXECUTE IMMEDIATE 'DELETE FROM AQ_MNTR_MSGS_QUEUE'; 
				exception
				    WHEN OTHERS THEN null;
				end;
				commit;
				
				-- Review comment => Do not include sys/system/sysman/dbsnmp schema as these might contain system queues
				for rec in (select owner, name, queue_table from dba_queues where owner not in ('SYS', 'SYSTEM', 'SYSMAN', 'DBSNMP') ) LOOP
                                  dbms_output.put_line('+++++ Begin Processing for: ' ||rec.owner||' , '||rec.name|| ', '||rec.queue_table);
					begin
                                            -- Calculate the average message age per queue and store them in the AQ_MNTR_MSGS_QUEUE table
                                            begin
						fromClause := rec.owner||'.AQ$'||rec.queue_table;
						finalQry := 'select queue, avg(sysdate-ENQ_TIME) * 86400 AVERAGE_MSG_AGE  from ' || fromClause ||' group by queue' ; 

						open test_cursor for finalQry;
						loop
							lc_var1 := ''; lc_var2 := 0; fullQName := '';
							fetch test_cursor into lc_var1 ,lc_var2 ;
							fullQName := rec.owner||'.'||lc_var1;
							begin
								IF lc_var2 != 0 THEN	
                                                                        totalProcessed := null; totalReceived := null; finalPerc := null;
                                                                        execute immediate 'insert into AQ_MNTR_MSGS_QUEUE values (:1, :2, :3, :4, :5, :6, :7)' using fullQName, rec.owner, lc_var1, lc_var2, totalProcessed, totalReceived, finalPerc;
									commit;
								END IF;
							exception
								WHEN OTHERS  THEN 
								rollback;
								DBMS_OUTPUT.PUT_LINE(' ***** Unique constaint error ***** ');
							end;

						exit when test_cursor %notfound;

						dbms_output.put_line('FETCHED DATA: ' ||lc_var1||' , '||lc_var2|| ', '||fullQName);
						end loop;

						lc_var1 := '';
						lc_var2 := 0;
						fullQName := '';

					    exception
						WHEN OTHERS THEN
                                                    v_error_code := SQLCODE; 
                                                    v_error_message := SQLERRM; 
                                                    DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                    DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                    DBMS_OUTPUT.PUT_LINE(' ***** Exception in calculating average age ***** ');
					    end;

                                            -- Average message age per queue end

                                            -- Messages processed % per queue. Calculate and update the AQ_MNTR_MSGS_QUEUE table
                                            begin
                                                fullQName := '';
						fullQName := rec.owner||'.'||rec.name;
						begin
							select B.CNUM_MSGS receivedB, B.CNUM_MSGS-B.EXPIRED_MSGS-B.NUM_MSGS processedB INTO receivedB, processedB from V$BUFFERED_QUEUES B
							where B.QUEUE_SCHEMA = rec.owner and B.QUEUE_NAME = rec.name;
						exception
							WHEN NO_DATA_FOUND THEN
							DBMS_OUTPUT.PUT_LINE(' ***** FIRST QUERY RETURNED NO DATA***** ');
						end;

						begin
							select P.ENQUEUED_MSGS receivedP , P.DEQUEUED_MSGS processedP INTO receivedP, processedP from V$PERSISTENT_QUEUES P
							where P.QUEUE_SCHEMA = rec.owner and P.QUEUE_NAME = rec.name;
						exception
							WHEN NO_DATA_FOUND THEN
							DBMS_OUTPUT.PUT_LINE(' ***** SECOND QUERY RETURNED NO DATA***** ');
						end;

						totalProcessed := processedB + processedP;
						totalReceived := receivedB + receivedP;

						IF totalReceived != 0 THEN
							finalPerc := (totalProcessed/totalReceived) * 100;								
                                                        execute immediate 'select count(*) from AQ_MNTR_MSGS_QUEUE where schema = :1 and queue_name = :2' into lc_var3 using rec.owner, rec.name;
                                                        IF lc_var3 = 0 THEN
                                                          avg_msg_age := null;
                                                          execute immediate 'insert into AQ_MNTR_MSGS_QUEUE values (:1, :2, :3, :4, :5, :6, :7)' using fullQName, rec.owner, rec.name, avg_msg_age, totalProcessed, totalReceived, finalPerc;
                                                        ELSE
                                                          execute immediate 'update AQ_MNTR_MSGS_QUEUE set totalProcessed = :1, totalReceived = :2, proc_perc = :3 where FULL_QUEUE_NAME = :4 ' using totalProcessed, totalReceived, finalPerc, fullQName;
                                                        END IF;
                                                        commit;	
						END IF;

						-- Reset after using
						receivedB := 0;
						processedB := 0;
						receivedP := 0;
						processedP := 0;
						totalReceived := 0;
						totalProcessed := 0;
						finalPerc := 0;

					    exception
						WHEN OTHERS THEN
                                                    v_error_code := SQLCODE; 
                                                    v_error_message := SQLERRM; 
                                                    DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                    DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                    DBMS_OUTPUT.PUT_LINE(' ***** Exception in calculating processed % ***** ');
					    end;
                                            
                                            -- Messages processed % per queue end
                                            
					exception
                                            WHEN OTHERS THEN
                                                v_error_code := SQLCODE; 
                                                v_error_message := SQLERRM; 
                                                DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                DBMS_OUTPUT.PUT_LINE(' ***** Exception in main for loop ***** ');
					end;
                                  dbms_output.put_line('+++++ END Processing +++++ ');
				end loop;								

                         
			 lv_sql_stmt:='select schema, queue_name, average_msg_age, totalProcessed, totalReceived, proc_perc from AQ_MNTR_MSGS_QUEUE';
                         open data_cursor for lv_sql_stmt;
                         :1  := data_cursor;

			 EXCEPTION
			   WHEN OTHERS THEN 
					v_error_code := SQLCODE; 
					v_error_message := SQLERRM; 
					DBMS_OUTPUT.PUT_LINE(v_error_code); 
					DBMS_OUTPUT.PUT_LINE(v_error_message); 
					DBMS_OUTPUT.PUT_LINE('>>>>>> Exception in main begin block  <<<<<<<');  
			end;


		]]>

		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>
	</Metric>



	<!--
	======================================================================
	== Category:         AQ MONITORING
	== Collection Level: Minimum
	== Purpose:          Alerts
	== Detials:	     Monitor the messages per queue per subscriber
	======================================================================
	-->


	<Metric NAME="aq_msgs_per_queue_per_subscriber" TYPE="TABLE">

	<ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="11gR2" />
	</ValidIf>
	<Display>
		<Label NLSID="aq_msgs_per_queue_per_subscriber">Messages per queue per subscriber</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">

		<ColumnDescriptor NAME="schema" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="schema">Schema Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="queue_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="queue_name">Queue Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="subs_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="subs_name">Subscriber Name</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="subs_address" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="subs_address">Subscriber Address</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="average_msg_age_subs" TYPE="NUMBER" >
		<Display>
			<Label NLSID="average_msg_age_subs">Average age of messages per queue per subscriber (seconds)</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="totalProcessed" TYPE="NUMBER" >
		<Display>
			<Label NLSID="totalProcessed">Total number of messages processed</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="totalReceived" TYPE="NUMBER" >
		<Display>
			<Label NLSID="totalReceived">Total number of messages received</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="proc_perc" TYPE="NUMBER" >
		<Display>
			<Label NLSID="proc_perc_subs">Messages processed per queue per subscriber (%) </Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="totalProcessed_subs_interval" TYPE="NUMBER" IS_KEY="FALSE"  
			COMPUTE_EXPR="(totalProcessed > _totalProcessed) ? ( (totalProcessed - _totalProcessed)/__interval ) : ( (_totalProcessed - totalProcessed)/__interval )" >
		<Display>
			<Label NLSID="totalProcessed_subs_interval">Total messages processed per queue per subscriber per minute in the last interval</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="totalReceived_subs_interval" TYPE="NUMBER" IS_KEY="FALSE"  
			COMPUTE_EXPR="(totalReceived > _totalReceived) ? ( (totalReceived - _totalReceived)/__interval ) : ( (_totalReceived - totalReceived)/__interval )" >
		<Display>
			<Label NLSID="totalReceived_subs_interval">Total messages received per queue per subscriber per minute in the last interval</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="proc_perc_subs_interval" TYPE="NUMBER" IS_KEY="FALSE"  
			COMPUTE_EXPR="(proc_perc > _proc_perc) ? ( (proc_perc - _proc_perc)/__interval ) : ( (_proc_perc - proc_perc)/__interval )" >
		<Display>
			<Label NLSID="proc_perc_subs_interval">Messages processed per queue (%) per subscriber per minute in the last interval</Label>
		</Display>
		</ColumnDescriptor>


	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[

                        declare
                                lv_sql_stmt varchar2(10000);
                                finalQry varchar2(2048);
                                fromClause varchar2(512);
                                lc_var1 varchar2(512);
                                lc_var2 varchar2(30);
                                lc_var3 varchar2(1024);
                                lc_var4 number;
                                lc_var5 number;
                                fullQName varchar2(512);
                                avg_msg_age number;
                                qtable varchar2(512);
                                qry1 varchar2(32767);
                                receivedB number := 0;
                                processedB number := 0;
                                receivedP number := 0;
                                processedP number := 0;
                                totalReceived number := 0;
                                totalProcessed number := 0;
                                finalPerc number := 0;
                                pk varchar2(32767);
                                subs_id number;
                                subs_name varchar2(512);
                                subs_address varchar2(1000);
                                TYPE data_cursor_type IS REF CURSOR;
                                data_cursor data_cursor_type;  
                                test_cursor sys_refcursor;
                                v_error_code number;
				v_error_message varchar2(255);
			  
			begin
                                begin
                                    begin
                                      EXECUTE IMMEDIATE 'SELECT * FROM AQ_MNTR_MSGS_SUBS where rownum <=1';
                                    exception
                                        WHEN OTHERS THEN 
                                          v_error_code := SQLCODE; 
                                          v_error_message := SQLERRM; 
                                          DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                          DBMS_OUTPUT.PUT_LINE(v_error_message);
                                          -- If table does not exist before then create it
                                          IF v_error_code = -942 THEN  -- ORA-00942: table or view does not exist
                                              EXECUTE IMMEDIATE 'CREATE TABLE AQ_MNTR_MSGS_SUBS (ID varchar2(2048) NOT NULL PRIMARY KEY, schema varchar2(256), queue_name varchar2(256), subs_name varchar2(256), subs_address varchar2(512), average_msg_age_subs number,  totalProcessed number, totalReceived number,  proc_perc number)'; 
                                          END IF;              
                                    end;  
    
                                    --If no exception means table exists already. Clean it up before reusing
                                    EXECUTE IMMEDIATE 'DELETE FROM AQ_MNTR_MSGS_SUBS'; 
                                exception
                                    WHEN OTHERS THEN null;
                                end;
    
                                commit;
				
				-- Review comment => Do not include sys/system/sysman/dbsnmp schema as these might contain system queues
				for rec in (select owner, name, queue_table from dba_queues where owner not in ('SYS', 'SYSTEM', 'SYSMAN', 'DBSNMP') ) LOOP
                                  dbms_output.put_line('+++++ Begin Processing for: ' ||rec.owner||' , '||rec.name|| ', '||rec.queue_table);
					begin
                                            -- Calculate the average message age per queue and store them in the AQ_MNTR_MSGS_SUBS table

                                                begin    
                                                    fromClause := rec.owner||'.AQ$'||rec.queue_table;
                                                    finalQry := 'select queue, consumer_name, address, avg(sysdate-ENQ_TIME) * 86400 AVERAGE_MSG_AGE  from ' || fromClause ||' group by queue, consumer_name, address' ; 
                                                    DBMS_OUTPUT.PUT_LINE(finalQry);
                    
                                                    begin
                                                            open test_cursor for finalQry;
                                                            loop
                                                                    lc_var1 := ''; lc_var2 := ''; lc_var3 := ''; lc_var4 := 0; pk := '';
                                                                    fetch test_cursor into lc_var1 ,lc_var2, lc_var3, lc_var4;
                                                                    pk := rec.owner||':'||lc_var1||':'||lc_var2||':'||lc_var3;
                                                                    DBMS_OUTPUT.PUT_LINE('pk1: '||pk);
                                                                    begin
                                                                            IF lc_var4 != 0 THEN				
                                                                              totalProcessed := null; totalReceived := null; finalPerc := null;
                                                                              execute immediate 'insert into AQ_MNTR_MSGS_SUBS values (:1, :2, :3, :4, :5, :6, :7, :8, :9)' using pk, rec.owner, lc_var1, lc_var2, lc_var3, lc_var4, totalProcessed, totalReceived, finalPerc;
                                                                              commit;
                                                                            END IF;
                                                                    exception
                                                                            WHEN OTHERS  THEN 
                                                                            rollback;
                                                                            DBMS_OUTPUT.PUT_LINE(' ***** Unique constaint error ***** ');
                                                                    end;
                    
                                                            exit when test_cursor %notfound;
                    
                                                            dbms_output.put_line('FETCHED DATA: ' ||lc_var1||' , '||lc_var2|| ', '||lc_var3||', '||lc_var4||', '||pk);

                                                            end loop;
                                                    exception
                                                            WHEN OTHERS  THEN 
                                                              v_error_code := SQLCODE; 
                                                              v_error_message := SQLERRM; 
                                                              DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                              DBMS_OUTPUT.PUT_LINE(v_error_message);
                                                              DBMS_OUTPUT.PUT_LINE(' ***** Could not open cursor ***** ');
                                                    end;

                                                 EXCEPTION
                                                    WHEN OTHERS THEN
                                                        v_error_code := SQLCODE; 
                                                        v_error_message := SQLERRM; 
                                                        DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                        DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                        DBMS_OUTPUT.PUT_LINE(' ***** Exception in calculating average age ***** ');
                                                end;

                                            -- Average message age per queue end

                                            -- Messages processed % per queue per subscriber. Calculate and update the AQ_MNTR_MSGS_SUBS table

                                             begin
                                                    qtable := rec.owner||'.AQ$_'||rec.queue_table||'_S';
                                                    qry1 := 'select subscriber_id, name, address from ' || qtable || ' where queue_name='''||rec.name||'''';
                                                    DBMS_OUTPUT.PUT_LINE(qry1);
                                                      open test_cursor for qry1;
                                                      loop
							      subs_id := 0; subs_name := ''; subs_address := '';
                                                              fetch test_cursor into subs_id, subs_name, subs_address;
                                                                
                                                                pk := rec.owner||':'||rec.name||':'||subs_name||':'||subs_address;
                                                                DBMS_OUTPUT.PUT_LINE('pk2: '||pk);
                                                                begin
                                                                    
                                                                    begin
                                                                      execute immediate 'SELECT ENQUEUED_MSGS, DEQUEUED_MSGS from V$PERSISTENT_SUBSCRIBERS where QUEUE_SCHEMA = :1  and QUEUE_NAME = :2 and SUBSCRIBER_ID = :3 ' 
                                                                              into receivedP, processedP using rec.owner, rec.name, subs_id;
                                                                    exception
                                                                            WHEN NO_DATA_FOUND THEN
                                                                            DBMS_OUTPUT.PUT_LINE(' ***** FIRST QUERY RETURNED NO DATA***** ');
                                                                    end;
                                                                              
                                                                    begin                      
                                                                      execute immediate 'SELECT CNUM_MSGS, (CNUM_MSGS-EXPIRED_MSGS-NUM_MSGS) from V$BUFFERED_SUBSCRIBERS where QUEUE_SCHEMA = :1  and QUEUE_NAME = :2 and SUBSCRIBER_ID = :3 ' 
                                                                              into receivedB, processedB using rec.owner, rec.name, subs_id;
                                                                    exception
                                                                            WHEN NO_DATA_FOUND THEN
                                                                            DBMS_OUTPUT.PUT_LINE(' ***** SECOND QUERY RETURNED NO DATA***** ');
                                                                    end;
                                                                            
                                                                    totalProcessed := processedB + processedP;
                                                                    totalReceived := receivedB + receivedP;
                                                                    IF totalReceived != 0 THEN
                                                                            finalPerc := (totalProcessed/totalReceived) * 100;
                                                                            execute immediate 'select count(*) from AQ_MNTR_MSGS_SUBS where schema = :1 and queue_name = :2' into lc_var5 using rec.owner, rec.name;
    
                                                                            IF lc_var5 = 0 THEN
                                                                              avg_msg_age := null;
                                                                              execute immediate 'insert into AQ_MNTR_MSGS_SUBS values (:1, :2, :3, :4, :5, :6, :7, :8, :9)' using pk, rec.owner, rec.name, subs_name, subs_address, avg_msg_age, totalProcessed, totalReceived, finalPerc;
                                                                            ELSE
                                                                              execute immediate 'update AQ_MNTR_MSGS_SUBS set totalProcessed = :1, totalReceived = :2, proc_perc = :3 where ID = :4 ' using totalProcessed, totalReceived, finalPerc, pk;
                                                                            END IF;
                                                                            
                                                                            commit;	
                                                                    END IF;
                                                                    
                                                                    -- Reset after using
                                                                    pk := '';
                                                                    receivedB := 0;
                                                                    processedB := 0;
                                                                    receivedP := 0;
                                                                    processedP := 0;
                                                                    totalReceived := 0;
                                                                    totalProcessed := 0;
                                                                    finalPerc := 0;
                                                                    
                                                                exception
                                                                    WHEN OTHERS  THEN 
                                                                        v_error_code := SQLCODE; 
                                                                        v_error_message := SQLERRM; 
                                                                        DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                                        DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                                        DBMS_OUTPUT.PUT_LINE(' ***** Insert into AQ_MNTR_MSGS_SUBS failed might be due to unique key constraint ***** ');
                                                                end;                 
                                                              exit when test_cursor %notfound;
                                                      end loop;
                                                      close test_cursor;      
                                             EXCEPTION
                                                WHEN OTHERS THEN 
                                                  v_error_code := SQLCODE; 
                                                  v_error_message := SQLERRM; 
                                                  DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                  DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                  DBMS_OUTPUT.PUT_LINE(' ***** Exception in calculating processed % ***** ');                                           
                                             end;

                                            -- Messages processed % per queue end
                                            
					exception
                                            WHEN OTHERS THEN
                                                v_error_code := SQLCODE; 
                                                v_error_message := SQLERRM; 
                                                DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                                DBMS_OUTPUT.PUT_LINE(v_error_message); 						
                                                DBMS_OUTPUT.PUT_LINE(' ***** Exception in main for loop ***** ');
					end;
                                  dbms_output.put_line('+++++ END Processing +++++ ');
				end loop;								

                            lv_sql_stmt:='select schema, queue_name, subs_name, subs_address, average_msg_age_subs, totalProcessed, totalReceived, proc_perc from AQ_MNTR_MSGS_SUBS';
                            open data_cursor for lv_sql_stmt;
                            :1  := data_cursor;

			EXCEPTION
			   WHEN OTHERS THEN 
                                v_error_code := SQLCODE; 
                                v_error_message := SQLERRM; 
                                DBMS_OUTPUT.PUT_LINE(v_error_code); 
                                DBMS_OUTPUT.PUT_LINE(v_error_message); 
                                DBMS_OUTPUT.PUT_LINE('>>>>>> Exception in main begin block  <<<<<<<');  
			end;

		]]>

		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>
	</Metric>


	<!--
	======================================================================
	== Category:         AQ MONITORING
	== Collection Level: Minimum
	== Purpose:          Alerts
	== Detials:	     Monitor the age of the first (top of the queue) message for persistent queue
	======================================================================
	-->


	<Metric NAME="aq_msgs_persistentqueue" TYPE="TABLE">

	<ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="11gR2" />
	</ValidIf>
	<Display>
		<Label NLSID="aq_msgs_persistentqueue">Messages in the persistent queue</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">

		<ColumnDescriptor NAME="schema" TYPE="STRING" IS_KEY="TRUE"  >
		<Display>
			<Label NLSID="schema">Schema Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="queue_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="queue_name">Queue Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="first_message_age" TYPE="NUMBER" >
		<Display>
			<Label NLSID="first_message_age">Age of the first message in persistent queue per queue (seconds)</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="first_message_state" TYPE="STRING"  >
		<Display>
			<Label NLSID="first_message_state">State of the first message in persistent queue per queue</Label>
		</Display>
		</ColumnDescriptor>

	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[
			declare
			  lv_sql_stmt varchar2(10000);
			  TYPE data_cursor_type IS REF CURSOR;
			  data_cursor data_cursor_type;
			  qtable varchar2(512);
			  qtable2 varchar2(512); 
			  qtable3 varchar2(512); 
			  qtable4 varchar2(512); 
                          pk varchar2(32767);
			  qry1 varchar2(32767);
			  qry2 varchar2(32767);  
			  qry3 varchar2(32767);  
			  qry4 varchar2(32767);  
                          first_msg_age number;
			  first_msg_state  varchar2(512);
			  subs_id number;
			  subs_name varchar2(512);
			  subs_address varchar2(1000);
			  subs_msgid  varchar2(32767);  
                          TYPE msgid_tab IS TABLE OF varchar2(2000);
                          msgids msgid_tab := msgid_tab();
                          TYPE col_names IS TABLE OF varchar2(512);
                          cols col_names := col_names();                          
                          n number := 0;
                          ind_col_count number;
                          sort_order varchar2(512);
                          finalMsgIds varchar2(32767);  
			  test_cursor sys_refcursor;  
			  test_cursor2 sys_refcursor;  
			  test_cursor3 sys_refcursor;    
			  v_error_code number;
			  v_error_message varchar2(255);
			  
			begin 

				begin
				    begin
				      EXECUTE IMMEDIATE 'SELECT * FROM AQ_MNTR_MSGS_PERSQ where rownum <=1';
				    exception
					WHEN OTHERS THEN 
					  v_error_code := SQLCODE; 
					  v_error_message := SQLERRM; 
					  DBMS_OUTPUT.PUT_LINE(v_error_code); 
					  DBMS_OUTPUT.PUT_LINE(v_error_message);
					  -- If table does not exist before then create it
					  IF v_error_code = -942 THEN  -- ORA-00942: table or view does not exist
					      EXECUTE IMMEDIATE 'CREATE TABLE AQ_MNTR_MSGS_PERSQ (schema varchar2(256), queue_name varchar2(256), first_message_age number, first_msg_state varchar2(100))';
					  END IF;              
				    end;  

				    --If no exception means table exists already. Clean it up before reusing
				    EXECUTE IMMEDIATE 'DELETE FROM AQ_MNTR_MSGS_PERSQ'; 
				exception
				    WHEN OTHERS THEN null;
				end;

				commit;

			  -- Review comment => Do not include sys/system/sysman/dbsnmp schema as these might contain system queues
			  for rec in (select owner, name, queue_table from dba_queues where owner not in ('SYS', 'SYSTEM', 'SYSMAN', 'DBSNMP') ) loop
                             DBMS_OUTPUT.PUT_LINE('+++++  BEGIN  +++++');                            
			      begin
				    qtable := rec.owner||'.AQ$_'||rec.queue_table||'_S';
				    qtable2 := rec.owner||'.AQ$_'||rec.queue_table||'_I';
				    qtable3 := rec.owner||'.AQ$'||rec.queue_table;     
				    DBMS_OUTPUT.PUT_LINE(qtable||','||qtable2||','||qtable3||','||rec.name); 
                                    -- initialise to null b4 usage
                                    msgids := msgid_tab();
                                    n := 0; 
                                    finalMsgIds := '';
				    qry1 := 'select subscriber_id, name, address from ' || qtable || ' where queue_name='''||rec.name||'''';
				    
				      open test_cursor for qry1;
				      loop
					  subs_id := ''; subs_name := ''; subs_address := '';
                                          fetch test_cursor into subs_id, subs_name, subs_address;
					    DBMS_OUTPUT.PUT_LINE(subs_id||','||subs_name||','||subs_address);
                                            pk := rec.owner||':'||rec.name||':'||subs_name||':'||subs_address;
                                            begin
                                                subs_msgid := '';
                                                qry2 := 'select  msgid from  ' || qtable2 || ' where SUBSCRIBER# = '|| subs_id ||' and rownum <=1';
                                                open test_cursor2 for qry2;
                                                fetch test_cursor2 into subs_msgid;
                                                close test_cursor2;
    
                                                subs_msgid := nvl(subs_msgid, 'EMPTY');
                                                IF subs_msgid != 'EMPTY' THEN
                                                    msgids.EXTEND(1);
                                                    n := n+1;
                                                    msgids(n) := subs_msgid;
                                                    DBMS_OUTPUT.PUT_LINE('Message fetched: '||subs_msgid);
                                                    DBMS_OUTPUT.PUT_LINE('Message inserted into msgids(n): '||msgids(n));
                                                END IF;
                                                
                                            exception
                                                WHEN OTHERS  THEN 
                                                v_error_code := SQLCODE;
                                                v_error_message := SQLERRM;
                                                DBMS_OUTPUT.PUT_LINE(v_error_code);
                                                DBMS_OUTPUT.PUT_LINE(v_error_message);
                                                DBMS_OUTPUT.PUT_LINE(' ***** construction of msgid array might have failed ***** ');
                                            end;                 
                                          exit when test_cursor %notfound;
				      end loop;
				      close test_cursor;      

                                  DBMS_OUTPUT.PUT_LINE('Messages count: '||msgids.count);

                             /*  Do all the processing only if there are messages in the queue/subscriber */ 
                             /*  Processing BEGIN */
                             IF msgids.count > 0 THEN 
                                          begin                                      
                                              qtable4 := 'AQ$_'||rec.queue_table||'_I';
                                              ind_col_count := 0;
                                              sort_order := '';
                                                EXECUTE IMMEDIATE 'select  column_name from  dba_ind_columns where TABLE_OWNER = :1 and table_name = :2 and index_name like ''%TOP%'''  BULK COLLECT INTO cols using rec.owner, qtable4;
                                                if(cols.last <> 0) THEN
                                                    FOR i IN cols.first..cols.last loop
                                                        if i=4 then
                                                          sort_order := cols(i)||',';
                                                        elsif i=cols.last then
                                                          sort_order := sort_order || cols(i);
                                                        elsif i > 4 and i < cols.last then
                                                          sort_order := sort_order||cols(i)||',';
                                                        end if;                                          
                                                    end loop;
                                                end if;
                                              DBMS_OUTPUT.PUT_LINE('+++++$$$$$: Final sort_order: '||sort_order);
                                         exception
                                           WHEN others THEN 
                                            v_error_code := SQLCODE;
                                            v_error_message := SQLERRM;
                                            DBMS_OUTPUT.PUT_LINE(v_error_code);
                                            DBMS_OUTPUT.PUT_LINE(v_error_message);                               
                                           DBMS_OUTPUT.PUT_LINE('Error in calculating sort order....');  
                                        end;
            
                            
                                        begin
                                            finalMsgIds := '';  
                                            FOR k IN 1..msgids.count loop
                                                    if k = msgids.count	then
                                                            finalMsgIds  := finalMsgIds ||DBMS_ASSERT.ENQUOTE_LITERAL(msgids(k));
                                                    else
                                                            finalMsgIds  := finalMsgIds ||DBMS_ASSERT.ENQUOTE_LITERAL(msgids(k))||',';
                                                    end if;
                                            end loop;
                                            DBMS_OUTPUT.PUT_LINE('+++++$$$$$: finalMsgIds: '||finalMsgIds );
                                       exception
                                         WHEN others THEN 
                                          v_error_code := SQLCODE;
                                          v_error_message := SQLERRM;
                                          DBMS_OUTPUT.PUT_LINE(v_error_code);
                                          DBMS_OUTPUT.PUT_LINE(v_error_message);                             
                                         DBMS_OUTPUT.PUT_LINE('Error in calculating finalMsgIds....');  
                                      end;
            
                                      begin
                                          subs_msgid := '';
                                          qry3 := 'select  msgid from  ' || qtable2 || ' where msgid in ( '|| finalMsgIds ||' ) order by '|| sort_order;
                                          -- qry3 := 'select  msgid from  ' || qtable2 || ' where msgid in ( '|| finalMsgIds ||' ) ';
                                          DBMS_OUTPUT.PUT_LINE('qry3: '||qry3);
                                          open test_cursor2 for qry3;
                                          fetch test_cursor2 into subs_msgid;
                                          close test_cursor2;
                                          DBMS_OUTPUT.PUT_LINE('+++++$$$$$: FINAL subs_msgid: '||subs_msgid);                                     
                                       exception
                                         WHEN others THEN 
                                          v_error_code := SQLCODE;
                                          v_error_message := SQLERRM;
                                          DBMS_OUTPUT.PUT_LINE(v_error_code);
                                          DBMS_OUTPUT.PUT_LINE(v_error_message);
                                         
                                         DBMS_OUTPUT.PUT_LINE('Error in getting FINAL subs_msgid....');  
                                      end;
            
                                      begin
                                          first_msg_age := 0; first_msg_state := '';
					  qry4 := 'select (sysdate-enq_time) * 86400, msg_state from '|| qtable3 ||' where msg_id ='''||subs_msgid||''''; 
                                          open test_cursor3 for qry4;
                                          fetch test_cursor3 into first_msg_age, first_msg_state ;
                                          
                                          IF first_msg_age != 0 THEN
                                            execute immediate 'insert into AQ_MNTR_MSGS_PERSQ values (:1, :2, :3, :4)' using rec.owner, rec.name, first_msg_age, first_msg_state;
                                            commit;	
                                          END IF;
                                       exception
                                         WHEN others THEN 
                                          v_error_code := SQLCODE;
                                          v_error_message := SQLERRM;
                                          DBMS_OUTPUT.PUT_LINE(v_error_code);
                                          DBMS_OUTPUT.PUT_LINE(v_error_message);
                                          DBMS_OUTPUT.PUT_LINE('Error in inserting into AQ_MNTR_MSGS_PERSQ....');  
                                      end;
                             END IF;
                            /*  Processing END */

                             DBMS_OUTPUT.PUT_LINE('+++++  END  +++++');  
                             
			     EXCEPTION
			       WHEN others THEN 
                                v_error_code := SQLCODE;
                                v_error_message := SQLERRM;
                                DBMS_OUTPUT.PUT_LINE(v_error_code);
                                DBMS_OUTPUT.PUT_LINE(v_error_message);                               
			        DBMS_OUTPUT.PUT_LINE('INSIDE THE MAIN LOOP >>>> NO DATA CONTINUE....');  
			    end;
			      
			  end loop;
			  lv_sql_stmt:='select schema, queue_name, first_message_age, first_msg_state from AQ_MNTR_MSGS_PERSQ';
			  open data_cursor for lv_sql_stmt;
			  :1 := data_cursor;

			exception
				WHEN OTHERS THEN 
                                  v_error_code := SQLCODE;
                                  v_error_message := SQLERRM;
                                  DBMS_OUTPUT.PUT_LINE(v_error_code);
                                  DBMS_OUTPUT.PUT_LINE(v_error_message);
                                  DBMS_OUTPUT.PUT_LINE(' ***** Failed to create AQ_MNTR_MSGS_PERSQ ! ! ! ! ! ***** ');
			end;



		]]>

		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>
	</Metric>



	<!--
	======================================================================
	== Category:         AQ MONITORING
	== Collection Level: Minimum
	== Purpose:          Alerts
	== Detials:	     Monitor the age of the first (top of the queue) message for persistent queue per subscriber
	======================================================================
	-->


	<Metric NAME="aq_msgs_persistentq_per_subscriber" TYPE="TABLE">

	<ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="11gR2" />
	</ValidIf>
	<Display>
		<Label NLSID="aq_msgs_persistentq_per_subscriber">Messages in the persistent queue per subscriber</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">

		<ColumnDescriptor NAME="schema" TYPE="STRING" IS_KEY="TRUE"  >
		<Display>
			<Label NLSID="schema">Schema Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="queue_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="queue_name">Queue Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="subs_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="subs_name">Subscriber Name</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="subs_address" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="subs_address">Subscriber Address</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="first_message_age_subs" TYPE="NUMBER" >
		<Display>
			<Label NLSID="first_message_age_subs">Age of the first message in persistent queue per subscriber (seconds) </Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="first_message_state_subs" TYPE="STRING"  >
		<Display>
			<Label NLSID="first_message_state_subs">State of the first message in persistent queue per subscriber</Label>
		</Display>
		</ColumnDescriptor>

	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[

			declare
			  lv_sql_stmt varchar2(10000);
			  TYPE data_cursor_type IS REF CURSOR;
			  data_cursor data_cursor_type;
			  qtable varchar2(512);
			  qtable2 varchar2(512); 
			  qtable3 varchar2(512); 
			  pk varchar2(32767);
			  qry1 varchar2(32767);
			  qry2 varchar2(32767);  
			  qry3 varchar2(32767);  
			  first_msg_age number;
			  first_msg_state  varchar2(512);
			  subs_id number;
			  subs_name varchar2(512);
			  subs_address varchar2(1000);
			  subs_msgid  varchar2(32767);  
			  test_cursor sys_refcursor;  
			  test_cursor2 sys_refcursor;  
			  test_cursor3 sys_refcursor;    
			  v_error_code number;
			  v_error_message varchar2(255);
			  
			begin 

				begin
				    begin
				      EXECUTE IMMEDIATE 'SELECT * FROM AQ_MNTR_MSGS_PERSQSUBS where rownum <=1';
				    exception
					WHEN OTHERS THEN 
					  v_error_code := SQLCODE; 
					  v_error_message := SQLERRM; 
					  DBMS_OUTPUT.PUT_LINE(v_error_code); 
					  DBMS_OUTPUT.PUT_LINE(v_error_message);
					  -- If table does not exist before then create it
					  IF v_error_code = -942 THEN  -- ORA-00942: table or view does not exist
					      EXECUTE IMMEDIATE 'CREATE TABLE AQ_MNTR_MSGS_PERSQSUBS (ID varchar2(2048) NOT NULL PRIMARY KEY, schema varchar2(256), queue_name varchar2(256), subs_name varchar2(256), subs_address varchar2(512), first_message_age number, first_msg_state varchar2(100))';
					  END IF;              
				    end;  

				    --If no exception means table exists already. Clean it up before reusing
				    EXECUTE IMMEDIATE 'DELETE FROM AQ_MNTR_MSGS_PERSQSUBS'; 
				exception
				    WHEN OTHERS THEN null;
				end;

				commit;

			  -- Review comment => Do not include sys/system/sysman/dbsnmp schema as these might contain system queues
			  for rec in (select owner, name, queue_table from dba_queues where owner not in ('SYS', 'SYSTEM', 'SYSMAN', 'DBSNMP') ) loop
			      begin
				    qtable := rec.owner||'.AQ$_'||rec.queue_table||'_S';
				    qtable2 := rec.owner||'.AQ$_'||rec.queue_table||'_I';
				    qtable3 := rec.owner||'.AQ$'||rec.queue_table;     
				    DBMS_OUTPUT.PUT_LINE(qtable||','||qtable2||','||qtable3);            
				    qry1 := 'select subscriber_id, name, address from ' || qtable || ' where queue_name='''||rec.name||'''';
				    
				      open test_cursor for qry1;
				      loop
					      subs_id := ''; subs_name := ''; subs_address := '';
					      fetch test_cursor into subs_id, subs_name, subs_address;
						DBMS_OUTPUT.PUT_LINE(qtable||','||rec.name||','||subs_id||','||subs_name||','||subs_address);
						pk := rec.owner||':'||rec.name||':'||subs_name||':'||subs_address;
						begin
						    
						    begin
							-- execute immediate 'select  msgid from  :1 where SUBSCRIBER# = :2  and and rownum <=1 ' into subs_msgid using qtable2, subs_id;
							qry2 := 'select  msgid from  ' || qtable2 || ' where SUBSCRIBER# = '|| subs_id ||' and rownum <=1';
							open test_cursor2 for qry2;
							subs_msgid := '';
							fetch test_cursor2 into subs_msgid;

							qry3 := 'select (sysdate-enq_time) * 86400, msg_state from '|| qtable3 ||' where msg_id ='''||subs_msgid||''''; 
							open test_cursor3 for qry3;
							first_msg_age := 0; first_msg_state := '';
							fetch test_cursor3 into first_msg_age, first_msg_state ;
							
							IF first_msg_age != 0 THEN
							  execute immediate 'insert into AQ_MNTR_MSGS_PERSQSUBS values (:1, :2, :3, :4, :5, :6, :7)' using pk, rec.owner, rec.name, subs_name, subs_address, first_msg_age, first_msg_state;
							  commit;	
							END IF;
							
						    exception
							    WHEN NO_DATA_FOUND THEN
							    DBMS_OUTPUT.PUT_LINE(' ***** FIRST QUERY RETURNED NO DATA***** ');
						    end;
						    
						    -- Reset after using
						    first_msg_age := 0;
						    first_msg_state := '';
						    close test_cursor2; 
						    close test_cursor3;                             
						    
						exception
						    WHEN OTHERS  THEN 
						    v_error_code := SQLCODE;
						    v_error_message := SQLERRM;
						    DBMS_OUTPUT.PUT_LINE(v_error_code);
						    DBMS_OUTPUT.PUT_LINE(v_error_message);
						    DBMS_OUTPUT.PUT_LINE(' ***** Insert into AQ_MNTR_MSGS_PERSQSUBS failed might be due to unique key constraint ***** ');
						end;                 
					      exit when test_cursor %notfound;
				      end loop;
				      close test_cursor;      
			     EXCEPTION
			       WHEN others THEN 
			       DBMS_OUTPUT.PUT_LINE('INSIDE THE MAIN LOOP >>>> NO DATA CONTINUE....');  
			    end;
			      
			  end loop;
			  lv_sql_stmt:='select schema, queue_name, subs_name, subs_address, first_message_age, first_msg_state from AQ_MNTR_MSGS_PERSQSUBS';
			  open data_cursor for lv_sql_stmt;
			  :1 := data_cursor;

			exception
				WHEN OTHERS THEN
				DBMS_OUTPUT.PUT_LINE(' ***** Failed to create AQ_MNTR_MSGS_PERSQSUBS ! ! ! ! ! ***** ');
			end;


		]]>

		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>
	</Metric>



	<!--
	======================================================================
	== Category:         AQ MONITORING
	== Collection Level: Minimum
	== Purpose:          Alerts
	== Detials:	     Monitor the age of the first (top of the queue) message for persistent queue per subscriber
	======================================================================
	-->


	<Metric NAME="aq_msgs_bufferedqueue" TYPE="TABLE">

	<ValidIf>
	<CategoryProp NAME="VersionCategory" CHOICES="11gR2" />
	</ValidIf>
	<Display>
		<Label NLSID="aq_msgs_bufferedqueue">Messages in the buffered queue</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">

		<ColumnDescriptor NAME="schema" TYPE="STRING" IS_KEY="TRUE"  >
		<Display>
			<Label NLSID="schema">Schema Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="queue_name" TYPE="STRING" IS_KEY="TRUE" >
		<Display>
			<Label NLSID="queue_name">Queue Name</Label>
		</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="buffq_first_message_age" TYPE="NUMBER" >
		<Display>
			<Label NLSID="buffq_first_message_age">Age of the first message in the buffered queue per queue (seconds)</Label>
		</Display>
		</ColumnDescriptor>
		<ColumnDescriptor NAME="buffq_first_message_state" TYPE="STRING"  >
		<Display>
			<Label NLSID="buffq_first_message_state">State of the first message in the buffered queue per queue</Label>
		</Display>
		</ColumnDescriptor>

	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
		<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
		<![CDATA[


            declare
                v_error_code number;
                v_error_message varchar2(255);
                qtable varchar2(512); 
                first_msg_age number;
                first_msg_state  varchar2(512);
                qry varchar2(32767);  
                test_cursor sys_refcursor; 
                lv_sql_stmt varchar2(10000);
                TYPE data_cursor_type IS REF CURSOR;
                data_cursor data_cursor_type;

            begin

				begin
				    begin
				      EXECUTE IMMEDIATE 'SELECT * FROM AQ_MNTR_MSGS_BUFFQ where rownum <=1';
				    exception
					WHEN OTHERS THEN 
					  v_error_code := SQLCODE; 
					  v_error_message := SQLERRM; 
					  DBMS_OUTPUT.PUT_LINE(v_error_code); 
					  DBMS_OUTPUT.PUT_LINE(v_error_message);
					  -- If table does not exist before then create it
					  IF v_error_code = -942 THEN  -- ORA-00942: table or view does not exist
					      EXECUTE IMMEDIATE 'CREATE TABLE AQ_MNTR_MSGS_BUFFQ (schema varchar2(256), queue_name varchar2(256), buffq_first_message_age number, buffq_first_message_state varchar2(100))';
					  END IF;              
				    end;  

				    --If no exception means table exists already. Clean it up before reusing
				    EXECUTE IMMEDIATE 'DELETE FROM AQ_MNTR_MSGS_BUFFQ'; 
				exception
				    WHEN OTHERS THEN null;
				end;

				commit;

			  for rec in (select owner, name, queue_table from dba_queues where owner not in ( 'SYS', 'SYSTEM', 'SYSMAN', 'DBSNMP') ) loop
                   DBMS_OUTPUT.PUT_LINE('+++++  BEGIN  +++++');                            
			      begin
				    qtable := rec.owner||'.AQ$'||rec.queue_table;     
				    DBMS_OUTPUT.PUT_LINE(qtable||','||rec.name); 

                    begin
                        first_msg_age := 0; first_msg_state := '';
                        qry := 'select (sysdate-enq_time) * 86400, msg_state from '|| qtable ||' 
                                where msg_id=(select OLDEST_MSGID from v$buffered_queues where queue_schema='''||rec.owner||''' and queue_name='''||rec.name||''')'; 
                        --qry3 := 'select (sysdate-enq_time) * 86400, msg_state from '|| qtable ||' where msg_id ='''||subs_msgid||''''; 
                        DBMS_OUTPUT.PUT_LINE(qry);
                        open test_cursor for qry;
                        fetch test_cursor into first_msg_age, first_msg_state ;
                        DBMS_OUTPUT.PUT_LINE(first_msg_age||','||first_msg_state); 
                        
                        IF first_msg_age != 0 THEN
                          execute immediate 'insert into AQ_MNTR_MSGS_BUFFQ values (:1, :2, :3, :4)' using rec.owner, rec.name, first_msg_age, first_msg_state;
                          commit;	
                        END IF;
                     exception
                       WHEN others THEN 
                        v_error_code := SQLCODE;
                        v_error_message := SQLERRM;
                        DBMS_OUTPUT.PUT_LINE(v_error_code);
                        DBMS_OUTPUT.PUT_LINE(v_error_message);
                        DBMS_OUTPUT.PUT_LINE('Error in inserting into AQ_MNTR_MSGS_BUFFQ....');  
                    end;                      
                 DBMS_OUTPUT.PUT_LINE('+++++  END  +++++');  
                                     
                  EXCEPTION
			       WHEN others THEN 
                                v_error_code := SQLCODE;
                                v_error_message := SQLERRM;
                                DBMS_OUTPUT.PUT_LINE(v_error_code);
                                DBMS_OUTPUT.PUT_LINE(v_error_message);                               
			        DBMS_OUTPUT.PUT_LINE('INSIDE THE MAIN LOOP >>>> NO DATA CONTINUE....');  
			    END;
			  
            --execute immediate 'select schema, queue_name, buffq_first_message_age, buffq_first_message_state from AQ_MNTR_MSGS_BUFFQ'; 

			  end loop;
			  lv_sql_stmt:='select schema, queue_name, buffq_first_message_age, buffq_first_message_state from AQ_MNTR_MSGS_BUFFQ';
			  open data_cursor for lv_sql_stmt;
			  :1 := data_cursor;

			exception
				WHEN OTHERS THEN 
                  v_error_code := SQLCODE;
                  v_error_message := SQLERRM;
                  DBMS_OUTPUT.PUT_LINE(v_error_code);
                  DBMS_OUTPUT.PUT_LINE(v_error_message);
                  DBMS_OUTPUT.PUT_LINE(' ***** Failed to create AQ_MNTR_MSGS_BUFFQ ! ! ! ! ! ***** ');
			end;

		]]>

		</Property>
		<Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
		<Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
		<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
		<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
		<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
		<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
		<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
		<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>
	</Metric>


	<!-- **********  AQ MONITORING ALERTS END **********  -->


	<!--
	======================================================================
	== Category:         Streams Capture process
	== Collection Level: Minimum
	== Purpose:          message stats
	======================================================================
	-->

	<Metric NAME="capture_message" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="capture_message">Streams Capture Message Statistics</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="CAPTURE_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="capture_message_capture_name">Capture Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_MESSAGES_CAPTURED" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="capture_message_total_messages_captured">Total Messages Captured</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_MESSAGES_ENQUEUED" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="capture_message_total_messages_enqueued">Total Messages Enqueued</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_MESSAGES_CAPTURED_PER_MIN" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" COMPUTE_EXPR="(TOTAL_MESSAGES_CAPTURED - _TOTAL_MESSAGES_CAPTURED)/(__interval)">
	<Display>
		<Label NLSID="capture_message_total_msgs_captured_permin">Message Capture Rate(per Sec)</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_MESSAGES_ENQUEUED_PER_MIN" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(TOTAL_MESSAGES_ENQUEUED - _TOTAL_MESSAGES_ENQUEUED)/(__interval)">

	<Display>
		<Label NLSID="capture_message_total_msgs_enqueued_permin">Messages Enqueue Rate(per Sec)</Label>
	</Display>
	</ColumnDescriptor>

	</TableDescriptor>



	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select  a.capture_name capture_name,total_messages_captured,total_messages_enqueued 
		from gv$streams_capture a,dba_capture b,dba_queues c,dba_queue_tables d
		where a.capture_name = b.capture_name and b.queue_name=c.name and b.queue_owner=c.owner
		and c.queue_table=d.queue_table and c.owner=d.owner and d.owner_instance=a.inst_id
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>

	<!--
	======================================================================
	== Category:         Streams Capture process
	== Collection Level: Minimum
	== Purpose:          queue stats
	======================================================================
	-->


	<Metric NAME="capture_queue" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="capture_queue">Streams Capture Queue Statistics</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="CAPTURE_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="capture_queue_capture_name">Capture Name</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="NUM_MSGS" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="capture_queue_num_msgs">Capture Queue - Number of Messages</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="SPILL_MSGS" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="capture_queue_spill_msgs">Capture Queue - Number of Spilled Messages</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="CNUM_MSGS" TYPE="NUMBER" IS_KEY="FALSE">
	<Display>
		<Label NLSID="capture_queue_cnum_msgs">Capture Queue - Cumulative Number of Messages</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="CSPILL_MSGS" TYPE="NUMBER" IS_KEY="FALSE">
	<Display>
		<Label NLSID="capture_queue_cspill_msgs">Capture Queue - Cumulative Number of Spilled Messages</Label>
	</Display>
	</ColumnDescriptor>


	<ColumnDescriptor NAME="capture_queue_perc_spilled_msgs" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(NUM_MSGS == 0) ? (0) : ((SPILL_MSGS/(NUM_MSGS))*100)" >
		<Display>
			<Label NLSID="capture_queue_perc_spilled_msgs">Streams Capture - (%)Spilled Messages</Label>
			<Unit NLSID="em__sys__standard_percent">%</Unit> 
		</Display>
	</ColumnDescriptor>
	<ColumnDescriptor NAME="capture_queue_perc_cspilled_msgs" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(CNUM_MSGS == 0) ? (0) : ((CSPILL_MSGS/(CNUM_MSGS))*100)" >
		<Display>
			<Label NLSID="capture_queue_perc_cspilled_msgs">Streams Capture - (%)Cumulative Spilled Messages</Label>
			<Unit NLSID="em__sys__standard_percent">%</Unit> 
		</Display>
	</ColumnDescriptor>



	</TableDescriptor>



	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select CAPTURE_NAME, NUM_MSGS, SPILL_MSGS, CNUM_MSGS, CSPILL_MSGS from 
		gv$buffered_queues b,dba_capture c,dba_queues q,dba_queue_tables t 
		where  c.queue_name = b.queue_name and c.queue_owner = b.queue_schema 
		and c.queue_name = q.name and c.queue_owner = q.owner  
		and q.queue_table=t.queue_table and q.owner=t.owner 
		and b.inst_id = t.owner_instance
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>

	<!--
	======================================================================
	== Category:         Streams Propagation Job
	== Collection Level: 30 mins
	== Purpose:          Message state stats for messages in propagation queue
	======================================================================
	-->


	<Metric NAME="propagation_msgstate_stats" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="propagation_msgstate_stats">Streams Propagation - Message State Stats</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	
	<ColumnDescriptor NAME="PROPAGATION_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_msgstate_stats_name">Propagation Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="MESSAGE_DELIVERY_MODE" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_msgstate_stats_mode">Messages Delivery Mode</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="READY" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_msgstate_stats_ready">Number of Ready Messages</Label>
	</Display>

	</ColumnDescriptor>
	<ColumnDescriptor NAME="WAITING" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_msgstate_stats_waiting">Number of Waiting Messages</Label>
	</Display>
	</ColumnDescriptor>
	<ColumnDescriptor NAME="propagation_msgstate_stats_perc_waiting" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="((WAITING/(READY+WAITING))*100)" >
		<Display>
			<Label NLSID="propagation_msgstate_stats_perc">Streams Prop - (%)Messages in Waiting State</Label>
			<Unit NLSID="em__sys__standard_percent">%</Unit>
		</Display>
	</ColumnDescriptor>
	

	
	</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="OSLineToken" >
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
			%perlBin%/perl %scriptsDir%/streams/pstats.pl
			</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="ENVSTREAMS_TYPE" SCOPE="GLOBAL">PROPAGATION</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
			</Property>
			 <Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
		</QueryDescriptor>

	</Metric>

	<!--
	======================================================================
	== Category:         Streams Apply process
	== Collection Level: 30mins
	== Purpose:          queue stats if apply type is persistent
	======================================================================
	-->

	<Metric NAME="apply_queue_persq" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="apply_queue_persq">Streams Apply Queue - Persistent </Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="APPLY_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_queue_persq_apply_name">Apply Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="MESSAGE_DELIVERY_MODE" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_queue_persq_stats_ready">Messages Delivery Mode</Label>
	</Display>
	</ColumnDescriptor>


	<ColumnDescriptor NAME="READY" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_queue_persq_ready">Number of Ready Messages</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="WAITING" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="apply_queue_persq_waiting">Number of Waiting Messages</Label>
	</Display>
	</ColumnDescriptor>
	
	<ColumnDescriptor NAME="apply_persq_perc_waiting" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="((WAITING/(READY+WAITING))*100)" >
		<Display>
			<Label NLSID="apply_persq_perc_waiting">Streams Apply - (%)Messages in Waiting State</Label>
			<Unit NLSID="em__sys__standard_percent">%</Unit>
		</Display>
	</ColumnDescriptor>
	

	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="OSLineToken" >
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
			%perlBin%/perl %scriptsDir%/streams/pstats.pl
			</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="ENVSTREAMS_TYPE" SCOPE="GLOBAL">APPLY</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVVersionCategory" SCOPE="INSTANCE">VersionCategory</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
			</Property>
		</QueryDescriptor>

	</Metric>




	<!--
	======================================================================
	== Category:         Streams Apply process
	== Collection Level: Minimum
	== Purpose:          queue stats if apply type is buffered
	======================================================================
	-->

	<Metric NAME="apply_queue_buffq" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="apply_queue_buffq">Streams Apply Queue - Buffered </Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="APPLY_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_queue_buffq_apply_name">Apply Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="NUM_MSGS" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_queue_buffq_nomsgs">Apply Queue - Number of Messages</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="SPILL_MSGS" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="apply_queue_buffq_nospillmsgs">Apply Queue - Number of Spilled Messages </Label>
	</Display>
	</ColumnDescriptor>
	
	<ColumnDescriptor NAME="apply_queue_perc_spilled_msgs" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(NUM_MSGS == 0) ? (0) : ((SPILL_MSGS/(NUM_MSGS))*100)" >
		<Display>
			<Label NLSID="apply_queue_perc_spilled_msgs">Streams Apply - (%)Spilled Messages</Label>
			<Unit NLSID="em__sys__standard_percent">%</Unit>
		</Display>
	</ColumnDescriptor>
	
	<ColumnDescriptor NAME="CNUM_MSGS" TYPE="NUMBER" IS_KEY="FALSE">
	<Display>
		<Label NLSID="apply_queue_buffq_cnomsgs">Apply Queue - Cumulative Number of Messages</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="CSPILL_MSGS" TYPE="NUMBER" IS_KEY="FALSE">

	<Display>
		<Label NLSID="apply_queue_buffq_cnospillmsgs">Apply Queue - Cumulative Number of Spilled Messages </Label>
	</Display>
	</ColumnDescriptor>
	
	<ColumnDescriptor NAME="apply_queue_perc_cspilled_msgs" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(CNUM_MSGS == 0) ? (0) : ((CSPILL_MSGS/(CNUM_MSGS))*100)" >
		<Display>
			<Label NLSID="apply_queue_perc_cspilled_msgs">Streams Apply - (%)Cumulative Spilled Messages</Label>
			<Unit NLSID="em__sys__standard_percent">%</Unit>
		</Display>
	</ColumnDescriptor>

	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select apply_name, s.num_msgs num_msgs, q.spill_msgs spill_msgs,s.cnum_msgs cnum_msgs, q.cspill_msgs cspill_msgs from
		dba_apply a, gv$buffered_queues q,gv$buffered_subscribers  s, dba_queues d, dba_queue_tables t 
		where  a.queue_name = s.queue_name and a.queue_owner = s.queue_schema 
		and a.queue_name = q.queue_name and a.queue_owner = q.queue_schema 
		and a.apply_name = s.subscriber_name
		and s.subscriber_address is null and a.queue_owner = d.owner 
		and a.queue_name = d.name and d.queue_table = t.queue_table 
		and q.inst_id = s.inst_id and q.inst_id = t.owner_instance
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>



	<!--
	======================================================================
	== Category:         Streams Apply process
	== Collection Level: Minimum
	== Purpose:          Reader stats
	======================================================================
	-->

	<Metric NAME="apply_reader" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="apply_reader">Streams Apply Reader Statistics</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="APPLY_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_reader_apply_name">Apply Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_MESSAGES_DEQUEUED" TYPE="NUMBER" >
	<Display>
		<Label NLSID="apply_reader_total_dequeued">Total number of Messages Dequeued </Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_MESSAGES_SPILLED" TYPE="NUMBER">
	<Display>
		<Label NLSID="apply_reader_total_spilled">Total number of Spilled Messages</Label>
	</Display>
	</ColumnDescriptor>
	<ColumnDescriptor NAME="DEQUEUE_RATE" TYPE="NUMBER" COMPUTE_EXPR="(TOTAL_MESSAGES_DEQUEUED - _TOTAL_MESSAGES_DEQUEUED)/(__interval)">
	<Display>
		<Label NLSID="apply_reader_dequeued_rate">Rate at which messages are being dequeued(per Sec)</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="MESSAGES_SPILL_RATE" TYPE="NUMBER" COMPUTE_EXPR="(TOTAL_MESSAGES_SPILLED - _TOTAL_MESSAGES_SPILLED)/(__interval)">
	<Display>
		<Label NLSID="apply_reader_spilled_rate">Rate at which messages are getting spilled(per Sec)</Label>
	</Display>
	</ColumnDescriptor>

	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2"/>
	</ValidIf>
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select r.apply_name apply_name, total_messages_dequeued, total_messages_spilled from gv$streams_apply_reader r, dba_apply a, dba_queues q, dba_queue_tables t
		where r.apply_name = a.apply_name and a.queue_name = q.name and a.queue_owner = q.owner
		and q.queue_table = t.queue_table and q.owner=t.owner and r.inst_id = t.owner_instance
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1"/>
	</ValidIf>
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select r.apply_name apply_name, total_messages_dequeued, null total_messages_spilled from gv$streams_apply_reader r, dba_apply a, dba_queues q, dba_queue_tables t
		where r.apply_name = a.apply_name and a.queue_name = q.name and a.queue_owner = q.owner
		and q.queue_table = t.queue_table and q.owner=t.owner and r.inst_id = t.owner_instance
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>


	<!--
	======================================================================
	== Category:         Streams Apply process
	== Collection Level: Minimum
	== Purpose:          coordinator stats
	======================================================================
	-->

	<Metric NAME="apply_coord" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="apply_coord">Streams Apply Coordinator Statistics</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="APPLY_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_coord_apply_name">Apply Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_RECEIVED" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_coord_total_received">Total Number of Transactions Received</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_ASSIGNED" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="apply_coord_total_assigned">Total Number of Transactions Assigned</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_APPLIED" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="apply_coord_total_applied">Total number of Transactions applied</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_RECEIVED_RATE" TYPE="NUMBER" COMPUTE_EXPR="(TOTAL_RECEIVED - _TOTAL_RECEIVED)/(__interval)">
	<Display>
		<Label NLSID="apply_coord_received_rate">Rate of Transactions Received(per Sec)</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_ASSIGNED_RATE" TYPE="NUMBER" COMPUTE_EXPR="(TOTAL_ASSIGNED - _TOTAL_ASSIGNED)/(__interval)">

	<Display>
		<Label NLSID="apply_coord_assigned_rate">Rate of  Transactions Assigned(per Sec)</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_APPLIED_RATE" TYPE="NUMBER"  COMPUTE_EXPR="(TOTAL_APPLIED - _TOTAL_APPLIED)/(__interval)">

	<Display>
		<Label NLSID="apply_coord_applied_rate">Rate of  Transactions Applied(per Sec)</Label>
	</Display>
	</ColumnDescriptor>

	</TableDescriptor>



	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select r.apply_name apply_name, r.total_received total_received, r.total_assigned total_assigned,r.total_applied total_applied from
		gv$streams_apply_coordinator r, dba_apply a, dba_queues q, dba_queue_tables t
		where r.apply_name = a.apply_name and a.queue_name = q.name and a.queue_owner = q.owner
		and q.queue_table = t.queue_table and q.owner=t.owner and r.inst_id = t.owner_instance
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>

	<!--
	======================================================================
	== Category:         Streams Apply process
	== Collection Level: Minimum
	== Purpose:          Errors in Apply Process
	======================================================================
	-->

	<Metric NAME="apply_errors"  TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="apply_errors">Streams Apply Errors</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="APPLY_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_errors_apply_name">Apply Name</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="QUEUE_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_errors_queue_name">Apply Queue Name</Label>
	</Display>
	</ColumnDescriptor>
	
	<ColumnDescriptor NAME="SOURCE_DATABASE" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_errors_srcdb">Source Database</Label>
	</Display>
	</ColumnDescriptor>
	 
	 <ColumnDescriptor NAME="LOCAL_TRANSACTION_ID" TYPE="STRING" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_errors_ltxnid">Local Transaction ID</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="SOURCE_TRANSACTION_ID" TYPE="STRING" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_errors_stxnid">Source Transaction ID</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="MESSAGE_COUNT" TYPE="STRING" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="apply_errors_msgcnt">Message Count</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="ERROR_NUMBER" TYPE="STRING" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="apply_errors_error_number">Error Number</Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="ERROR_MESSAGE" TYPE="STRING" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="apply_errors_error_msg">Error Message</Label>
	</Display>
	</ColumnDescriptor>

	</TableDescriptor>



	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select APPLY_NAME,QUEUE_NAME,SOURCE_DATABASE,LOCAL_TRANSACTION_ID,SOURCE_TRANSACTION_ID,MESSAGE_COUNT,ERROR_NUMBER,ERROR_MESSAGE
		from dba_apply_error where ERROR_CREATION_TIME=(select max(ERROR_CREATION_TIME) from dba_apply_error)
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>




	<!--
	======================================================================
	== Category		 :  Streams propagation process
	== Collection Level:  Minimum
	== Purpose		 :  Sender Statistics for queue component of streams propagation job.
	======================================================================
	-->

	<Metric NAME="propagation_sender_stats" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="propagation_sender_stats">Streams Propagation  - Queue Propagation</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
	<ColumnDescriptor NAME="PROPAGATION_NAME" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_sender_stats_propagation_name">Propagation Name</Label>
	</Display>
	</ColumnDescriptor>
	
	<ColumnDescriptor NAME="MESSAGE_DELIVERY_MODE" TYPE="STRING" IS_KEY="TRUE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_sender_stats_mode">Message Delivery Mode</Label>
	</Display>
	</ColumnDescriptor>
	<ColumnDescriptor NAME="TOTAL_NUMBER" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">
	<Display>
		<Label NLSID="propagation_sender_stats_nomsgs">Total Number of Messages Propagated </Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="KBYTES" TYPE="NUMBER" IS_KEY="FALSE" TRANSIENT="FALSE" IS_LONG_TEXT="FALSE" IS_DATE="FALSE" STATELESS_ALERTS="FALSE" IS_TIMESTAMP="FALSE">

	<Display>
		<Label NLSID="propagation_sender_stats_kbytes">Total Number of KBytes Propagated </Label>
	</Display>
	</ColumnDescriptor>

	<ColumnDescriptor NAME="TOTAL_NUMBER_RATE" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(TOTAL_NUMBER - _TOTAL_NUMBER)/(__interval)" >
	<Display>
		<Label NLSID="propagation_sender_stats_ratemsgs">Message Propagation Rate (per sec)</Label>
	</Display>

	</ColumnDescriptor>

	<ColumnDescriptor NAME="KBYTES_RATE" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(KBYTES - _KBYTES)/(__interval)" >

	<Display>
		<Label NLSID="propagation_sender_stats_ratekbs">Rate of KBytes Propagated (per sec)</Label>
	</Display>
	</ColumnDescriptor>


	</TableDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
	 SELECT PROPAGATION_NAME,MESSAGE_DELIVERY_MODE, TOTAL_NUMBER, TOTAL_BYTES/1024 KBYTES FROM DBA_PROPAGATION P, DBA_QUEUE_SCHEDULES Q
	 WHERE  P.SOURCE_QUEUE_NAME = Q.QNAME AND P.SOURCE_QUEUE_OWNER = Q.SCHEMA AND MESSAGE_DELIVERY_MODE='BUFFERED'
	 AND Q.DESTINATION LIKE '%'||P.DESTINATION_DBLINK||'%' 
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>


	</Metric>

	<!--
	======================================================================
	== Category:         Streams Latency and Throughput
	== Collection Level: 10 mins
	== Purpose:          Latency and Throughput for Streams processes
	======================================================================
	-->

	<Metric NAME="streams_latency_throughput"  TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">

	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203;11gR1;11gR2" />
	        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
	</ValidIf>
	<Display>
		<Label NLSID="streams_latency_throughput">Streams Latency and Throughput</Label>
	</Display>
	<TableDescriptor SKIP_TARGET_COLUMN="FALSE" SKIP_METRIC_COLUMN="FALSE" SKIP_COLLTIME_PK="FALSE" SKIP_COLLTIME_COLUMN="FALSE">
		<ColumnDescriptor NAME="streams_process_name" TYPE="STRING" IS_KEY="TRUE" >
			<Display>
				<Label NLSID="streams_process_name">Streams Process Name</Label>
			</Display>
		</ColumnDescriptor>

		 <ColumnDescriptor NAME="streams_process_type" TYPE="STRING" IS_KEY="TRUE" >
			<Display>
				<Label NLSID="streams_process_type">Streams Process Type</Label>
			</Display>
		</ColumnDescriptor>
	
		<ColumnDescriptor NAME="streams_latency" TYPE="NUMBER" IS_KEY="FALSE" >
			<Display>
				<Label NLSID="streams_latency">Latency</Label>
			</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="TOTAL_MESSAGES" TYPE="NUMBER" IS_KEY="FALSE" >
			<Display>
				<Label NLSID="streams_total_messages">Total Messages</Label>
			</Display>
		</ColumnDescriptor>

		<ColumnDescriptor NAME="streams_throughput" TYPE="NUMBER" IS_KEY="FALSE" COMPUTE_EXPR="(TOTAL_MESSAGES > _TOTAL_MESSAGES) ? ( (TOTAL_MESSAGES - _TOTAL_MESSAGES)/__interval ) : ( (_TOTAL_MESSAGES - TOTAL_MESSAGES)/__interval )">
			<Display>
				<Label NLSID="streams_throughput">Throughput(per sec)</Label>
			</Display>

		</ColumnDescriptor>		

	</TableDescriptor>



	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="10gR2;10gR203"/>
	</ValidIf>
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select capture_name streams_name,'capture' streams_type , (available_message_create_time-capture_message_create_time)*86400 latency, 
		nvl(total_messages_enqueued,0) total_messages from gv$streams_capture
		union all
		select dba_propagation.propagation_name streams_name,'propagation' streams_type,null streams_latency , total_msgs total_messages from gv$propagation_sender, dba_propagation
		where source_queue_owner=queue_schema and source_queue_name=queue_name and dblink='"'||destination_queue_owner ||'"' ||'.'||'"' ||destination_queue_name||'"@'||destination_dblink
		union all
		SELECT apc.apply_name                     as STREAMS_NAME,
        'apply'                            as STREAMS_TYPE,
        nvl(aps.TOTAL_MESSAGES_APPLIED, 0) as TOTAL_MESSAGES,
         CASE WHEN aps.state != 'IDLE' THEN
               nvl((aps.apply_time - aps.create_time)*86400, -1)
             WHEN apc.state != 'IDLE' THEN
               nvl((apc.apply_time - apc.create_time)*86400, -1)
             WHEN apr.state != 'IDLE' THEN
               nvl((apr.apply_time - apr.create_time)*86400, -1)
             ELSE 0
        END                                as STREAMS_LATENCY,
	nvl(aps.TOTAL_MESSAGES_APPLIED, 0) as TOTAL_MESSAGES 
 FROM ( SELECT * FROM (
           SELECT distinct apply_name,
               state,
               apply_time,
               applied_message_create_time as create_time,
               total_messages_applied
           FROM ( SELECT apply_name,
                      state,
                      apply_time,
                      applied_message_create_time,
                      MAX(applied_message_create_time)
                        OVER (PARTITION BY apply_name)
                        as max_create_time,
                      SUM(total_messages_applied)
                        OVER (PARTITION BY apply_name)
                        as total_messages_applied
               FROM gv$streams_apply_server )
           WHERE MAX_CREATE_TIME||'X' =
              APPLIED_MESSAGE_CREATE_TIME||'X' ) 
        WHERE rownum = 1) aps,
      ( SELECT apply_name,
               state,
               lwm_time                     as apply_time,
               lwm_message_create_time      as create_time
        FROM gv$streams_apply_coordinator ) apc,
      ( SELECT apply_name,
               state,
               dequeue_time                 as apply_time,
               dequeued_message_create_time as create_time
        FROM gv$streams_apply_reader ) apr
 WHERE apc.apply_name = apr.apply_name AND
       apr.apply_name = aps.apply_name 	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="11gR1"/>
	</ValidIf>
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select capture_name streams_name,'capture' streams_type , (available_message_create_time-capture_message_create_time)*86400 latency,
		nvl(total_messages_enqueued,0) total_messages from gv$streams_capture
		union all
		select propagation_name streams_name,'propagation' streams_type,last_lcr_latency latency , total_msgs total_messages 
		from gv$propagation_sender where propagation_name is not null
		union all
		SELECT apc.apply_name                     as STREAMS_NAME,
        'apply'                            as STREAMS_TYPE,                
        CASE WHEN aps.state != 'IDLE' THEN
               nvl((aps.apply_time - aps.create_time)*86400, -1)
             WHEN apc.state != 'IDLE' THEN
               nvl((apc.apply_time - apc.create_time)*86400, -1)
             WHEN apr.state != 'IDLE' THEN
               nvl((apr.apply_time - apr.create_time)*86400, -1)
             ELSE 0
        END                                as STREAMS_LATENCY,
	nvl(aps.TOTAL_MESSAGES_APPLIED, 0) as TOTAL_MESSAGES 
 FROM ( SELECT * FROM (
           SELECT distinct apply_name,
               state,
               apply_time,
               applied_message_create_time as create_time,
               total_messages_applied
           FROM ( SELECT apply_name,
                      state,
                      apply_time,
                      applied_message_create_time,
                      MAX(applied_message_create_time)
                        OVER (PARTITION BY apply_name)
                        as max_create_time,
                      SUM(total_messages_applied)
                        OVER (PARTITION BY apply_name)
                        as total_messages_applied
               FROM gv$streams_apply_server )
           WHERE MAX_CREATE_TIME||'X' =
              APPLIED_MESSAGE_CREATE_TIME||'X' ) 
        WHERE rownum = 1) aps,
      ( SELECT apply_name,
               state,
               lwm_time                     as apply_time,
               lwm_message_create_time      as create_time
        FROM gv$streams_apply_coordinator ) apc,
      ( SELECT apply_name,
               state,
               dequeue_time                 as apply_time,
               dequeued_message_create_time as create_time
        FROM gv$streams_apply_reader ) apr
 WHERE apc.apply_name = apr.apply_name AND
       apr.apply_name = aps.apply_name 
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>

	<QueryDescriptor FETCHLET_ID="SQL" NEED_CHARSET_CONVERT="TRUE">
	 <ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
	</ValidIf>
	<Property NAME="STATEMENT" SCOPE="GLOBAL" OPTIONAL="FALSE">
	<![CDATA[
		select capture_name streams_name,
		       'capture' streams_type ,
		       (available_message_create_time-
			capture_message_create_time)*86400 latency,
		       nvl(total_messages_enqueued,0) total_messages
		from gv$streams_capture
		union all
		select propagation_name streams_name,
		       'propagation' streams_type,
		       last_lcr_latency latency ,
		       total_msgs total_messages
		from gv$propagation_sender where propagation_name is not null
		union all
		select server_name streams_name,
		       'apply' streams_type,
		       (send_time-last_sent_message_create_time)*86400 latency,
		       nvl(total_messages_sent,0) total_messages
		from gv$xstream_outbound_server where committed_data_only='NO'
		union all
		SELECT distinct apc.apply_name as STREAMS_NAME,
		      'apply' as STREAMS_TYPE,
		      CASE WHEN aps.state != 'IDLE' THEN
			  nvl((aps.apply_time - aps.create_time)*86400, -1)
			WHEN apc.state != 'IDLE' THEN
			  nvl((apc.apply_time - apc.create_time)*86400, -1)
			WHEN apr.state != 'IDLE' THEN
			  nvl((apr.apply_time - apr.create_time)*86400, -1)
			ELSE 0
		      END as STREAMS_LATENCY,
		      nvl(aps.TOTAL_MESSAGES_APPLIED, 0) as TOTAL_MESSAGES
		FROM ( SELECT apply_name,
			      state,
			      apply_time,
			      applied_message_create_time as create_time,
			      total_messages_applied
		       FROM ( SELECT apply_name,
				     state,
				     apply_time,
				     applied_message_create_time,
				     MAX(applied_message_create_time)
				       OVER (PARTITION BY apply_name) as max_create_time,
				     SUM(total_messages_applied)
				       OVER (PARTITION BY apply_name) as total_messages_applied
			      FROM gv$streams_apply_server )
		       WHERE MAX_CREATE_TIME||'X' =
			     APPLIED_MESSAGE_CREATE_TIME||'X' ) aps,
		     ( SELECT c.apply_name,
			      state,
			      --   This is the XOUT case
			      c.hwm_time                  as apply_time,
			      hwm_message_create_time     as create_time,
			      total_applied
		       FROM gv$streams_apply_coordinator c, dba_apply p
		       WHERE p.apply_name = c.apply_name
				and p.apply_name in
				(select server_name from dba_xstream_outbound)
		       union
		       SELECT c.apply_name,
			      state,
			      --   This is non-XOUT case
			      c.lwm_time                  as apply_time,
			      lwm_message_create_time     as create_time,
			      total_applied
		       FROM gv$streams_apply_coordinator c, dba_apply p
		       WHERE p.apply_name = c.apply_name
				and p.apply_name not in
				(select server_name from dba_xstream_outbound) ) apc,
		     ( SELECT apply_name,
			      state,
			      dequeue_time                 as apply_time,
			      dequeued_message_create_time as create_time
		       FROM gv$streams_apply_reader ) apr
		    WHERE apc.apply_name = apr.apply_name AND
			  apr.apply_name = aps.apply_name 
	]]>
	</Property>
	<Property NAME="MachineName" SCOPE="INSTANCE" OPTIONAL="FALSE">MachineName</Property>
	<Property NAME="Port" SCOPE="INSTANCE" OPTIONAL="FALSE">Port</Property>
	<Property NAME="SID" SCOPE="INSTANCE" OPTIONAL="FALSE">SID</Property>
	<Property NAME="UserName" SCOPE="INSTANCE" OPTIONAL="FALSE">UserName</Property>
	<Property NAME="password" SCOPE="INSTANCE" OPTIONAL="FALSE">password</Property>
	<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
	</QueryDescriptor>

	</Metric>


<Metric NAME="DatabaseVaultRealmViolation" TYPE="TABLE" >
	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	</ValidIf>
	
    <Display>
            <Label NLSID="dv_realm_violation_nlsid">Database Vault Attempted Violations - Realms</Label>
    </Display>


	<TableDescriptor >

        <ColumnDescriptor NAME="ACTION_OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" >
	        <Display>
	                <Label NLSID="dv_realm_nlsid">Database Vault Realm </Label>
	        </Display>
        </ColumnDescriptor>
	
    
        <ColumnDescriptor NAME="ACTION_COMMAND" TYPE="STRING" STATELESS_ALERTS="TRUE">
                <Display>
                        <Label NLSID="dv_realm_violation_count_nlsid">Database Vault Attempted Violations Count - Realms</Label>
                </Display>
        </ColumnDescriptor>
 
          <ColumnDescriptor NAME="VIOLATIONTIMESTAMP" TYPE="STRING" IS_KEY="TRUE">
            <Display>
             <Label NLSID="dv_violation_timestamp_nlsid">Violation Time</Label>
            </Display>
          </ColumnDescriptor>
                  
	</TableDescriptor>


		<QueryDescriptor FETCHLET_ID="OSLineToken" >
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
			%perlBin%/perl %scriptsDir%/dv/realmviolations.pl
			</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
			</Property>
      <Property NAME="ENVEM_AGENT_STATE_DIR" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
      <Property NAME="ENVEM_TARGET_GUID" SCOPE="INSTANCE">GUID</Property>
			
		</QueryDescriptor>

        
</Metric>


<Metric NAME="DatabaseVaultCommandRuleViolation" TYPE="TABLE" >
	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	</ValidIf>
	
    <Display>
            <Label NLSID="dv_command_rule_violation_nlsid">Database Vault Attempted Violations - Command Rules</Label>
    </Display>

	<TableDescriptor >

        <ColumnDescriptor NAME="ACTION_OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" >
	        <Display>
	                <Label NLSID="dv_command_rule_nlsid">Database Vault Command Rule </Label>
	        </Display>
        </ColumnDescriptor>
	
    
        <ColumnDescriptor NAME="ACTION_COMMAND" TYPE="STRING" STATELESS_ALERTS="TRUE">



                <Display>
                        <Label NLSID="dv_command_rule_violation_count_nlsid">Database Vault Attempted Violations Count - Command Rules</Label>
                </Display>
        </ColumnDescriptor>
 
          <ColumnDescriptor NAME="VIOLATIONTIMESTAMP" TYPE="STRING" IS_KEY="TRUE">
            <Display>
             <Label NLSID="dv_violation_timestamp_nlsid">Violation Time</Label>
            </Display>
          </ColumnDescriptor>
                  
	</TableDescriptor>


		<QueryDescriptor FETCHLET_ID="OSLineToken" >
			<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
			<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
			<Property NAME="command" SCOPE="GLOBAL">
			%perlBin%/perl %scriptsDir%/dv/commandruleviolations.pl
			</Property>
			<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
			<Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
			<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property>
			<Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
			<Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))
			</Property>
      <Property NAME="ENVEM_AGENT_STATE_DIR" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
      <Property NAME="ENVEM_TARGET_GUID" SCOPE="INSTANCE">GUID</Property>
			
		</QueryDescriptor>

        
</Metric>

<Metric NAME="DatabaseVaultRealmConfigurationIssue" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">
	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	</ValidIf>
	
    <Display>
            <Label NLSID="dv_realm_configuration_issue_nlsid">Database Vault Configuration Issues - Realms</Label>
    </Display>


	<TableDescriptor >

        <ColumnDescriptor NAME="ACTION_OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" >
	        <Display>
	                <Label NLSID="dv_realm_nlsid">Database Vault Realm </Label>
	        </Display>
        </ColumnDescriptor>
	
        <ColumnDescriptor NAME="ACTION_OBJECT_COUNT" TYPE="NUMBER" >
	        <Display>
	                <Label NLSID="dv_realm_configuration_issues_nlsid">Database Vault Configuration Issues Count - Realms</Label>
	        </Display>
        </ColumnDescriptor>
        
	</TableDescriptor>

        <QueryDescriptor FETCHLET_ID="OSLineToken" > 
              <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property> 
              <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property> 
              <Property NAME="command" SCOPE="GLOBAL"> 
              %perlBin%/perl %scriptsDir%/dv/realmconfissue.pl 
              </Property> 
              <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property> 
              <Property NAME="delimiter" SCOPE="GLOBAL">|</Property> 
              <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property> 
              <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property> 
              <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property> 
              <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property> 
              <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
              <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property> 
              <Property NAME="Port" SCOPE="INSTANCE">Port</Property> 
              <Property NAME="SID" SCOPE="INSTANCE">SID</Property> 
              <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%))) 
                  </Property> 
                         
        </QueryDescriptor>
</Metric>

<Metric NAME="DatabaseVaultCommandRuleConfigurationIssue" TYPE="TABLE" USAGE_TYPE="VIEW_COLLECT"  IS_METRIC_LONG_RUNNING="FALSE">
	<ValidIf>
		<CategoryProp NAME="VersionCategory" CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	</ValidIf>
	
    <Display>
            <Label NLSID="dv_command_rule_configuration_issue_nlsid">Database Vault Configuration Issues - Command Rules
            </Label>
    </Display>


	<TableDescriptor >

        <ColumnDescriptor NAME="ACTION_OBJECT_NAME" TYPE="STRING" IS_KEY="TRUE" >
	        <Display>
	                <Label NLSID="dv_command_rule_nlsid">Database Vault Command Rule </Label>
	        </Display>
        </ColumnDescriptor>
	
        <ColumnDescriptor NAME="ACTION_OBJECT_COUNT" TYPE="NUMBER">
	        <Display>
	                <Label NLSID="dv_command_rule_configuration_issues_nlsid">DV(Command Rule) - Configuration Issue Count </Label>
	        </Display>
        </ColumnDescriptor>
        
	</TableDescriptor>

        <QueryDescriptor FETCHLET_ID="OSLineToken" > 
              <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property> 
              <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property> 
              <Property NAME="command" SCOPE="GLOBAL"> 
              %perlBin%/perl %scriptsDir%/dv/commandruleconfissue.pl 
              </Property> 
              <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property> 
              <Property NAME="delimiter" SCOPE="GLOBAL">|</Property> 
              <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property> 
              <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property> 
              <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property> 
              <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property> 
              <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
              <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property> 
              <Property NAME="Port" SCOPE="INSTANCE">Port</Property> 
              <Property NAME="SID" SCOPE="INSTANCE">SID</Property> 
              <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%))) 
                  </Property> 
                         
        </QueryDescriptor>
 
</Metric> 


<Metric NAME="DatabaseVaultPolicyChanges" 
		TYPE="TABLE" 
		USAGE_TYPE="VIEW_COLLECT"  
		IS_METRIC_LONG_RUNNING="FALSE">
	<ValidIf>
		<CategoryProp NAME="VersionCategory" 
			CHOICES="9iR2;10gR1;10gR2;10gR203;11gR1;11gR2" />
	</ValidIf>
	
    <Display>
            <Label NLSID="dv_policy_changes_nlsid">Database Vault Policy Changes
            </Label>
    </Display>


	<TableDescriptor >

        <ColumnDescriptor NAME="POLICY_CATEGORY_NAME" TYPE="STRING" IS_KEY="TRUE" >
	        <Display>
	                <Label NLSID="dv_policy_category_name_nlsid">DV Policy Change Category</Label>
	        </Display>
        </ColumnDescriptor>

        <ColumnDescriptor NAME="POLICY_CHANGE_TIMESTAMP" TYPE="STRING" IS_KEY="TRUE">
            <Display>
             <Label NLSID="dv_policy_change_timestamp_nlsid">DV Policy Change Time</Label>
            </Display>
        </ColumnDescriptor>

         <ColumnDescriptor NAME="DIFF_IN_POLICY_CHNAGES_COUNT" TYPE="NUMBER" 
			   IS_KEY="FALSE" 
			   STATELESS_ALERTS="TRUE">
               <Display>
                         <Label NLSID="diff_in_policy_changes_count_nlsid">Database Vault Policy Changes Count</Label>
               </Display> 
         </ColumnDescriptor>

        
	</TableDescriptor>

        <QueryDescriptor FETCHLET_ID="OSLineToken" > 
              <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property> 
              <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property> 
              <Property NAME="command" SCOPE="GLOBAL"> 
              %perlBin%/perl %scriptsDir%/dv/policychanges.pl 
              </Property> 
              <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property> 
              <Property NAME="delimiter" SCOPE="GLOBAL">|</Property> 
              <Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE">NAME</Property> 
              <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property> 
              <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property> 
              <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property> 
              <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property> 
              <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property> 
              <Property NAME="Port" SCOPE="INSTANCE">Port</Property> 
              <Property NAME="SID" SCOPE="INSTANCE">SID</Property> 
              <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%))) 
                  </Property> 
                         
      <Property NAME="ENVEM_AGENT_STATE_DIR" SCOPE="SYSTEMGLOBAL">agentStateDir</Property>
      <Property NAME="ENVEM_TARGET_GUID" SCOPE="INSTANCE">GUID</Property>

        </QueryDescriptor> 
	
</Metric> 

      <!--
        ======================================================================
        == Category              :  Key SQL Profiles
        == Collection Level      :  Minimum
        == Purpose               :  Reporting
        ======================================================================
        -->

        <Metric NAME="key_profiles" TYPE="TABLE" >
                <ValidIf>
                        <CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
                        <CategoryProp NAME="MetricScope" CHOICES="DB"/>
                </ValidIf>
                <Display>
                        <Label NLSID="key_profiles">Key Profiles</Label>
                </Display>
                <TableDescriptor>
                        <ColumnDescriptor NAME="key_profiles_count" TYPE="NUMBER" >
                                <Display>
                                        <Label NLSID="key_profiles_count">key_profiles_count</Label>
                                </Display>
                        </ColumnDescriptor>
                        <ColumnDescriptor NAME="key_profiles_enable" TYPE="STRING" >
                                <Display>
                                        <Label NLSID="key_profiles_enable">key_profiles_enable</Label>
                                </Display>
                        </ColumnDescriptor>
                        <ColumnDescriptor NAME="auto_impl_enable" TYPE="STRING" >
                                <Display>
                                        <Label NLSID="auto_impl_enable">auto_impl_enable</Label>
                                </Display>
                        </ColumnDescriptor>
                </TableDescriptor>
                <QueryDescriptor FETCHLET_ID="SQL">
                        <Property NAME="STATEMENT" SCOPE="GLOBAL">
                        <![CDATA[

                        DECLARE
                           rept          varchar2(4000);
                           rref          varchar2(4000);
                           key_enable    varchar2(20);
                           autoimpl_enable    varchar2(20);
                           key_count     number;

                           TYPE        data_cursor_type IS REF CURSOR;
                           data_cursor data_cursor_type;

                           BEGIN

                              rref := dbms_report.build_report_reference_varg(
                                      'sqltune', 'auto_summary',
                                      'section', 'task_stats',
                                      'validate', 'n');

                              rept := dbms_report.get_report(rref);

                              WITH data AS (select xmltype(rept) rept_xml FROM dual)
                              SELECT extractvalue(rept_xml,'/report/summary/statistics/task_stats/info_group/info[position()=1]'),
                                     extractvalue(rept_xml,'/report/summary/statistics/task_stats/info_group/info[position()=2]') 
                              INTO key_enable,autoimpl_enable FROM data;
                              
                              
                              SELECT count(*) INTO key_count FROM table(xmlsequence(xmltype(rept).extract('//obj_id')));

                              OPEN data_cursor FOR
                              SELECT key_count, key_enable,autoimpl_enable  FROM dual; 
                              :1 := data_cursor;
                           END;

      
                        ]]></Property>
                        <Property NAME="SQLOUTPARAMPOS" SCOPE="GLOBAL">1</Property>
                        <Property NAME="SQLOUTPARAMTYPE" SCOPE="GLOBAL">SQL_CURSOR</Property>
                        <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
                        <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
                        <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
                        <Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
                        <Property NAME="password" SCOPE="INSTANCE">password</Property>
                        <Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
                </QueryDescriptor>
        </Metric>


  <!--
  ======================================================================
  == Category:         Database Replay Status
  == Collection Level: Recommended
  == Purpose:          Alerts
  ======================================================================
  -->
	<Metric NAME="WCR" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="wcr">Database Replay</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="wcr_capture_status" TYPE="STRING" NON_THRESHOLDED_ALERTS="TRUE" IS_KEY="FALSE">
                <Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="wcr_capture_status">Workload Capture Status</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="wcr_replay_status" TYPE="STRING" NON_THRESHOLDED_ALERTS="TRUE" IS_KEY="FALSE">
                <Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="wcr_replay_status">Workload Replay Status</Label>
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
		</PushDescriptor>
	</Metric>

  <!--
  ======================================================================
  == Category:         Database Replay Client
  == Collection Level: Recommended
  == Purpose:          Alerts
  ======================================================================
  -->
	<Metric NAME="wrc_client" TYPE="TABLE">
		<ValidIf>
			<CategoryProp NAME="VersionCategory" CHOICES="11gR2"/>
			<CategoryProp NAME="MetricScope" CHOICES="DB"/>
		</ValidIf>
		<Display>
			<Label NLSID="wrc_client">Database Replay Client</Label>
		</Display>
		<TableDescriptor>
			<ColumnDescriptor NAME="id" TYPE="STRING" IS_KEY="TRUE">
                <Display>
					<Label NLSID="wrc_client_id">Database Replay Client ID</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="avg_io_lat" TYPE="NUMBER" NON_THRESHOLDED_ALERTS="TRUE" IS_KEY="FALSE">
                <Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="wrc_client_avg_io_lat">Average I/O Latency (milliseconds)</Label>
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="p_cpu" TYPE="NUMBER" NON_THRESHOLDED_ALERTS="TRUE" IS_KEY="FALSE">
                <Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="wrc_client_p_cpu">Replay Threads (%) Using CPU</Label>
                    <Unit NLSID="em__sys__standard_percent">%</Unit> 
				</Display>
			</ColumnDescriptor>
			<ColumnDescriptor NAME="p_io" TYPE="NUMBER" NON_THRESHOLDED_ALERTS="TRUE" IS_KEY="FALSE">
                <Display FOR_SUMMARY_UI="TRUE">
					<Label NLSID="wrc_client_p_io">Replay Threads (%) Performing I/O</Label>
                    <Unit NLSID="em__sys__standard_percent">%</Unit> 
				</Display>
			</ColumnDescriptor>
		</TableDescriptor>
		<QueryDescriptor FETCHLET_ID="SQL">
			<Property NAME="STATEMENT" SCOPE="GLOBAL">
                <![CDATA[
                SELECT TO_CHAR(m.entity_id, 'FM999999999') AS id,
                       SUM(CASE WHEN a.internal_metric_name = 'avg_io_lat'
                                THEN m.value ELSE 0 END) AS avg_io_lat,
                       SUM(CASE WHEN a.internal_metric_name = 'p_cpu'
                                THEN m.value ELSE 0 END) AS p_cpu,
                       SUM(CASE WHEN a.internal_metric_name = 'p_io'
                                THEN m.value ELSE 0 END) AS p_io
                  FROM gv$alert_types a, gv$threshold_types t, gv$metric m
                 WHERE a.internal_metric_category = 'wrc_client'
                   AND a.reason_id = t.alert_reason_id
                   AND t.metrics_id = m.metric_id
              GROUP BY m.entity_id
                ]]>
            </Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
		</QueryDescriptor>
		<PushDescriptor RECVLET_ID="AQMetrics">
			<Property NAME="QueueName" SCOPE="GLOBAL">ALERT_QUE</Property>
			<Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
			<Property NAME="Port" SCOPE="INSTANCE">Port</Property>
			<Property NAME="SID" SCOPE="INSTANCE">SID</Property>
			<Property NAME="UserName" SCOPE="INSTANCE">UserName</Property>
			<Property NAME="password" SCOPE="INSTANCE">password</Property>
			<Property NAME="Role" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
			<Property NAME="InstanceName" SCOPE="INSTANCE">InstanceName</Property>
			<Property NAME="KeyField" SCOPE="GLOBAL">OBJECT_NAME</Property>
			<Property NAME="KeyColumn" SCOPE="GLOBAL">id</Property>
		</PushDescriptor>
	</Metric>

    <!--
      ======================================================================
      == Metric: cluster_resource_name
      ======================================================================
      -->

  <Metric NAME="cluster_resource_name" TYPE="TABLE" IS_METRIC_LONG_RUNNING="TRUE" USAGE_TYPE="COLLECT_UPLOAD">
    <Display>
      <Label NLSID="cluster_resource_name">Cluster Resource</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="resource_name" TYPE="STRING" IS_KEY="FALSE" >
        <Display>
          <Label NLSID="resource_name">Resource Name</Label>
        </Display>
      </ColumnDescriptor>
    </TableDescriptor>
      <QueryDescriptor FETCHLET_ID="OSLineToken" >
        <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
        <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
        <Property NAME="command" SCOPE="GLOBAL"><![CDATA[
%perlBin%/perl %scriptsDir%/has/has_metrics.pl resource_name %OracleHome% database %SID%
]]></Property>  
        <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
        <Property NAME="warningStartsWith" SCOPE="GLOBAL">em_warning=</Property>
        <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
        <Property NAME="ENVEM_CRS_HOME" SCOPE="INSTANCE" OPTIONAL="TRUE">OracleHome</Property>
        <Property NAME="OracleHome" SCOPE="INSTANCE" OPTIONAL="TRUE">OracleHome</Property>
        <Property NAME="SID" SCOPE="INSTANCE">SID</Property>

        <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
        <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>
        <Property NAME="ENVEM_PERLBIN_DIR" SCOPE="SYSTEMGLOBAL">perlBin</Property>
        <Property NAME="ENVEM_SCRIPTS_DIR" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
        <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
        <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
        <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
        <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
        <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
      </QueryDescriptor> 
  </Metric>


    <!--
      ======================================================================
      == Metric: isHasManaged
      ======================================================================
      -->

  <Metric NAME="isHasManaged" TYPE="TABLE" IS_METRIC_LONG_RUNNING="TRUE" USAGE_TYPE="COLLECT_UPLOAD">
    <Display>
      <Label NLSID="isHasManaged">DB Managed by Single Instance HA</Label>
    </Display>
    <TableDescriptor>
      <ColumnDescriptor NAME="isHasManaged" TYPE="STRING" IS_KEY="FALSE" >
        <Display>
          <Label NLSID="isHasManaged">DB Managed by Single Instance HA</Label>
        </Display>
      </ColumnDescriptor>
      <ColumnDescriptor NAME="crsHome" TYPE="STRING" IS_KEY="FALSE" >
        <Display>
          <Label NLSID="crsHome">CRS Home Directory</Label>
        </Display>
      </ColumnDescriptor>
    </TableDescriptor>
      <QueryDescriptor FETCHLET_ID="OSLineToken" >
        <Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
        <Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
        <Property NAME="command" SCOPE="GLOBAL"><![CDATA[
%perlBin%/perl %scriptsDir%//has/has_metrics.pl db_has_managed %OracleHome% database %SID% %VersionCategory%
]]></Property>
        <Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
        <Property NAME="warningStartsWith" SCOPE="GLOBAL">em_warning=</Property>
        <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>
        <Property NAME="ENVEM_CRS_HOME" SCOPE="INSTANCE" OPTIONAL="TRUE">OracleHome</Property>
        <Property NAME="OracleHome" SCOPE="INSTANCE" OPTIONAL="TRUE">OracleHome</Property>
        <Property NAME="ENVEM_VERSION_CATEGORY" SCOPE="INSTANCE" OPTIONAL="TRUE">VersionCategory</Property>
        <Property NAME="VersionCategory" SCOPE="INSTANCE" OPTIONAL="TRUE">VersionCategory</Property>
        <Property NAME="SID" SCOPE="INSTANCE">SID</Property>
        <Property NAME="ENVEM_ORACLE_SID" SCOPE="INSTANCE">SID</Property>

        <Property NAME="STDINEM_TARGET_USERNAME" SCOPE="INSTANCE">UserName</Property>
        <Property NAME="STDINEM_TARGET_PASSWORD" SCOPE="INSTANCE">password</Property>

        <Property NAME="ENVEM_PERLBIN_DIR" SCOPE="SYSTEMGLOBAL">perlBin</Property>
        <Property NAME="ENVEM_SCRIPTS_DIR" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>

        <Property NAME="ENVEM_TARGET_ORACLE_HOME" SCOPE="INSTANCE">OracleHome</Property>
        <Property NAME="ENVEM_TARGET_ROLE" SCOPE="INSTANCE" OPTIONAL="TRUE">Role</Property>
        <Property NAME="MachineName" SCOPE="INSTANCE">MachineName</Property>
        <Property NAME="Port" SCOPE="INSTANCE">Port</Property>
        <Property NAME="ENVEM_TARGET_ADDRESS" SCOPE="GLOBAL">(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=%MachineName%)(Port=%Port%))(CONNECT_DATA=(SID=%SID%)))</Property>
      </QueryDescriptor>
  </Metric>

