Skip to main content
Version: 1.24.2

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


SoftwareHW Requirements (minimum)SW Requirements
Agent
  • CPU: 1.4 GHz 64-bit processor.
  • RAM: 512 MB
  • HDD: 32 GB
  • Internet connection: 10/100/1000 Mbit/sec
Agent system requirements align with the OS system requirements.
  • Microsoft Windows server (2012r2 or higher)
  • PHP interpreter (version 7.2 or higher)
  • cURL library
tip

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:

  1. Install the infrastructure agent on the Microsoft Windows server in a customer infrastructure.
  2. Configure your SimpleOne instance.
  3. 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.
note

Ensure the agent→server connections are allowed in your firewall rules.

The diagram below illustrates the interaction process:

Set up an infrastructure server

info

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:

  1. Navigate to MID servers → MID server.
  2. Click New and fill in the form.
  3. Click Save or Save and Exit to apply changes.

MID Server form fields

FieldMandatoryDescription
NameYSpecify the infrastructure server name displayed in the list.
HostnameYSpecify the hostname of the external server to connect to. For example, mid_server.
UserYSpecify the system user name with access to the infrastructure agent functionality. The user must have the admin role.
note

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


  1. Unzip the infrastructure agent archive.
  2. Find the .env configuration file in the bin directory where the infrastructure agent is installed.
  3. Copy your .env.example file into the .env file and modify it according to your instance settings.

Infrastructure Server configuration file description

FieldDescription
MID_API_USERNAMEThe system user name with access to the infrastructure agent functionality.
MID_API_PASSWORDThe password for the specified user.
MID_API_SERVERIDThe server ID that is configured in the MID Server table.
MID_API_ENDPOINTThe 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. 

caution

PowerShell script development is beyond the scope of this article. Refer to PowerShell product documentation.

  1. Navigate to MID Servers → MID Scripts.
  2. Click New and fill in the form.
  3. Click Save or Save and Exit to apply the changes.

MID Script form fields

FieldMandatoryDescription
NameYSpecify the infrastructure server name displayed in the list.
DescriptionNAdd a brief description of the script.
ActiveNSelect this checkbox to activate the script.
ScriptYSpecify a script that handles specific tasks and responsibilities associated with the corresponding activities.
tip

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:

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:

MID Queue Request
{"param1":"String value"}

After the script execution, the Response field in the related MID Queue record contains the following value:

MID Queue Response
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:

  1. Navigate to MID Servers → MID Queue.
  2. Click New and fill in the form.
  3. Click Save or Save and Exit to apply the changes.

MID Queue form fields

FieldMandatoryDescription
RequestNEnter a request to the external server in the JSON format.
ResponseNThe 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.

DescriptionNAdd a brief description of the job.
ServerYSpecify the record containing information about the infrastructure server configured earlier in the MID Server table.
ScriptYSpecify a record that contains the infrastructure script configured earlier in the MID Script table.
StatusNThe job status. This field is populated automatically. Possible options:
  • Created – the job has been created but not yet processed.
  • Processing – the job is being processed now, and no error code is returned.
  • Done – the job is completed successfully, and the 0 error code is returned.
  • Error – the job is completed with errors, and any other error code is returned.
1. If there is more than one job in the queue, they are executed sequentially from the oldest to the newest.
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 atYThe date and time when the request was processed.