oid_users_count.sql 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. REM Script version: 19.1
  2. REM The following privileges are needed to run this script:
  3. REM grant create session
  4. REM grant select on sys.v_$instance
  5. REM grant select on sys.dba_users
  6. REM grant select on sys.dba_tables
  7. REM grant select on sys.v_$version
  8. REM grant select on <<oid schema>>.ods_process --ver 10g
  9. REM grant select on <<oid schema>>.ods_process_status --ver 11g
  10. REM grant select on <<oid schema>>.ds_attrstore
  11. REM grant select on <<oid schema>>.ct_objectclass
  12. REM grant select on <<oid schema>>.ct_tombstone
  13. -- PREPARE AND DISPLAY LICENSE AGREEMENT
  14. SET TERMOUT OFF
  15. SET ECHO OFF
  16. SPOOL license_agreement.txt
  17. PROMPT ===============================================================
  18. PROMPT For reading LICENSE AGREEMENT use:
  19. PROMPT <SPACE> to display next page
  20. PROMPT <RETURN> to display next line
  21. PROMPT ===============================================================
  22. PROMPT
  23. PROMPT Terms for Oracle Software Collection Tool
  24. PROMPT
  25. PROMPT
  26. PROMPT By selecting "Accept License Agreement" (or the equivalent) or by installing or using the Software (as defined below), You indicate Your acceptance of these terms and Your agreement, as an authorized representative of Your company or organization (if being acquired for use by an entity) or as an individual, to comply with the license terms that apply to the Software. If you are not willing to be bound by these terms, do not indicate Your acceptance and do not download, install, or use the Software.
  27. PROMPT
  28. PROMPT
  29. PROMPT License Agreement
  30. PROMPT
  31. PROMPT PLEASE SCROLL DOWN AND READ ALL OF THE FOLLOWING TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT (this "Agreement") CAREFULLY. THIS AGREEMENT IS A LEGALLY BINDING CONTRACT BETWEEN YOU AND ORACLE AMERICA, INC. THAT SETS FORTH THE TERMS THAT GOVERN YOUR USE OF THE SOFTWARE.
  32. PROMPT
  33. PROMPT YOU MUST ACCEPT AND ABIDE BY THESE TERMS AS PRESENTED TO YOU - ANY CHANGES, ADDITIONS OR DELETIONS BY YOU TO THESE TERMS ARE NOT ACCEPTED AND WILL NOT BE PART OF THIS AGREEMENT.
  34. PROMPT
  35. PROMPT Definitions
  36. PROMPT "Oracle" refers to Oracle America, Inc.
  37. PROMPT
  38. PROMPT "You" and "Your" refers to the individual or entity that wishes to use the Software.
  39. PROMPT
  40. PROMPT "Software" refers to the tool(s), script(s) and/or software product(s) (and any applicable documentation) provided with these terms to You by Oracle and which You wish to access and use to measure, monitor and/or manage Your usage of separately-licensed Oracle software (the "Programs") that has been licensed under a separate agreement between Oracle and You, such as an Oracle Master Agreement, an Oracle Software License and Services Agreement, an Oracle PartnerNetwork Agreement or an Oracle distribution agreement (each, an "Oracle License Agreement").
  41. PROMPT
  42. PROMPT Rights Granted
  43. PROMPT Oracle grants You a non-exclusive, non-transferable limited right to use the Software, subject to the terms of this Agreement, for the limited purpose of measuring, monitoring and/or managing Your usage of the Programs. You may allow Your agents and contractors (including, without limitation, outsourcers) to use the Software for this purpose and You are responsible for their compliance with this Agreement in such use. You (including Your agents, contractors and/or outsourcers) may not use the Software for any other purpose.
  44. PROMPT
  45. PROMPT Ownership and Restrictions
  46. PROMPT Oracle and Oracle's licensors retain all ownership and intellectual property rights to the Software. The Software may be installed on one or more servers; provided, however, that You may only make one copy of the Software for backup or archival purposes.
  47. PROMPT
  48. PROMPT Third party technology that may be appropriate or necessary for use with the Software is specified in the Software documentation, notice files or readme files. Such third party technology is licensed to You under the terms of the third party technology license agreement specified in the Software documentation, notice files or readme files and not under the terms of this Agreement.
  49. PROMPT
  50. PROMPT You may not:
  51. PROMPT - use the Software for Your own internal data processing or for any commercial or production purposes, or use the Software for any purpose except the purpose stated herein;
  52. PROMPT - remove or modify any Software markings or any notice of Oracle's or Oracle's licensors' proprietary rights;
  53. PROMPT - make the Software available in any manner to any third party for use in the third party's business operations, without Oracle's prior written consent;
  54. PROMPT - use the Software to provide third party training or rent or lease the Software or use the Software for commercial time sharing or service bureau use;
  55. PROMPT - assign this Agreement or give or transfer the Software or an interest in them to another individual or entity;
  56. PROMPT - cause or permit reverse engineering (unless required by law for interoperability), disassembly or decompilation of the Software (the foregoing prohibition includes but is not limited to review of data structures or similar materials produced by the Software);
  57. PROMPT - disclose results of any Software benchmark tests without Oracle's prior written consent;
  58. PROMPT - use any Oracle name, trademark or logo without Oracle's prior written consent.
  59. PROMPT
  60. PROMPT Disclaimer of Warranty
  61. PROMPT ORACLE DOES NOT GUARANTEE THAT THE SOFTWARE WILL PERFORM ERROR-FREE OR UNINTERRUPTED. TO THE EXTENT NOT PROHIBITED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND THERE ARE NO WARRANTIES, EXPRESS OR IMPLIED, OR CONDITIONS, INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, NONINFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE, THAT APPLY TO THE SOFTWARE.
  62. PROMPT
  63. PROMPT No Right to Technical Support
  64. PROMPT You acknowledge and agree that Oracle's technical support organization will not provide You with technical support for the Software licensed under this Agreement.
  65. PROMPT
  66. PROMPT End of Agreement
  67. PROMPT You may terminate this Agreement by destroying all copies of the Software. Oracle has the right to terminate Your right to use the Software at any time upon notice to You, in which case You shall destroy all copies of the Software.
  68. PROMPT
  69. PROMPT Entire Agreement
  70. PROMPT You agree that this Agreement is the complete agreement for the Software and supersedes all prior or contemporaneous agreements or representations, written or oral, regarding the Software. If any term of this Agreement is found to be invalid or unenforceable, the remaining provisions will remain effective and such term shall be replaced with a term consistent with the purpose and intent of this Agreement.
  71. PROMPT
  72. PROMPT Limitation of Liability
  73. PROMPT IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR ANY LOSS OF PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD PARTY. ORACLE'S ENTIRE LIABILITY FOR DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT, WHETHER IN CONTRACT OR TORT OR OTHERWISE, SHALL IN NO EVENT EXCEED THE GREATER OF ONE THOUSAND U.S. DOLLARS (U.S. $1,000) OR THE LICENSE FEES THAT YOU HAVE PAID TO ORACLE FOR PROGRAMS PURSUANT TO AN ORACLE LICENSE AGREEMENT.
  74. PROMPT
  75. PROMPT Export
  76. PROMPT Export laws and regulations of the United States and any other relevant local export laws and regulations apply to the Software. You agree that such export control laws govern Your use of the Software (including technical data) provided under this Agreement, and You agree to comply with all such export laws and regulations (including "deemed export" and "deemed re-export" regulations). You agree that no data, information, and/or Software (or direct product thereof) will be exported, directly or indirectly, in violation of any export laws, nor will they be used for any purpose prohibited by these laws including, without limitation, nuclear, chemical, or biological weapons proliferation, or development of missile technology.
  77. PROMPT
  78. PROMPT Other
  79. PROMPT 1. This Agreement is governed by the substantive and procedural laws of the State of California, USA. You and Oracle agree to submit to the exclusive jurisdiction of, and venue in, the courts of San Francisco or Santa Clara counties in California in any dispute arising out of or relating to this Agreement.
  80. PROMPT
  81. PROMPT 2. You may not assign this Agreement or give or transfer the Software or an interest in them to another individual or entity. If You grant a security interest in the Software, the secured party has no right to use or transfer the Software.
  82. PROMPT
  83. PROMPT 3. Except for actions for breach of Oracle's proprietary rights, no action, regardless of form, arising out of or relating to this Agreement may be brought by either party more than two years after the cause of action has accrued.
  84. PROMPT
  85. PROMPT 4. The relationship between You and Oracle is that of licensee/licensor. Nothing in this Agreement shall be construed to create a partnership, joint venture, agency, or employment relationship between the parties. The parties agree that they are acting solely as independent contractors hereunder and agree that the parties have no fiduciary duty to one another or any other special or implied duties that are not expressly stated herein. Neither party has any authority to act as agent for, or to incur any obligations on behalf of or in the name of the other.
  86. PROMPT
  87. PROMPT 5. This Agreement may not be modified and the rights and restrictions may not be altered or waived except in a writing signed by authorized representatives of You and Oracle.
  88. PROMPT
  89. PROMPT 6. Any notice required under this Agreement shall be provided to the other party in writing.
  90. PROMPT
  91. PROMPT 7. In order to assist You with the measurement, monitoring or management of Your usage of the Programs, Oracle may have access to and collect Your information, which may include personal information, and data residing on Oracle, customer or third-party systems on which the Software is used and/or to which Oracle is provided access to perform any associated services. Oracle treats such information and data in accordance with the terms of the Oracle Services Privacy Policy and the Oracle Corporate Security Practices, which are available at http://www.oracle.com/contracts, and treats such data as confidential in accordance with the terms of the Oracle License Agreement applicable to the Programs. The Oracle Services Privacy Policy and the Oracle Corporate Security Practices are subject to change at Oracle's discretion; however, Oracle will not materially reduce the level of protection specified in the Oracle Services Privacy Policy or the Oracle Corporate Security Practices in effect at the time the information was collected during the period that Oracle retains such information.
  92. PROMPT
  93. PROMPT Contact Information
  94. PROMPT Should You have any questions concerning Your use of the Software or this Agreement, please contact Oracle at: http://www.oracle.com/corporate/contact/
  95. PROMPT
  96. PROMPT Oracle America, Inc.
  97. PROMPT 500 Oracle Parkway,
  98. PROMPT Redwood City, CA 94065
  99. PROMPT
  100. PROMPT Last updated 1 November 2018
  101. PROMPT
  102. PROMPT ===============================================================
  103. SPOOL OFF
  104. HOST more license_agreement.txt
  105. HOST rm license_agreement.txt
  106. HOST del license_agreement.txt
  107. -- PROMT FOR LICENSE AGREEMENT ACCEPTANCE
  108. DEFINE LANSWER=N
  109. SET TERMOUT ON
  110. ACCEPT LANSWER FORMAT A1 PROMPT 'Accept License Agreement? (y\n): '
  111. SET TERMOUT OFF
  112. WHENEVER SQLERROR EXIT
  113. select 1/decode('&LANSWER', 'Y', null, 'y', null, decode('', null, 0, null)) as " " from dual;
  114. PROMPT
  115. -- PROMT FOR BASE_DN
  116. SET TERMOUT ON
  117. ACCEPT BDN_ANSWER PROMPT 'Enter BASE_DN: '
  118. SET TERMOUT OFF
  119. WHENEVER SQLERROR CONTINUE
  120. SET TERMOUT ON
  121. SET FEEDBACK ON
  122. SET LINESIZE 160
  123. SET SERVEROUTPUT ON SIZE 1000000
  124. SET SERVEROUTPUT ON SIZE UNLIMITED
  125. SET VERIFY OFF
  126. column host_name new_value v_h_name
  127. column instance_name new_value v_i_name
  128. select host_name, instance_name from sys.v_$instance;
  129. SPOOL results-oid-users-count-&v_h_name-&v_i_name..txt;
  130. PROMPT =================================================================================
  131. PROMPT Script Name=oid_users_count_v18_1.sql
  132. PROMPT =================================================================================
  133. PROMPT
  134. select host_name, instance_name from sys.v_$instance;
  135. SELECT banner FROM sys.v_$version WHERE banner like 'Oracle%';
  136. select USERNAME, ACCOUNT_STATUS, LOCK_DATE, EXPIRY_DATE, CREATED from SYS.DBA_USERS where username='ODS';
  137. -- Querying table ODS_PROCESS or ODS_PROCESS_SYSTEM
  138. DECLARE
  139. N_ODS_PROCESS NUMBER;
  140. N_ODS_PROCESS_STATUS NUMBER;
  141. BEGIN
  142. SYS.DBMS_OUTPUT.PUT_LINE('Querying table ODS_PROCESS (for version 10g) ...');
  143. SELECT COUNT(*) INTO N_ODS_PROCESS FROM SYS.DBA_TABLES WHERE OWNER = 'ODS' AND TABLE_NAME = 'ODS_PROCESS';
  144. IF (N_ODS_PROCESS > 0) THEN
  145. DECLARE
  146. ODS_PROC_CURSOR NUMBER := SYS.DBMS_SQL.OPEN_CURSOR;
  147. L_HOSTNAME VARCHAR2(255);
  148. L_RESULTS NUMBER;
  149. BEGIN
  150. SYS.DBMS_SQL.PARSE(ODS_PROC_CURSOR,'SELECT DISTINCT HOSTNAME FROM ODS.ODS_PROCESS',SYS.DBMS_SQL.NATIVE);
  151. SYS.DBMS_SQL.DEFINE_COLUMN(ODS_PROC_CURSOR, 1, L_HOSTNAME, 255);
  152. L_RESULTS := SYS.DBMS_SQL.EXECUTE(ODS_PROC_CURSOR);
  153. SYS.DBMS_OUTPUT.PUT_LINE('HOSTNAME');
  154. SYS.DBMS_OUTPUT.PUT_LINE('-----------------------------');
  155. LOOP
  156. IF SYS.DBMS_SQL.FETCH_ROWS(ODS_PROC_CURSOR) > 0 THEN
  157. SYS.DBMS_SQL.COLUMN_VALUE(ODS_PROC_CURSOR, 1, L_HOSTNAME);
  158. SYS.DBMS_OUTPUT.PUT_LINE(L_HOSTNAME);
  159. ELSE
  160. EXIT;
  161. END IF;
  162. END LOOP;
  163. SYS.DBMS_SQL.CLOSE_CURSOR(ODS_PROC_CURSOR);
  164. SYS.DBMS_OUTPUT.PUT_LINE(CHR(10));
  165. END;
  166. ELSE
  167. SYS.DBMS_OUTPUT.PUT_LINE('--- Table ODS_PROCESS not found.');
  168. SYS.DBMS_OUTPUT.PUT_LINE(CHR(10));
  169. END IF;
  170. SYS.DBMS_OUTPUT.PUT_LINE('Querying table ODS_PROCESS_STATUS (for version 11g) ...');
  171. SELECT COUNT(*) INTO N_ODS_PROCESS_STATUS FROM SYS.DBA_TABLES WHERE OWNER = 'ODS' AND TABLE_NAME = 'ODS_PROCESS_STATUS';
  172. IF (N_ODS_PROCESS_STATUS > 0) THEN
  173. DECLARE
  174. ODS_PROC_ST_CURSOR NUMBER := SYS.DBMS_SQL.OPEN_CURSOR;
  175. L_HOSTNAME VARCHAR2(255);
  176. L_RESULTS NUMBER;
  177. BEGIN
  178. SYS.DBMS_SQL.PARSE(ODS_PROC_ST_CURSOR,'SELECT DISTINCT HOSTNAME FROM ODS.ODS_PROCESS_STATUS', SYS.DBMS_SQL.NATIVE);
  179. SYS.DBMS_SQL.DEFINE_COLUMN(ODS_PROC_ST_CURSOR, 1, L_HOSTNAME, 255);
  180. L_RESULTS := SYS.DBMS_SQL.EXECUTE(ODS_PROC_ST_CURSOR);
  181. SYS.DBMS_OUTPUT.PUT_LINE('HOSTNAME');
  182. SYS.DBMS_OUTPUT.PUT_LINE('-----------------------------');
  183. LOOP
  184. IF SYS.DBMS_SQL.FETCH_ROWS(ODS_PROC_ST_CURSOR) > 0 THEN
  185. SYS.DBMS_SQL.COLUMN_VALUE(ODS_PROC_ST_CURSOR, 1, L_HOSTNAME);
  186. SYS.DBMS_OUTPUT.PUT_LINE(L_HOSTNAME);
  187. ELSE
  188. EXIT;
  189. END IF;
  190. END LOOP;
  191. SYS.DBMS_SQL.CLOSE_CURSOR(ODS_PROC_ST_CURSOR);
  192. SYS.DBMS_OUTPUT.PUT_LINE(CHR(10));
  193. END;
  194. ELSE
  195. SYS.DBMS_OUTPUT.PUT_LINE('--- Table ODS_PROCESS_STATUS not found.');
  196. SYS.DBMS_OUTPUT.PUT_LINE(CHR(10));
  197. END IF;
  198. END;
  199. /
  200. PROMPT =================================================================================
  201. PROMPT
  202. PROMPT Number of records from ODS.DS_ATTRSTORE joined with ODS.CT_OBJECTCLASS for BASE_DN: &BDN_ANSWER
  203. SELECT COUNT(*) FROM ODS.DS_ATTRSTORE STORE, ODS.CT_OBJECTCLASS OBJ WHERE STORE.ATTRNAME = 'orclentrydn' AND OBJ.ATTRVALUE = 'inetorgperson' AND STORE.ENTRYID = OBJ.ENTRYID AND REPLACE(LOWER(STORE.ATTRVAL),' ') LIKE REPLACE(LOWER('%&BDN_ANSWER'),' ');
  204. PROMPT =================================================================================
  205. PROMPT
  206. PROMPT Number of records from ODS.DS_ATTRSTORE joined with ODS.CT_OBJECTCLASS
  207. SELECT COUNT(*) FROM ODS.DS_ATTRSTORE STORE, ODS.CT_OBJECTCLASS OBJ WHERE STORE.ATTRNAME = 'orclentrydn' AND OBJ.ATTRVALUE = 'inetorgperson' AND STORE.ENTRYID = OBJ.ENTRYID;
  208. PROMPT =================================================================================
  209. PROMPT
  210. PROMPT Number of records from ODS.CT_TOMBSTONE table:
  211. SELECT COUNT(*) FROM ODS.CT_TOMBSTONE;
  212. SPOOL OFF
  213. QUIT