Skip to main content
Version: Next

Get process activity

Get process activity {( options )} -> Function result

ParameterTypeDescription
optionsLongint🡒Return options
Function resultObject🡐Snapshot of running processes and/or (4D Server only) user sessions

Description

The Get process activity command returns a snapshot of connected user sessions and/or related running processes at a given time. This command returns all processes, including internal processes that were not reachable by the PROCESS PROPERTIES command.

  • When executed on the server, by default if you omit the options parameter, Get process activity returns both user session and process lists, as shown below:
{"sessions": [          {             "type": "remote",             "userName": "Designer",             "machineName": "iMac27caroline",             "systemUserName": "Caroline Briaud",             "IPAddress": "192.168.18.18",             "hostType": "mac",             "creationDateTime": "2017-09-22T12:46:39Z",             "state": "postponed",             "ID": "3C81A8D7AFE64C2E9CCFFCDC35DC52F5"           },...       ],"processes": [          {             "name": "Application process",             "sessionID": "3C81A8D7AFE64C2E9CCFFCDC35DC52F5",             "number": 4,             "ID": 4,             "visible": true,             "systemID": "123145476132864",             "type": -18,             "state": 0,             "cpuUsage": 0,             "cpuTime": 0.006769,             "preemptive": false,             "session": {                         "type": "remote",                      "userName": "Designer",                      "machineName": "iMac27caroline",                      "systemUserName": "Caroline Briaud",                      "IPAddress": "192.168.18.18",                      "hostType": "mac",                      "creationDateTime": "2017-09-22T12:46:39Z",                      "state": "postponed",                      "ID": "3C81A8D7AFE64C2E9CCFFCDC35DC52F5"                       }           },...    ]}  

You can select the list to return by passing one of the following constants of the "4D Environment" theme in the options parameter:

ConstantTypeValueComment
Processes onlyLongint1Returns only the process list
Sessions onlyLongint2Returns only the user session list
  • When executed on 4D in remote or local mode, Get process activity only returns the process list (options parameter is useless).
Sessions

The "sessions" property contains a collection of objects describing all running user sessions on the server.

Each session object contains the following properties:

Property nameTypeDescription
typeText (enum)Session type. Possible values: "remote", "storedProcedure", "web", "rest"
userNameTextUser name
machineNameTextName of the remote machine
systemUserNameTextName of the system session opened on the remote machine
IPAddressTextIP address of the remote machine
hostTypeText (enum)Host type. Possible values: "windows", "mac", "browser"
creationDateTimeDate ISO 8601Date and time of connection of the remote machine
stateText (enum)Session state. Possible values: "active", "postponed", "sleeping"
IDTextSession UUID
persistentIDTextSession's persistent ID

Note: You can get the object of the current client or stored procedure session using the Session command.

Processes

The "processes" property contains a collection of objects describing all running processes on the server.

Each process object contains the following properties:

Property nameTypeDescription
nameTextProcess name
sessionIDTextSession UUID
numberLongintProcess number
IDLongintProcess unique ID
visibleBooleanTrue if visible, false otherwise
systemIDTextID for the user process, 4D process or spare process
typeLongintRunning process type. You can use the following constants from the "Process Type" theme:
ConstantValueComment
HTTP Log flusher-58
Logger process-57
HTTP Listener-56
HTTP Worker pool server-55
SQL Listener-54
SQL Net Session manager-53
SQL Worker pool server-52
DB4D Listener-51
DB4D Mirror-50
DB4D Cron-49
DB4D Worker pool user-48
DB4D Garbage collector-47
DB4D Flush cache-46
DB4D Index builder-45
ServerNet Session manager-44
ServerNet Listener-43
Worker pool spare-42
Worker pool in use-41
Other internal process-40
Main 4D process-39
SOAP process-33
Web server spare process-32
Client manager process-31
Compiler process-29
Monitor process-26
Internal timer process-25
SQL Method execution process-24
MSC process-22
Restore Process-21
Log file process-20
Backup process-19
Internal 4D server process-18
Method editor macro process-17
On exit process-16
Server interface process-15
Execute on client process-14
Web server process-13
Web process on 4D remote-12
Other 4D process-10
External task-9
Event manager-8
Apple event manager-7
Serial Port Manager-6
Indexing process-5
Cache manager-4
Web process with no context-3
Design process-2
Main process-1
None0
Execute on server process1
Created from menu command2
Created from execution dialog3
Other user process4
Worker process5Worker process launched by user
stateLongintCurrent status (see Process State constant list)
cpuUsageRealPercentage of time devoted to this process (between 0 and 1)
cpuTimeRealRunning time (seconds)
preemptiveBooleanTrue if run preemptive, false otherwise
sessionObjectThe specific session in which the process is running. Undefined if the Processes only parameter is passed.
urlTextURL with path and parameters (if any) of the web (-3) and SOAP (-33) processes running on the web server. Not returned for other types of processes.

Example

You want to get the collection of all user sessions:

  //To be executed on the server
 
 var $o : Object
 var $i : Integer
 
 $o:=Get process activity //Get process & session info
 For($i;0;($o.processes.length)-1) //Iterate over the "processes" collection
    $processName:=$o.processes[$i].name
    $userName:=String($o.processes[$i].session.userName) // Easy access to userName
  //use String because session object might be undefined
 End for

See also

PROCESS PROPERTIES
Session storage by ID
WEB Get server info