Program / script execution
The probe runs executable file and returns data from the streams stdout and stderr.
Depending on the selected probe subtype, the next field is different.
Settings
There are three possible subtypes:
-
Program/script in file system.
In the field Executable file the program name or script full path must be specified.
-
Script from repository. In the field Script the script saved in repository must be selected from the dropdown list.
-
Script with text. The field allows users to type a script as text.
This subtype is available only for users who have the permission to execute scripts. If the user doesn’t have the permission, but a script has already been created by another user, the subtype will be available, but the script will be in the read-only mode.
For each script subtype additional Arguments can be specified, if necessary.
If one of the arguments is a string with spaces, each argument needs to be specified in its own field:
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 |
In order 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
}
}
Examples of scripts for *nix:
#!/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"}"
Examples of scripts for Windows:
@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%"}