This article applies as of PRTG 22


Use meta-scans when adding custom EXE/Script sensors via auto-discovery. Is there an option to include such scans with device templates?


Using the meta-scan functionality for EXE/Script Advanced sensors


As of PRTG 16.1.22, it is possible to create custom EXE/Script Advanced sensors that use a meta-scan when you add the sensor via auto-discovery.

To apply this meta-scan functionality, you can write a custom sensor that uses an executable file that returns a list in XML format. Your sensor can then use the data from the XML output to create one sensor for each entry in this list. The data from the XML output will be added to the respective sensor.

What do you need?

There are a few things you must provide to add your custom EXE/Script Advanced sensor with a meta-scan.

  • You need your custom sensor in executable file format, for example, mysensor.exe (you can also use another supported executable file, for example, PS1 or BAT).
  • You need a parameter that triggers the meta-scan, for example, -metascan
  • When you run mysensor.exe –metascan, it must write XML outputto the console in the following format:
    <prtg> 
    <item> 
    <name>Sensor name</name> 
    <exefile>myfile.exe</exefile> 
    <params>-run 1</params> 
    </item> 
    <item> 
    <name>Sensor name 2</name> 
    <exefile>myfile.exe</exefile> 
    <params>-run 2</params> 
    </item> 
    [...] 
    </prtg> 
  • You need a device templatethat adds your sensor using the meta-scan. The template must look like this: 
    <?xml version="1.0" encoding="UTF-8"?> 
    <devicetemplate id="customexexml" name="my custom exe xml" priority="1"> 
    <check id="ping" meta="ping"/> 
    <create id="<my meta id>" kind="exexml" meta="customexexmlscan" requires="ping"> <metadata> 
    <exefile> 
    mysensor.exe 
    </exefile> 
    <exeparams> 
    -metascan 
    </exeparams> 
    </metadata> 
    <createdata/> 
    </create> 
    </devicetemplate> 
  • Replace <my meta id> with a unique ID.
  • mysensor.exe is your custom sensor that returns XML that is used to create the actual sensors.
  • If the meta-scan needs credentials, you can use the same placeholders for <exeparams> that you can use in the Parameters field in the sensor settings.
  • You can use the same executable file with different parameters or even different executable files for the meta-scan and the sensor itself.


You can now run an auto-discovery using this template (my custom exe xml in this example). This automatically adds the sensors according to the XML output. In this example, the added sensors Sensor name and Sensor name 2 execute myfile.exe with the parameters -run 1 and -run 2.


Disclaimer:
The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.