Agent on PHP
System Requirements
The server and agent do not require any considerable system resources, such as CPU, RAM or hard disk space.
Software requirements
Software | HW Requirements (minimum) | SW Requirements |
---|---|---|
Agent |
|
|
The infrastructure server is configured on the SimpleOne instance as a dictionary record, implementing appropriate business logic on the server and client sides.
Interaction procedure
To configure the interaction, complete the following steps:
- Install the infrastructure agent on the Microsoft Windows server in a customer infrastructure.
- Configure your SimpleOne instance.
- Configure the infrastructure agent.
As a result, the interaction is configured and active. The agent periodically sends requests to the server to retrieve job assignments. The default request interval is one minute and can be adjusted using Windows Task Scheduler.
- If there are no tasks to run, the agent continues to poll the server at configured intervals.
- If there are some tasks to run, the agent executes the tasks and reports the results to the server regardless of success or failure.
Ensure the agent→server connections are allowed in your firewall rules.
The diagram below illustrates the interaction process:
Set up an infrastructure server
The logic of the MID Server table is under active development at the moment and will be extended in the future versions of the platform.
To add server parameters to the appropriate table, complete the following steps:
- Navigate to MID servers → MID server.
- Click New and fill in the form.
- Click Save or Save and Exit to apply changes.
MID Server form fields
Field | Mandatory | Description |
---|---|---|
Name | Y | Specify the infrastructure server name displayed in the list. |
Hostname | Y | Specify the hostname of the external server to connect to. For example, mid_server. |
User | Y | Specify the system user name with access to the infrastructure agent functionality. The user must have the admin role. |
PHP infrastructure agent contains two .bat files:
- one to add the infrastructure agent starting up into the external server schedule;
- one to remove the agent from the scheduler.
These files enable monitoring task processing at defined intervals.
Configure the infrastructure agent
- Unzip the infrastructure agent archive.
- Find the .env configuration file in the bin directory where the infrastructure agent is installed.
- Copy your .env.example file into the .env file and modify it according to your instance settings.
Infrastructure Server configuration file description
Field | Description |
---|---|
MID_API_USERNAME | The system user name with access to the infrastructure agent functionality. |
MID_API_PASSWORD | The password for the specified user. |
MID_API_SERVERID | The server ID that is configured in the MID Server table. |
MID_API_ENDPOINT | The link to the SimpleOne instance, where the MID server operates. |
Example of the configuration file:
- MID_API_USERNAME=admin
- MID_API_PASSWORD=123456
- MID_API_SERVERID=157237947616342741
- MID_API_ENDPOINT=
https://instance.example.com/rest
Adding scripts
After configuring the infrastructure agent, set up PowerShell scripts.
PowerShell script development is beyond the scope of this article. Refer to PowerShell product documentation.
- Navigate to MID Servers → MID Scripts.
- Click New and fill in the form.
- Click Save or Save and Exit to apply the changes.
MID Script form fields
Field | Mandatory | Description |
---|---|---|
Name | Y | Specify the infrastructure server name displayed in the list. |
Description | N | Add a brief description of the script. |
Active | N | Select this checkbox to activate the script. |
Script | Y | Specify a script that handles specific tasks and responsibilities associated with the corresponding activities. |
In these scripts, you can use variables to facilitate the data exchange across the client infrastructure and the SimpleOne instances.
For example, you can make this definition in your MID Script:
$title=``'Title:\n'``;Write-Host($title);Write-Host($param1);
Then the value for the title variable should be transferred into the Request field of the related MID Queue record:
{"param1":"String value"}
After the script execution, the Response field in the related MID Queue record contains the following value:
Title:
String value
Set up a task
To set up a job on the external infrastructure element, create a record in the MID Queue (sys_mid_queue) table. To do so, complete the steps below:
- Navigate to MID Servers → MID Queue.
- Click New and fill in the form.
- Click Save or Save and Exit to apply the changes.
MID Queue form fields
Field | Mandatory | Description |
---|---|---|
Request | N | Enter a request to the external server in the JSON format. |
Response | N | The server response containing the output of the command (the stdout response) and other feedback. This field is populated automatically. The response size should not exceed 2.5Mb. Otherwise, the process results in a verification error and the record is not saved. |
Description | N | Add a brief description of the job. |
Server | Y | Specify the record containing information about the infrastructure server configured earlier in the MID Server table. |
Script | Y | Specify a record that contains the infrastructure script configured earlier in the MID Script table. |
Status | N | The job status. This field is populated automatically. Possible options:
2. If an external server is not responding for a minute, the script is terminated by timeout. In this case, the corresponding job will not return the error code. 3. You can run a job manually if necessary. To do so, run the command run:job where job is the name of the job you need to execute.Note: bin\agent is a relative path to the infrastructure agent installation folder. If you set it in another folder, specify the full path; otherwise, the job may not be executed. |
Processed at | Y | The date and time when the request was processed. |