4D continues to deliver features to help you create your own applications to monitor your servers. From programmatically retrieving information about sessions, processes, and the application server, to getting information about the web server.
Having already provided you commands to read about statuses, 4D v17 R4 now gives you the ability to change statuses. You can now create your own administration interfaces as dialogs on the server, client, or even as HTML pages for web access. It’s up to you. These commands allow you to perform the same actions as the standard 4D administration interface. For example, you can send a message to your users to notify them of scheduled maintenance, or block new connections to the application server while you perform an operation on it.
User commands
You can send a message from the server to a remote user with the SEND MESSAGE TO REMOTE USER command. To retrieve a list of user sessions, you can use the Get process activity command.
For example, the server administrator wants to send a message to all connected users.
C_TEXT($message)
$message:="A maintenance operation is scheduled and the server will be restarted. Please log out before 10pm."
SEND MESSAGE TO REMOTE USER($message)
Or send a message only to John.
C_TEXT($message)
C_COLLECTION($userCol)
C_OBJECT($element)
// Retrieve the list of sessions with the userName: "John"
$userCol:=Get process activity(Sessions only).sessions.query("userName = :1";"John")
$message:="Hello John."
For each ($element;$userCol)
SEND MESSAGE TO REMOTE USER($message;$element.ID)
End for each
You can also end a user session with the DROP REMOTE USER command.
C_COLLECTION($userCol)
C_OBJECT($element)
// Retrieve the list of sessions
$userCol:=Get process activity(Sessions only).sessions.query("userName = :1";"John")
For each ($element;$userCol)
DROP REMOTE USER($element.ID)
End for each
Process commands
With the new ABORT PROCESS BY ID command, you can stop a specific process by using its unique process ID. To retrieve the unique process ID, you can use the Get process activity or Process properties commands.
For example, an operation was started on the database but it seems never-ending and is disrupting server performance. The administrator can retrieve the process number and thus abort the process.
// Retrieve the list of processes on the server and display it in a list box
$activity:=Get process activity(Processes only).processes
...
// The process selected by the administrator is aborted
ABORT PROCESS BY ID($activity.processes[selectedItem].ID)
Client connections
The server administrator can block new remote connections with the REJECT NEW REMOTE CONNECTION command. To tell if the connections have been accepted or refused, use the Get application info command.
// Reject the new connections
REJECT NEW REMOTE CONNECTIONS(True)
// Execute the maintenance operation
...
// Accept the new connections
REJECT NEW REMOTE CONNECTIONS(False)
SOAP REQUESTS
To block SOAP requests, you can use the SOAP REJECT NEW REQUESTS command. To know if the requests have been accepted or refused, use the WEB Get server info command.
If (WEB Get server info.SOAPServerStarted)
SOAP REJECT NEW REQUESTS(True)
End if
Refresh license
Your team has grown, so you’ve purchased new client connections for your server. Server administrators are no longer required to physically access the server machine to update a license. The Refresh license command is now available. It calls the same action as if the administrator had clicked the button in 4D Server’s license dialog. Just in case you missed this feature, it automatically installs purchased licenses for clients, 4D Write Pro, or 4D View Pro. Read more about this feature.
C_OBJECT($res)
$res:=Refresh license
If ($res.success)
ALERT("Success")
Else
ALERT($res.message)
End if