What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I use meta-scans for custom EXE/Script sensors?

Votes:

0

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

auto-discovery custom-exe custom-script-exe custom-sensor device-template exe-script-sensor meta-scan prtg

Created on Jan 27, 2016 3:39:20 PM by  Gerald Schoch [Paessler Support]



6 Replies

Accepted Answer

Votes:

0

This article applies as of PRTG 22

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 output to 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 template that 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.

Created on Jan 27, 2016 3:46:13 PM by  Gerald Schoch [Paessler Support]

Last change on Jan 4, 2023 2:28:10 PM by  Brandy Greger [Paessler Support]



Votes:

0

Hi... I'm having a problem with this one... Is there a way to extend the timeout ? My meta-scan times out: 2021-10-15 22:40:09.119923 INFO TId 19712 CoreAutoDiscovery> Template Create Meta Request; Device ID: 122674; Create ID: prtgc.sensor.velocloud.edge; ERROR: 106ErrorMessage: Timeout (5000 ms)

measure-command {prtgc_velocloud --action meta -u "@APITOKEN" -p "**TOKEN**" --url https://server.velocloud.net --query1  "Customer1" --subsystem edge -t 15000 }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 5
Milliseconds      : 781
Ticks             : 57810923
TotalDays         : 6.69107905092593E-05
TotalHours        : 0.00160585897222222
TotalMinutes      : 0.0963515383333333
TotalSeconds      : 5.7810923
TotalMilliseconds : 5781.0923
<?xml version="1.0" encoding="UTF-8"?>
<devicetemplate id="customexexml" name="PRTGC Velocloud sensor by Link" priority="1" deviceicon="vendors_Velocloud.png">
    <check id="https443" meta="http">
        <metadata>
          <protocol>https</protocol>
          <port>443</port>
        </metadata>
    </check>

    <create id="prtgc.sensor.velocloud.link" kind="exexml" meta="customexexmlscan" requires="https443">
        <metadata>
            <exefile>prtgc_velocloud.exe</exefile>
            <exeparams>--action meta -u "%windowsuser" -p "%windowspassword" -C windows --url https://%host --query1 "%group" --subsystem link</exeparams>
        </metadata>
        <createdata>
            <tags>bandwidthsensor trafficsensor prtgcvelocloud prtgcvelocloudlink prtgcapisensor</tags>
            <stack>2</stack>
            <environment>1</environment>
        </createdata>
    </create>
</devicetemplate>

Is there a way to set the environment with the same variables like an EXEXML sensor ? Environment: ALLUSERSPROFILE =>C:\ProgramData APPDATA =>C:\WINDOWS\system32\config\systemprofile\AppData\Roaming AWS_EC2_METADATA_DISABLED =>true ChocolateyInstall =>C:\ProgramData\chocolatey CommonProgramFiles =>C:\Program Files\Common Files CommonProgramFiles(x86) =>C:\Program Files (x86)\Common Files CommonProgramW6432 =>C:\Program Files\Common Files COMPUTERNAME =>JRZ ComSpec =>C:\WINDOWS\system32\cmd.exe DriverData =>C:\Windows\System32\Drivers\DriverData INTELOCLPATH =>C:\Dev\IntelSWTools\sw_dev_tools\OpenCL\sdk\bin\x64;C:\Dev\IntelSWTools\sw_dev_tools\OpenCL\sdk\bin\x86 INTELOCLSDKROOT =>C:\Dev\IntelSWTools\sw_dev_tools\OpenCL\sdk\ JAVA_HOME =>C:\Program Files\RedHat\java-11-openjdk-11.0.8-2\ LOCALAPPDATA =>C:\WINDOWS\system32\config\systemprofile\AppData\Local MSMPI_BIN =>C:\Program Files\Microsoft MPI\Bin\ NUMBER_OF_PROCESSORS =>16 OS =>Windows_NT Path =>C:\Windows\system32;C:\Windows;C:\tools;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python38\Scripts\;C:\Python38\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files\RedHat\java-11-openjdk-11.0.8-2\bin;C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.232-3\bin;C:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.232-3\jre\bin;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64;C:\Program Files\PuTTY\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Common Files\Autodesk Shared\;C:\Dev\vcpkg;C:\Dev\Perl\Strawberry\perl\bin;C:\Dev\libs\openssl-1.1.1g\Win64\bin;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Dev\IntelSWTools\sw_dev_tools\OpenCL\sdk\bin\x64;C:\Dev\IntelSWTools\sw_dev_tools\OpenCL\sdk\bin\x86;;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\SafeNet\Authentication\SAC\x64;C:\Program Files\SafeNet\Authentication\SAC\x32;C:\Program Files (x86)\dotnet\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\TortoiseGit\bin;;C:\Program Files (x86)\NTP\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps PATHEXT =>.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW PROCESSOR_ARCHITECTURE =>AMD64 PROCESSOR_IDENTIFIER =>Intel64 Family 6 Model 158 Stepping 13, GenuineIntel PROCESSOR_LEVEL =>6 PROCESSOR_REVISION =>9e0d ProgramData =>C:\ProgramData ProgramFiles =>C:\Program Files ProgramFiles(x86) =>C:\Program Files (x86) ProgramW6432 =>C:\Program Files PSModulePath =>C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\ PUBLIC =>C:\Users\Public SystemDrive =>C: SystemRoot =>C:\WINDOWS TEMP =>C:\WINDOWS\TEMP TMP =>C:\WINDOWS\TEMP USERDOMAIN =>WORKGROUP USERNAME =>JRZ$ USERPROFILE =>C:\WINDOWS\system32\config\systemprofile windir =>C:\WINDOWS ZES_ENABLE_SYSMAN =>1 _NT_SYMBOL_PATH =>srv*C:\Dev\Win-Symbols*http://msdl.microsoft.com/downloads/symbols --------------------------------- Params: Param[0] =>C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\dump_env.exe Param[1] =>--action Param[2] =>meta Param[3] =>-C Param[4] =>windows Param[5] =>--url Param[6] =>https://server.velocloud.net Param[7] =>-Query1 Param[8] =>'Customer1' Param[9] =>-Setting Param[10] =>%settings Param[11] =>-u Param[12] => Param[13] =>-p Param[14] => Param[15] =>-snmpcommunity Param[16] =>public Param[17] =>-LnxUsr Param[18] =>**REDACTED** Param[19] =>-LnxPwd Param[20] =>**REDACTED**

And, finally, would it possible to set the log path in the environment too ? (for all external exe programs...) like:

prtg_logpath=D:\PRTG\Data\Paessler\PRTG Network Monitor\Logs

in addition to the standard:
prtg_device=Local Test
prtg_deviceid=63384
prtg_groupid=63362
prtg_host=server.velocloud.net
prtg_linuxpassword=**REDACTED**
prtg_linuxuser=user1
prtg_name=XML Custom EXE/Script Sensor
prtg_primarychannel=1
prtg_probe=Local Probe
prtg_probeid=1
prtg_sensorid=63430
prtg_snmpcommunity=public
prtg_url=http://172.20.40.25/
prtg_version=19.4.53.1912
prtg_windowsdomain=
prtg_windowspassword=**REDACTED**
prtg_windowsuser=@APITOKEN


Thanks JR

Created on Oct 15, 2021 10:59:02 PM by  JR Andreassen (10) 2



Votes:

0

Hello JR,

The auto-discovery timeout can be increased via registry. The environment variables or log files path cannot be be changed though.

Created on Oct 18, 2021 8:52:54 AM by  Arne Seifert [Paessler Support]



Votes:

0

Hi Arne, OK.. Thanks for the reply

Created on Oct 20, 2021 7:18:14 PM by  JR Andreassen (10) 2



Votes:

0

Hello again..> I have another question related to the custom auto discovery ... The custom metascan works with a customer XML sensors...

It does not seem to work with a "httpdataadvanced"...

It only creates one sensor but none of the parameters are filled in. Is there something that I'm missing ? Thanks JR

Template

<?xml version="1.0" encoding="UTF-8"?>
<devicetemplate id="prtgc.gateway.XXX.link" name="PRTGC Gateway XXX sensor by Link" priority="1" deviceicon="vendors_XXX.png">
    <check id="https443" meta="http">
        <metadata>
          <protocol>https</protocol>
          <port>443</port>
        </metadata>
    </check>

    <create id="prtgc.sensor.gw.XXX.link" kind="httpdataadvanced" meta="customexexmlscan" requires="https443">
        <metadata>
            <exefile>prtgc_XXX.exe</exefile>
            <exeparams>--action meta -C windows -u "%windowsuser" -p "%windowspassword" --url https://%host --query1 "%group" --subsystem link --query4 "http://server.local"</exeparams>
            <!-- -C {linux|windows} in the metascan indicates to expect to use the linux/windows creds from the prtg environmnet variables when generating the sensors -->
        </metadata>
        <createdata>
            <tags>bandwidthsensor trafficsensor prtgcapisensor prtgcgw metric_jitter metric_latency metric_packetloss</tags>
            <stack>2</stack>
        </createdata>
    </create>
</devicetemplate>

It returns:

<?xml version="1.0" encoding="UTF-8"?>
<prtg>
	<item>
		<name>xxx Customer (Vco:1)</name>
		<postdata>{&quot;password&quot;:&quot;%windowspassword&quot;,&quot;user&quot;:&quot;%windowsuser&quot;,&quot;subsystem&quot;:&quot;customer&quot;,&quot;query1&quot;:&quot;222&quot;,&quot;url&quot;:&quot;https://172.16.0.1/portal/rest&quot;}</postdata>
		<httpmethod>POST</httpmethod>
		<httpurl>http://server.local</httpurl>
		<tags>bandwidthsensor trafficsensor metric_latency metric_jitter metric_packetloss prtgcxxx prtgcxxxlink prtgcapisensor metric_jitter</tags>
		<postcontenttype>application/json</postcontenttype>
		<httpauthneeded>0</httpauthneeded>
		<customheaders>X-PRTGC-ID: xxx-BFD0</customheaders>
		<httpauthentication>0</httpauthentication>
		<useuseragent>0</useuseragent>
	</item>
	<item>
		<name>Austin, TX - 123 Main Street (Vco Edge:333)</name>
		<postdata>{&quot;subsystem&quot;:&quot;edge&quot;,&quot;query222&quot;:&quot;333&quot;,&quot;query1&quot;:&quot;555&quot;,&quot;url&quot;:&quot;https://172.16.0.1/portal/rest&quot;,&quot;user&quot;:&quot;%windowsuser&quot;,&quot;password&quot;:&quot;%windowspassword&quot;}</postdata>
		<httpurl>http://server.local</httpurl>
		<httpmethod>POST</httpmethod>
		<customheaders>X-PRTGC-ID: xxx-BFD0</customheaders>
		<httpauthentication>0</httpauthentication>
		<postcontenttype>application/json</postcontenttype>
		<useuseragent>0</useuseragent>
		<httpauthneeded>0</httpauthneeded>
		<tags>bandwidthsensor trafficsensor metric_latency metric_jitter metric_packetloss prtgcxxx prtgcxxxlink prtgcapisensor metric_jitter</tags>
	</item>
...
</prtg>

Probe Log:

2021-11-03 20:19:16.413659 INFO TId   34432 CoreAutoDiscovery> Autodiscovery Started; Device ID: 122670
2021-11-03 20:19:16.413659 INFO TId   34432 CoreAutoDiscovery> Device ID: 122670 Name: XXXX Link Host: 172.16.0.1/ ProbeGUID: {75E3939D-C380-4331-93B1-35080ADD3977}
2021-11-03 20:19:16.414659 INFO TId   34432 CoreAutoDiscovery> Device Templates; Device ID: 122670; Selected: 1
2021-11-03 20:19:16.420657 INFO TId   34432 CoreAutoDiscovery> Template Loaded; Device ID: 122670; Name: PRTGC Gateway XXXX sensor by Link
2021-11-03 20:19:17.350544 INFO TId   34432 CoreAutoDiscovery> Template Check; Device ID: 122670; Check ID: https443; FOUND
2021-11-03 20:19:17.350544 INFO TId   34432 CoreAutoDiscovery> Template Assigned; Device ID: 122670; Name: PRTGC Gateway XXXX sensor by Link
2021-11-03 20:19:23.994657 INFO TId   34432 CoreAutoDiscovery> Template Create Meta Request; Device ID: 122670; Create ID: prtgc.sensor.gw.XXXX.link; FOUND: 1
2021-11-03 20:19:24.007752 INFO TId   34432 CoreAutoDiscovery> Sensor Created; Device ID: 122670; Create ID: prtgc.sensor.gw.XXXX.link; Sensor ID: 123333; Name: HTTP Data Advanced
2021-11-03 20:19:24.134611 INFO TId   34432 CoreAutoDiscovery> Autodiscovery Finished: Device ID: 122670; Sensor(s): 1; Templates: PRTGC Gateway XXXX sensor by Link

My Log:

20211103 20:19:23.953880600 UTC|INFO |P: 33528|T: 31092|prtgc_XXXX::sensor_XXXX| Meta/link meta_data_scan("CustomerName")[65 recs]  -> Generating 1 Customers, 95 sensors... 
20211103 20:19:23.953970200 UTC|INFO |P: 33528|T: 31092|prtgc_XXXX::sensor_XXXX|  Meta/link Sensor timing: Exec:815ms | Wait/Query:4762ms | Total:5577ms

Created on Nov 3, 2021 8:30:31 PM by  JR Andreassen (10) 2



Votes:

0

Hello JR,

the custom metascan is available only for custom sensors.

For creating sensors using scripts, the currently easiest way is lordmilko's PrtgAPI plugin.

Created on Nov 9, 2021 12:43:47 PM by  Arne Seifert [Paessler Support]




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.