Total Sessions

Embed Size (px)

DESCRIPTION

Oracle Total Sessions

Citation preview

select resource_name, current_utilization, max_utilization, limit_value from v$resource_limit where resource_name in ('sessions', 'processes');TOTAL NUMBER OF SESSIONSselect count(status) TOTAL_SESSIONSfrom v$session;SESSIONS GROUP OF USERNAMEselect count(status) Count, username from v$session group by username;SESSIONS GROUP OF USERNAMEselect count(status) Count, program from v$session group by program;*******************************************************************************************Total Count of sessionsselect count(s.status) TOTAL_SESSIONSfrom gv$session s;Total Count of Inactive sessionsselect count(s.status) INACTIVE_SESSIONSfrom gv$session s, v$process pwhere p.addr=s.paddr and s.status='INACTIVE';SESSIONS WHICH ARE IN INACTIVE STATUS FROM MORE THAN 1HOURselect count(s.status) "INACTIVE SESSIONS > 1HOUR "from gv$session s, v$process pwhere p.addr=s.paddr and s.last_call_et > 3600 ands.status='INACTIVE';COUNT OF ACTIVE SESSIONSselect count(s.status) ACTIVE_SESSIONSfrom gv$session s, v$process pwhere p.addr=s.paddr and s.status='ACTIVE';TOTAL SESSIONS COUNT ORDERED BY PROGRAMcol program for a30select s.program,count(s.program) Total_Sessionsfrom gv$session s, v$process pwhere p.addr=s.paddr group by s.program;TOTAL COUNT OF SESSIONS ORDERED BY MODULEcol module for a30prompt TOTAL SESSIONSselect s.module,count(s.sid) Total_Sessionsfrom gv$session s, v$process pwhere p.addr=s.paddr group by s.module;TOTAL COUNT OF SESSIONS ORDERED BY ACTIONcol action for a30prompt TOTAL SESSIONSselect s.action,count(s.sid) Total_Sessionsfrom gv$session s, v$process pwhere p.addr=s.paddr group by s.action;INACTIVE SESSIONSprompt INACTIVE SESSIONSselect p.spid, s.sid,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.programfrom gv$session s, v$process pwhere p.addr=s.paddr and s.status='INACTIVE';INACTIVEprompt INACTIVE SESSIONSselect count(s.status) INACTIVEfrom gv$session s, gv$sqlarea t,v$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE';INACTIVE PROGRAMScol module for a40 prompt INACTIVE SESSIONScol INACTIVE_PROGRAMS FOR A40select distinct (s.program) INACTIVE_PROGRAMS,s.modulefrom gv$session s, v$process pwhere p.addr=s.paddr and s.status='INACTIVE';INACTIVE PROGRAMS with disk readsprompt INACTIVE SESSIONSselect distinct (s.program) INACTIVE_PROGRAMS,SUM(T.DISK_READS)from gv$session s, gv$sqlarea t,v$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'GROUP BY S.PROGRAM;INACTIVE SESSIONS COUNT WITH PROGRAMcol program for a30prompt TOTAL INACTIVE SESSIONScol INACTIVE_PROGRAMS FOR A40select s.program,count(s.program) Total_Inactive_Sessionsfrom gv$session s,v$process pwhere p.addr=s.paddr ANDs.status='INACTIVE'group by s.programorder by 2 desc;TOTAL INACTIVE SESSIONS MORE THAN 1HOURcol program for a30col INACTIVE_PROGRAMS FOR A40select s.program,count(s.program) Inactive_Sessions_from_1Hourfrom gv$session s,v$process pwhere p.addr=s.paddr ANDs.status='INACTIVE' and s.last_call_et > (3600)group by s.programorder by 2 desc;TOTAL INACTIVE SESSIONS GROUP BY MODULEcol program for a60COL MODULE FOR A30prompt TOTAL SESSIONScol INACTIVE_PROGRAMS FOR A40select s.module,count(s.module) Total_Inactive_Sessionsfrom gv$session s,v$process pwhere p.addr=s.paddr ANDs.status='INACTIVE'group by s.module;INACTIVE SESSION DETAILS MORE THAN 1 HOURset pagesize 40col INST_ID for 99col spid for a10set linesize 150col PROGRAM for a10col action format a10col logon_time format a16col module format a13col cli_process format a7col cli_mach for a15col status format a10col username format a10col last_call_et_Hrs for 9999.99col sql_hash_value for 9999999999999col username for a10set linesize 152set pagesize 80col "Last SQL" for a60col elapsed_time for 999999999999select p.spid, s.sid,s.last_call_et/3600 last_call_et_Hrs ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.last_call_et > (3600)order by last_call_et;INACTIVE PROGRAM --ANY--select p.spid, s.sid,s.last_call_et/3600 last_call_et_Hrs ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'And s.program='&PROGRAM_NAME'order by last_call_et;INACTIVE MODULES --ANY--select p.spid, s.sid,s.last_call_et/3600 last_call_et_Hrs ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddrAnd s.module like '%order_cleanup_hazmat_v3.sql'order by last_call_et;INACTIVE JDBC SESSIONSset pagesize 40col INST_ID for 99col spid for a10set linesize 150col PROGRAM for a10col action format a10col logon_time format a16col module format a13col cli_process format a7col cli_mach for a15col status format a10col username format a10col last_call_et for 9999.99col sql_hash_value for 9999999999999col username for a10set linesize 152set pagesize 80col "Last SQL" for a60col elapsed_time for 999999999999select p.spid, s.sid,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.program='JDBC Thin Client'and s.last_call_et > 3600order by last_call_et;COUNT OF INACTIVE SESSIONS MORE THAN ONE HOURSELECT COUNT(P.SPID)from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.program='JDBC Thin Client'and s.last_call_et > 3600order by last_call_et;FORMSTOTAL FORM SESSIONSSELECT COUNT(S.SID) INACTIVE_FORM_SESSIONS FROM V$SESSION SWHERE S.STATUS='INACTIVE' ands.action like ('%FRM%');FORMS SESSIONS DETAILScol "Last SQL" for a30select p.spid,s.sid,s.status,s.last_call_et/3600 last_call_et_hrs ,s.sid,t.disk_reads, t.elapsed_time,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.action like ('FRM%') ands.last_call_et > 3600order by spid; col machine for a15col "Last SQL" for a30select p.spid,s.sid,s.status,s.last_call_et/3600 last_call_et_hrs ,S.ACTION,s.process Client_Process,s.machinefrom gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.action like ('FRM%') ands.last_call_et > 3600; order by 4; INACTIVE FORMS SESSIONS DETAILScol program for a15col last_call_et for 999.99select p.spid, s.sid, s.process,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.action like 'FRM:%'and s.last_call_et > 3600order by last_call_et desc;UNIQUE SPIDselect unique(p.spid)from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.action like 'FRM:%'and s.last_call_et > 3600;COUNT FORMSselect COUNT(p.spid)from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.action like 'FRM:%'and s.last_call_et > 3600;ZERO HASH VALUEselect COUNT(p.spid)from gv$session s,gv$process pwhere p.addr=s.paddr and s.status='INACTIVE'and s.action like 'FRM:%'and s.last_call_et > 3600AND S.SQL_HASH_VALUE=0;INACTIVE FORM BY NAMEselect count(s.sid) from v$session S where s.action like ('%&ACTION%')AND S.STATUS='INACTIVE';GROUP BY ACTIONSELECT S.ACTION,COUNT(S.SID) FROM V$SESSION SWHERE S.STATUS='INACTIVE' ands.action like ('%FRM%')group by s.action;FROM A SPECIFIC USERNAMESET LINSIZE 152col spid for a10col process_spid for a10col user_name for a20col form_name for a20select a.pid,a.spid,a.process_spid, c.user_name,to_char(a.start_time,'DD-MON-YYYY HH24:MI:SS') "START_TIME" ,d.user_form_name "FORM_NAME"from apps.fnd_logins a, apps.fnd_login_resp_forms b, apps.fnd_user c,apps.fnd_form_tl dwherea.login_id=b.login_id and c.user_name like 'JROMO'and a.user_id=c.user_idand trunc(b.start_time) >trunc(sysdate -11)and trunc(b.end_time) is nulland b.form_id=d.form_idand d.language='US';INACTIVE FORMset pagesize 40col INST_ID for 99col spid for a10set linesize 150col PROGRAM for a10col action format a10col logon_time format a16col module format a13col cli_process format a7col cli_mach for a15col status format a10col username format a10col last_call_et for 9999.99col sql_hash_value for 9999999999999col username for a10set linesize 152set pagesize 80col "Last SQL" for a30col elapsed_time for 999999999999select p.spid, s.sid,s.process cli_process,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='INACTIVE'and s.action like ('FRM%')and s.last_call_et > (3600*3)order by last_call_et; INACTIVE FORM SESSIONS col cli_proc for a9COL AUDSID FOR A6COL PID FOR A6COL SID FOR A5COL FORM_NAME FOR A25COL USER_NAME FOR A15col last_call_et for 9999.99SELECT -- /*+ ORDERED FULL(fl) FULL(vp) USE_HASH(fl vp) */( SELECT SUBSTR ( fu.user_name, 1, 20 )FROM apps.fnd_user fuWHERE fu.user_id = fl.user_id) user_name,vs.status,TO_CHAR ( fl.start_time, 'DD-MON-YYYY HH24:MI' ) login_start_time,TO_CHAR ( fl.end_time, 'DD-MON-YYYY HH24:MI' ) login_end_time,vs.last_call_et/3600 last_call_et,SUBSTR ( fl.process_spid, 1, 6 ) spid,SUBSTR ( vs.process, 1, 8 ) cli_proc,SUBSTR ( TO_CHAR ( vs.sid ), 1, 3 ) sid,SUBSTR ( TO_CHAR ( vs.serial#), 1, 7 ) serial#,SUBSTR ( TO_CHAR ( rf.audsid ), 1, 6 ) audsid,SUBSTR ( TO_CHAR ( fl.pid ), 1, 3 ) pid,SUBSTR ( vs.module || ' - ' ||( SELECT SUBSTR ( ft.user_form_name, 1, 40 )FROM apps.fnd_form_tl ftWHERE ft.application_id = rf.form_appl_idAND ft.form_id = rf.form_idAND ft.language = USERENV('LANG')), 1, 40 ) form_nameFROM apps.fnd_logins fl,gv$process vp,apps.fnd_login_resp_forms rf,gv$session vsWHERE fl.start_time > sysdate - 7 /* login within last 7 days */AND fl.login_type = 'FORM'AND fl.process_spid = vp.spidAND fl.pid = vp.pidAND fl.login_id = rf.login_idAND rf.end_time IS NULLAND rf.audsid = vs.audsidand vs.status='INACTIVE'ORDER BYvs.process,fl.process_spid;ACTIVEprompt ACTIVE SESSIONSselect count(s.status) ACTIVEfrom gv$session s, gv$sqlarea t,v$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.status='ACTIVE';MODULEset pagesize 40col INST_ID for 99col spid for a10set linesize 150col PROGRAM for a10col action format a10col logon_time format a16col module format a13col cli_process format a7col cli_mach for a15col status format a10col username format a10col last_call_et for 9999.99col sql_hash_value for 9999999999999col username for a10set linesize 152set pagesize 80col "Last SQL" for a30col elapsed_time for 999999999999select p.spid, s.sid,s.process cli_process,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.program,t.disk_reads,lpad(t.sql_text,30) "Last SQL"from gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr and s.MODULE like ('&MODULE_NAME_1HR%')and s.last_call_et > ('&TIME_HRS' * 3600)order by last_call_et;select p.spid, s.sid,s.process cli_process,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.programfrom gv$session s, gv$sqlarea t,gv$process pwhere s.sql_address =t.address andp.addr=s.paddr and s.MODULE like ('%TOAD%')Order by last_call_et;TOAD SESSIONSselect p.spid, s.sid,s.process cli_process,s.last_call_et/3600 last_call_et ,s.status,s.action,s.module,s.programfrom gv$session s, gv$process pwhere p.addr=s.paddr and s.MODULE like ('%TOAD%')Order by last_call_et;CLIENT MACHINE SESSIONS COUNTselect count(s.process) TOTAL from v$session Swhere s.machine like ('%&CLIENT_MACHINE%');select count(s.process) INACTIVE from v$session Swhere s.machine like ('%&CLIENT_MACHINE%')and s.status='INACTIVE';hash value=0select count(s.process) from v$session Swhere s.machine like ('%&CLIENT_MACHINE%')AND S.SQL_HASH_VALUE=0;select count(s.process) from v$session Swhere s.machine like ('%&CLIENT_MACHINE%')AND S.SQL_HASH_VALUE=0AND S.LAST_CALL_ET > 3600;Unique Actionscol module for a40 prompt INACTIVE SESSIONScol INACTIVE_PROGRAMS FOR A40select distinct (s.program) INACTIVE_PROGRAMS,s.modulefrom gv$session s, gv$sqlarea t,v$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and s.machine like ('%&CLIENT_MACHINE%') ANDp.addr=s.paddr and s.status='INACTIVE';GROUP BY programcol program for a60prompt TOTAL SESSIONScol INACTIVE_PROGRAMS FOR A40select s.program,count(s.program) Total_Inactive_Sessionsfrom gv$session s, gv$sqlarea t,v$process pwhere s.sql_address =t.address ands.sql_hash_value =t.hash_value and p.addr=s.paddr ANDs.machine like ('%&CLIENT_MACHINE%') ANDs.status='INACTIVE'group by s.program;find * -mtime +150 -exec rm {} \;