Note: Technical Talk being moved to:
www.nazimcricket.com/wiki


Friday, 7 May 2010

Check Oracle Blocking Locks

SELECT to_char(sysdate,'yyyy-mm-dd hh24:mi') dttm
, ' --- BLOCKER --- '
, lo.session_id
, lo.process
, lo.os_user_name
, dob.object_name
, dob.object_type
, ' --- BLOCKING --- '
, s.sid
, s.username
, s.status
, s.schemaname
, s.osuser
, s.process
, s.machine
, s.terminal
, s.program
, s.sql_hash_value
, s.logon_time
, p.spid
, l.id2
, l.ctime
FROM v$session s
, v$process p
, v$lock l
, v$locked_object lo
, dba_objects dob
WHERE s.lockwait is not null
AND p.addr(+) = s.paddr
AND l.sid = s.sid
AND l.type='TX'
AND l.id2 = lo.xidsqn
AND lo.object_id = dob.object_id

Wednesday, 5 May 2010

Count network connections

Task:

Get a count of number of network connections on a Windows server.

My Solution:

Create a batch file containing the following lines:

REM list network connections and write them to a file
netstat -n > netstat_count.txt

REM search for non-existant string in file and return line count instead
find /v /c "zzz" netstat_count.txt

This returns something like ...

---------- NETSTAT_COUNT.TXT: nnn