Program / script execution
The probe runs executable file and returns data from the streams stdout and stderr.
Settings
This section contains description of parameters for every program/script subtype.


Subtype
Тип программы/скрипта.
There are three available subtypes:
-
Program/script in file system,
-
Script from repository,
-
Script with text.
The Script with text subtype is available to users with manage scripts permission. Users without such permissions can access existing scripts, but cannot edit them. |
Work directory
This parameter requires SAYMON Agent v5.5.8 or higher. Older versions of SAYMON Agent will always use the agent installation directory as working directory (default /opt/saymon-agent ).
|
Script’s working directory.
If this parameter is not defined, the system uses agent installation directory (by default /opt/saymon-agent
).
Script/Executable file
Script that the sensor will execute. Parameter field depends on the selected subtype.
-
For a Program/script in file system you can define an absolute path to an executable file in the Executable file,
-
For a Script from repository you can select an existing script from the repository in the Script field,
-
For a Script with text subtype the Script field is a script editor where you can script’s text.
Script editor
You can use a built-in script editor to define a script for the Program / script execution with the Script with text subtype. This editor supports code highlighting.


Editor controls are only available to users with the manage scripts permissions. If a user doesn’t have such permissions, the editor will be in read-only mode. |
You can use the
button to add the current script to the repository. You can use and buttons to undo and redo actions respectively.Examples
Executable files can also return data in the JSON format:
{"cpu": "10", "mem": "20"}
In that case the data will be recognized and automatically distributed across the Data table with the columns cpu and mem with the values 10 and 20 respectively:
cpu | mem |
---|---|
10 |
20 |
For multiline tables the JSON data need to be changed that way:
{
"host1": {
"cpu": "10",
"mem": "20"
},
"host2": {
"cpu": "30",
"mem": "40"
}
}
In that case the data will be recognized and automatically distributed across the Data table with the columns host1.cpu, host1.mem, host2.cpu and host2.mem:
host1.cpu | host1.mem | host2.cpu | host2.mem |
---|---|---|---|
10 |
20 |
30 |
40 |
With selecting stdout in the dropdown list Table for field, there will be the multiline table the section Data:
cpu | mem |
---|---|
10 |
20 |
30 |
40 |
To make the data more illustrative, it is possible to add the field host to the data:
{
"host1": {
"host": "1",
"cpu": "10",
"mem": "20"
},
"host2": {
"host": "2",
"cpu": "30",
"mem": "40"
}
}
The result is the table:
host | cpu | mem |
---|---|---|
1 |
10 |
20 |
2 |
30 |
40 |
And another one good example:
{
"MEM": {
"memoryType": "MEM",
"bytesTotal": 4130643968,
"bytesUsed": 3002249216,
"bytesAvailable": 1128394752,
"percentUsed": 72.68235266119164
},
"SWAP": {
"memoryType": "SWAP",
"bytesTotal": 536866816,
"bytesUsed": 469790720,
"bytesAvailable": 67076096,
"percentUsed": 87.50600819403225
},
"TOTAL": {
"memoryType": "TOTAL",
"bytesTotal": 4667510784,
"bytesUsed": 3472039936,
"bytesAvailable": 1195470848,
"percentUsed": 74.38740040841435
}
}
#!/bin/sh
# Example of stdout output
# Search for TEST.sh script running
echo `ps -ef | grep "TEST.sh" | grep -v grep | wc -l`
#!/bin/sh
# Example of stdout JSON-output
# Search for TEST.sh script running
TEST=$( ps -ef | grep "TEST.sh" | grep -v grep | wc -l )
echo "{"TEST":"$TEST"}"
@echo off
REM Example of stdout output
REM Search for RDP service running
for /F "tokens=*" %%i in ('tasklist.exe /svc ^| find /c "TermService"') do set TERMSRV=%%i
echo %TERMSRV%
@echo off
REM Example of stdout JSON-output
REM Search for RDP service and test.cmd file running
for /F "tokens=*" %%i in ('tasklist.exe /svc ^| find /c "TermService"') do set TERMSRV=%%i
for /F "tokens=*" %%i in ('tasklist.exe /v ^| find /c "test.cmd"') do set TEST=%%i
echo {"TERMSRV":"%TERMSRV%","TEST":"%TEST%"}