Get process activity
Get process activity {( options )} -> Function result
Parameter | Type | Description | |
---|---|---|---|
options | Longint | 🡒 | Return options |
Function result | Object | 🡐 | 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:
Constant | Type | Value | Comment |
---|---|---|---|
Processes only | Longint | 1 | Returns only the process list |
Sessions only | Longint | 2 | Returns 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 name | Type | Description |
---|---|---|
type | Text (enum) | Session type. Possible values: "remote", "storedProcedure", "web", "rest" |
userName | Text | User name |
machineName | Text | Name of the remote machine |
systemUserName | Text | Name of the system session opened on the remote machine |
IPAddress | Text | IP address of the remote machine |
hostType | Text (enum) | Host type. Possible values: "windows", "mac", "browser" |
creationDateTime | Date ISO 8601 | Date and time of connection of the remote machine |
state | Text (enum) | Session state. Possible values: "active", "postponed", "sleeping" |
ID | Text | Session UUID |
persistentID | Text | Session'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 name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | Text | Process name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sessionID | Text | Session UUID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
number | Longint | Process number | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ID | Longint | Process unique ID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
visible | Boolean | True if visible, false otherwise | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
systemID | Text | ID for the user process, 4D process or spare process | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type | Longint | Running process type. You can use the following constants from the "Process Type" theme:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
state | Longint | Current status (see Process State constant list) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cpuUsage | Real | Percentage of time devoted to this process (between 0 and 1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cpuTime | Real | Running time (seconds) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
preemptive | Boolean | True if run preemptive, false otherwise | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
session | Object | The specific session in which the process is running. Undefined if the Processes only parameter is passed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url | Text | URL 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