| 
                    
 This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com  | 
            ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
                 
                
  | 
                
					
                    
                         
    4D v20.6
 
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 | |||||
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.
{
"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"
                       }
           },...
    ]
}
| Constant | Type | Value | Comment | 
| Processes only | Longint | 1 | Returns only the "processes" list  | 
		
| Sessions only | Longint | 2 | Returns only the "sessions" list  | 
		
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 | 
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. | 
You want to get the collection of all user sessions:
  //To be executed on the server
 
 C_OBJECT($o)
 C_LONGINT($i)
 
 $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
	Product:  4D
	Theme:  Processes
	Number:  
        1495
        
        
        
	
	Created:  4D v16 R4
	Modified:  4D v16 R5
	Modified:  4D v17 R5
	Modified:  4D v19 R4
	
	
	
	
	
	4D Language Reference ( 4D v20)
	
	4D Language Reference ( 4D v20.1)
	
	
	4D Language Reference ( 4D v20.2)
	4D Language Reference ( 4D v20.3)
	4D Language Reference ( 4D v20.4)
	4D Language Reference ( 4D v20.5)
	4D Language Reference ( 4D v20.6)
Add a comment