Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
hyee committed Jun 25, 2016
1 parent 18486e3 commit a659ecc
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 38 deletions.
2 changes: 1 addition & 1 deletion change log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2016-06-21: ! oracle: fix issue for 'loadtrace' in 10g
2016-06-21: ! oracle: fix error for command 'loadtrace' in 10g
2016-06-16: + oracle: new "-d" option for "ora awrstat"
+ public: new setting "set echo on/off"
! public: fix invalid cursor position when 'Ctrl+C' in Win10
Expand Down
3 changes: 3 additions & 0 deletions dbcli.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ cd /d "%~dp0"
SET JAVA_HOME=
SET CLASSPATH=
SET JAVA_TOOL_OPTIONS=
set ANSICOLOR=off
if not defined CONSOLE_COLOR SET CONSOLE_COLOR=0A
if not defined ANSICON_CMD SET ANSICON_CMD=.\lib\x64\ansicon.exe
if !ANSICOLOR!==off set ANSICON_CMD=

if not defined JRE_HOME SET JRE_HOME=d:\soft\java
if not defined TNS_ADM SET TNS_ADM=d:\Soft\InstanceClient\network\admin
SET DBCLI_ENCODING=UTF-8
Expand Down
Binary file modified lib/dbcli.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions oracle/chart/awr/sysmetric.chart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
&TITLE: V={GV$SYSMETRIC_HISTORY}, D={DBA_HIST_SYSMETRIC_SUMMARY}
&CAT : {
default={1=1},
eff={METRIC_NAME in ('CPU Usage Per Sec','CPU Usage Per Txn','Database CPU Time Ratio',
'Database Wait Time Ratio','Executions Per Sec','Executions Per Txn',
'Response Time Per Txn','SQL Service Response Time','User Transaction Per Sec')}
eff={METRIC_NAME in ('Host CPU Utilization (%)','Database CPU Time Ratio',
'Database Wait Time Ratio','Executions Per Sec',
'SQL Service Response Time','Physical Read Total IO Requests Per Sec','Physical Write Total IO Requests Per Sec')}
}
]]--
]]*/

