Oracle: who is connected to the server

Here is the simple query, showing who is connected to the server.


col username for a15
col program for a25 trun

select sid, serial#, username, program, substr(module,1,10) module, logon_time
from v$session
order by 1,2;

This is almost the same query, limiting the output to the active users:

select sid, serial#, username, program, substr(module,1,10) module, logon_time
from v$session
where status = 'ACTIVE'
order by 1,2;

It’s important to set “MODULE” field for the running sessions. It makes the output more clear.
The setting could be done with the following command:


exec DBMS_APPLICATION_INFO.SET_MODULE( module_name=>'&module',action_name=>'&action' );

WMI: list of the methods and properties


strComputer = "."
Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

For Each objclass in objWMIService.SubclassesOf()
intCounter=0
If Left(objClass.Path_.Class,5) = "Win32" Then
For Each Qualifier in objClass.Qualifiers_
If UCase(Trim(Qualifier.Name)) = "ASSOCIATION" Then
intCounter = 1
End If
Next
If x = 0 Then
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set strClass = objWMIService.Get(objClass.Path_.Class)
Wscript.Echo "PROPERTIES:"
For each strItem in strClass.properties_
Wscript.Echo objClass.Path_.Class & vbTab & strItem.name
Next
Wscript.Echo "METHODS:"
For Each strItem in strClass.methods_
Wscript.Echo objClass.Path_.Class & vbTab & strItem.name
Next
End If
End If
Next

Other scripts could be found here