monitor sys and system user(轉自http://www.oracle.com)
Tip of the Week Tip for Week of February 23, 2003 Monitor SYS and SYSTEM Accounts This tip comes from Daniel Stanley, Oracle DBA/Developer at ASIX, Inc., in Bellevue, WA. Create a procedure to monitor and log users logging onto the database with the SYS and SYSTEM accounts. Create two new SYS objects: --trigger sys$logtrig-- This logon trigger fires the procedure if you are logged on with the SYS or SYSTEM accounts. --procedure sys$logproc-- This procedure writes an ascii file to either the utl_file_dir or the c:winnt directory if the utl_file_dir is set to *. This parameter must be set in the init.ora file prior to installing and running the procedure. It moves and makes a backup every 8k. First create the sys$logproc procedure. create or replace procedure sys$logproc as /* ******************************* ** SYS/SYSTEM LOG MONITOR ***** ******************************* CREATED BY: Dan Stanley daniels@asix.com FILENAME: SYS_sys$log.src COMPANY: ASIX, Inc. DATE: 01/28/2003 OBJECTIVE: stores log of all successful SYS and SYSTEM connections to database; recycle and backup done at 8k. INPUT: SQL> exec sys$logproc OUTPUT: [v$%SID%.log] VERSION TESTING: This script was tested on Oracle EE 8.1.6 to 9.2.x and is intended to be used in SQL*Plus. MODS: 11/16/2002 drs - description. */ v_date char(30); v_user char(30); v_osuser char(40); v_term char(30); v_host char(40); v_program char(40); v_exists boolean := FALSE; v_file_len number := 0; v_blk_sz binary_integer; squote char(1) := chr(39); dquote char(2) := chr(34); comma char(1) := chr(44); v_file utl_file.file_type; v_utl_file_path varchar2(40); v_write_path varchar2(40); v_instance varchar2(16); v_file_name varchar2(40); v_old varchar2(40); v_writeappend char(1) := 'A'; begin select to_char(sysdate, 'mm-dd-yyyy HH:MI:SSam'), user, sys_context('userenv','OS_USER'), userenv('TERMINAL'), (select trim(value) from v$parameter where name = 'utl_file_dir'), (select trim(upper(instance_name)) from v$instance), (select program from v$session where sid = (select distinct sid from v$mystat)) into v_date, v_user, v_osuser, v_term, v_utl_file_path, v_instance, v_program from dual; -- NOTE: this section is for debugging purposes only if nvl(v_utl_file_path,' ') = ' ' then dbms_output.put_line('*************************************************'); dbms_output.put_line('*** ERROR: utl_file_dir parameter is not set.'); dbms_output.put_line('*************************************************'); elsif v_utl_file_path = '*' then v_write_path := 'c:winnt'; else v_write_path := v_utl_file_path; end if; -- END NOTE: v_file_name := 'v$'||v_instance||'.log'; v_old := 'v$' ||v_instance||'.old'; utl_file.fgetattr( location => v_write_path, filename => v_file_name, fexists => v_exists, file_length => v_file_len, block_size => v_blk_sz); if v_exists then if v_file_len >= 8192 then utl_file.frename( src_location => v_write_path, src_filename => v_file_name, dest_location => v_write_path, dest_filename => v_old, overwrite => true); v_writeappend := 'W'; end if; end if; v_file := utl_file.fopen(''||v_write_path||'', v_file_name, v_writeappend); utl_file.put_line(v_file, trim(v_date) || '|' || trim(v_user) || '|' || trim(v_osuser) || '|' || trim(v_term) || '|' || trim(v_program)); utl_file.fclose(v_file); end sys$logproc; / Now create the sys$logtrig trigger. CREATE OR REPLACE TRIGGER sys$logtrig AFTER LOGON ON DATABASE declare v_user char(30); begin select user into v_user from dual; if v_user = 'SYS' or v_user = 'SYSTEM' then sys$logproc; end if; end; /[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/95530/viewspace-1023332/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- http://www.oracle.com/technetworkHTTPOracle
- aix_system_monitorAI
- Oracle/PLSQL: Sys_Context Function(轉自http://www.techonthenet.com)OracleSQLContextFunctionHTTP
- System Monitor Process (SMON) (120)
- system sys,sysoper sysdba 的區別
- for public synonym, only sys user can compile it?Compile
- System.Net.HttpHTTP
- 修改sys ,system使用者密碼密碼
- sys.allocation_units與sys.system_internals_allocation_units的差別
- Rewrite %{HTTP_USER_AGENT}用法HTTP
- Oracle中sys和system的區別小結Oracle
- 自動生成大語言模型的系統指令System或使用者提示User模型
- SYS,SYSTEM,DBA,SYSDBA,SYSOPER的區別與聯絡
- Protecting Your Database: Specifying Passwords for Users SYS and SYSTEM (70)Database
- sys使用者與system使用者的區別
- 將SYS和SYSTEM的物件都KEEP到shared pool物件
- linux_系統資源監控指令碼_system_monitorLinux指令碼
- 0506-324 Cannot Mount File System (轉自網路)
- 轉:os和sys模組
- Nginx http_user_agent 防禦 ab 等NginxHTTP
- [20190423]簡單測試user和SYS_CONTEXT ('USERENV','CURRENT_USER').txtContext
- How to Clean Up Duplicate Objects Owned by SYS and SYSTEM Schema_1030426.6Object
- 轉載:System:System.arraycopy方法詳解
- 奇妙的 sys 請求(轉)
- 如何設定HTTP自動跳轉到HTTPSHTTP
- rfc1945-http1.0自譯本-(4) (轉)HTTP
- RFC2617- HTTP Authentication自譯本-(2) (轉)HTTP
- rfc1945-http1.0自譯本-(1) (轉)HTTP
- rfc1945-http1.0自譯本-(5) (轉)HTTP
- rfc1945-http1.0自譯本-(3) (轉)HTTP
- rfc1945-http1.0自譯本-(7) (轉)HTTP
- rfc1945-http1.0自譯本-(6) (轉)HTTP
- rfc1945-http1.0自譯本-(2) (轉)HTTP
- RFC2617- HTTP Authentication自譯本-(1) (轉)HTTP
- RFC2617- HTTP Authentication自譯本-(4) (轉)HTTP
- RFC2617- HTTP Authentication自譯本-(3) (轉)HTTP
- ASP.NET Core 託管和部署(二)【HTTP.sys】ASP.NETHTTP
- system自動關機函式函式