{
_attrs=[[select 'Sysmetric History(&TITLE)' title from dual]],
_attrs=[[select 'System Metric History(&TITLE)' title from dual]],
_sql=[[
SELECT sample_time,
REPLACE(METRIC_NAME, ' Per ', ' / ') metric_name,
Expand Down
12 changes: 11 additions & 1 deletion oracle/ora/ash/ashtop.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
/*[[
Get ASH top event, type 'help @@NAME' for more info. Usage: @@NAME [-sql|-p|-none|-pr|-o|-plan|-ash|-dash|-snap|-f] {[fields] [filters]}
--[[
&fields: sql={sql_id},e={null}, p={p1,p2,p3,p3text},pr={p1raw,p2raw,p3raw}, o={obj},plan={plan_hash,current_obj#,SQL_PLAN_LINE_ID} none={1}
&fields: {
sql={sql_id},
e={null},
p={p1,p2,p3,p3text},
pr={p1raw,p2raw,p3raw},
o={obj},
plan={plan_hash,current_obj#,SQL_PLAN_LINE_ID}
none={1},
proc={sql_id,PLSQL_ENTRY_OBJECT_ID},
}
&View: ash={gv$active_session_history}, dash={Dba_Hist_Active_Sess_History}
&BASE: ash={1}, dash={10}
&Range: default={sample_time+0 between nvl(to_date(nvl(:V2,:starttime),'YYMMDDHH24MISS'),sysdate-1) and nvl(to_date(nvl(:V3,:endtime),'YYMMDDHH24MISS'),sysdate)}
Expand All @@ -22,6 +31,7 @@
-pr : group by event+p1raw,p2raw,p3raw
-o : group by event+object_id
-plan: group by sql plan line(for 11g)
-proc: group by procedure name
DataSource:
-ash : source table is gv$active_session_history(default)
-dash: source table is dba_hist_active_sess_history
Expand Down
15 changes: 11 additions & 4 deletions oracle/ora/block.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/*[[Show object info for the input block in bh. Usage: @@NAME <file#> <block#>]]*/
/*[[Show object info for the input block in bh. Usage: @@NAME <file#> <block#>
--[[
@CHECK_ACCESS_SEG: {
sys.seg$={select HWMINCR objd,file# from sys.seg$ where :V2 between block# and block#-1+blocks},
default={select objd,file# from gv$bh where block#=:V2}
}
@CHECK_ACCESS_OBJ: dba_objects={dba_objects}, default={all_objects}
--]]
]]*/

SELECT b.*
FROM gv$bh a, all_objects b
FROM (&CHECK_ACCESS_SEG) a, &CHECK_ACCESS_OBJ b
WHERE rownum < 2
AND file# = :V1
AND block# = :V2
AND objd IN (object_id, data_object_id)
AND objd = data_object_id
4 changes: 2 additions & 2 deletions oracle/snap/sesstat.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*[[Generate delta values based on gv$sesstat. Usage: @@NAME {[<sid>] [<inst_id>] [<key>]}]]*/
/*[[Generate delta values based on gv$sesstat. Usage: @@NAME {[0|<sid>] [<inst_id>] [<key>]}]]*/
{
sql=[[
SELECT A.*,VALUE DELTA FROM(
Expand Down Expand Up @@ -35,7 +35,7 @@
USING (inst_id, statistic#)
WHERE (VALUE > 0 OR :V3 IS NOT NULL)
AND (:V3 IS NULL OR lower(name) like lower('%&V3%'))
AND (:V1 IS NULL OR sid=:V1)
AND (:V1 IS NULL OR sid=decode(:V1,'0',userenv('sid'),:V1))
AND (:V2 IS NULL OR inst_id=:V2)) A
ORDER BY NAME]],
agg_cols="Delta",
Expand Down
4 changes: 2 additions & 2 deletions oracle/snap/sestime.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*[[Generate delta values based on gv$session_event,gv$sess_time_model. Usage: @@NAME {<sid> [<inst_id>] [keyword]}]]*/
/*[[Generate delta values based on gv$session_event,gv$sess_time_model. Usage: @@NAME {<0|sid> [<inst_id>] [keyword]}]]*/
{
sql=[[
SELECT /*+no_expand*/ a.*
Expand All @@ -9,7 +9,7 @@
SELECT inst_id, SID, 'Event', event,total_waits, TIME_WAITED_MICRO * 1e-6 t
FROM gv$session_event
where wait_class!='Idle' or :V3 is not null) a
WHERE (sid = :V1 or :V1 IS NULL) and (:V2 IS NULL OR inst_id=:V2) and (:V3 is null or lower(name) like '%&V3%')
WHERE (:V1 IS NULL or sid=decode(:V1,'0',userenv('sid'),:V1)) and (:V2 IS NULL OR inst_id=:V2) and (:V3 is null or lower(name) like '%&V3%')
]],
agg_cols="secs,count",
grp_cols="inst_id,sid,class#,name",
Expand Down
4 changes: 2 additions & 2 deletions oracle/sqlplus/xplan_ash.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Store current SQL*Plus environment
-- This requires at least a 10.2 SQL*Plus version to work
store set .xplan_settings replace
--store set .xplan_settings replace
set echo off verify off termout off timing off define "&" concat "." trimspool on
-- If you need to debug, uncomment the following line
-- set echo on verify on termout on
Expand Down Expand Up @@ -14231,4 +14231,4 @@ end;
/

-- Restore previous SQL*Plus environment
@.xplan_settings
--@.xplan_settings
56 changes: 35 additions & 21 deletions oracle/tracefile.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local env=env
local db,grid=env.getdb(),env.grid
local trace={}
local tracefile
function trace.get_trace(filename,mb,from_mb)
local sql=[[
DECLARE
Expand Down Expand Up @@ -95,18 +96,24 @@ function trace.get_trace(filename,mb,from_mb)
if filename=="default" or lv then
if lv then
db:internal_call("alter session set tracefile_identifier='dbcli_"..math.random(1e6).."'");
tracefile=nil
end
if db.props.db_version>'11' then
filename=db:get_value[[select value from v$diag_info where name='Default Trace File']]
if not tracefile then
if db.props.db_version>'11' then
filename=db:get_value[[select value from v$diag_info where name='Default Trace File']]
else
filename=db:get_value[[SELECT u_dump.value || '/' || SYS_CONTEXT('userenv','instance_name') || '_ora_' || p.spid ||
nvl2(p.traceid, '_' || p.traceid, NULL) || '.trc' "Trace File"
FROM v$parameter u_dump
CROSS JOIN v$process p
JOIN v$session s
ON p.addr = s.paddr
WHERE u_dump.name = 'user_dump_dest'
AND s.audsid = sys_context('userenv', 'sessionid')]]
end
tracefile=filename
else
filename=db:get_value[[SELECT u_dump.value || '/' || SYS_CONTEXT('userenv','instance_name') || '_ora_' || p.spid ||
nvl2(p.traceid, '_' || p.traceid, NULL) || '.trc' "Trace File"
FROM v$parameter u_dump
CROSS JOIN v$process p
JOIN v$session s
ON p.addr = s.paddr
WHERE u_dump.name = 'user_dump_dest'
AND s.audsid = sys_context('userenv', 'sessionid')]]
filename,tracefile=tracefile,nil
end
if lv then
if lv > 0 then
Expand All @@ -133,16 +140,23 @@ function trace.get_trace(filename,mb,from_mb)
print("Result written to file "..env.write_cache(args[2],args[3]))
end

env.set_command(nil,{"loadtrace","dumptrace"},[[
Download Oracle trace file into local directory. Usage: @@NAME {<trace_file|default|alert|0/1/4/8/12> [MB] [begin_MB]}
This command requires the "create directory" privilige.
Parameters:
trace_file: 1) The absolute path of the target trace file, or
2) "default" to extract current session's trace, or
4) 0/1/4/8/12 to enable 10046 trace with specific level
3) "alert" to extract local instance's alert log.
MB : MegaBytes to extract, default as 2 MB.
begin_MB : The start file position(in MB) to extract, default as "total_MB - <MB>"
]],trace.get_trace,false,4)
function trace.reset()
tracefile=nil
end

function trace.onload()
env.set_command(nil,{"loadtrace","dumptrace"},[[
Download Oracle trace file into local directory. Usage: @@NAME {<trace_file|default|alert|0/1/4/8/12> [MB] [begin_MB]}
This command requires the "create directory" privilige.
Parameters:
trace_file: 1) The absolute path of the target trace file, or
2) "default" to extract current session's trace, or
4) 0/1/4/8/12 to enable 10046 trace with specific level
3) "alert" to extract local instance's alert log.
MB : MegaBytes to extract, default as 2 MB.
begin_MB : The start file position(in MB) to extract, default as "total_MB - <MB>"
]],trace.get_trace,false,4)
env.event.snoop("AFTER_ORACLE_CONNECT",trace.reset)
end

return trace
2 changes: 1 addition & 1 deletion oracle/xplan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local xplan={}
local default_fmt,e10053,prof="ALLSTATS ALL -PROJECTION OUTLINE REMOTE"
function xplan.explain(fmt,sql)
local ora,sqltext=db.C.ora
e10053=false
env.checkhelp(fmt)
e10053=false
if fmt:sub(1,1)=='-' then
if not sql then return end
fmt=fmt:sub(2)
Expand Down

0 comments on commit a659ecc

Please sign in to comment.