Top Tags

Can I use a generic meta-scan for any sensor type?

0

There are many sensor types in PRTG which scan for available monitoring items during sensor creation, the “meta-scan”. I would like to know if it is possible to perform such meta-scans for other sensor types, too?

For example, can I create a device template that adds several HTTP sensors for different URLs using meta-scans?

10 Replies

0

Creating a Meta-Scan for Any Sensor Type

PRTG provides the possibility to create your own meta-scan for any sensor type you want. This generic meta-scan functionality allows advanced users to write an individual meta-scan without the need to edit the code of the sensor itself. HTTP sensors, for example, do not have a meta-scan functionality, but if you create a meta-scan for them, you can automatically add various HTTP sensors with different target URLs using the PRTG Auto-Discovery.

Note: We recommend that you use this feature only if you are an advanced PRTG user with knowledge about scripting and device templates.

The generic meta-scan is not officially supported.

To use the generic meta-scan for a specific sensor type, you need to create the following objects.

1) Executable File

You need to write an executable file (for example, an .exe, .ps1, or .bat file) that defines what to monitor. Save this executable into the \Custom Sensors\EXEXML subfolder of your PRTG installation path, for example, as mysensor.exe.

PRTG will add one sensor for each <item> element within the <prtg> section. The <item> sections define the properties of each sensor, for example, the sensor name. PRTG will copy all these sub-items into fields of the PRTG configuration file, using the same sub-item names.

To find the correct names of the config fields to use them for the sub-items, manually add a sensor of the type you want to use in the meta-scan and export it into a device template:

Open this template with an editor. You can find it in the \devicetemplates subfolder of your PRTG program directory.

See section <createdata> in the template. Here you can find the names (for example, <httpurl>) of all available parameters that you can use as sub-items in your executable for the meta-scan.

Note: This is not possible for sensors which cannot be saved into device templates (see the manual for a list of exceptions) and sensor types that dynamically scan for available monitoring items when you add the sensor. As an alternative you can use a web developer tool (for example, Firebug) on the settings page of the desired sensor and find the field name this way. Note that the field names are followed by an underscore (_) that you have to leave out in the return code of your executable.

Here is an example for such a sub-item in the XML output:

<httpurl>http://paessler.com</httpurl>

2) Device Template

When you have written your program that returns the XML output in the expected format, you will need to create a device template that attaches the generic meta-scan to your sensor. This template has to execute your meta-scan executable file from above, for example, mysensor.exe.

You can now run an auto-discovery in PRTG using the template which executes your meta-scan program. See below for an example with HTTP sensors.

Example: Generic Meta-Scan for HTTP Sensors

HTTP sensors, for example, do not provide a meta-scan functionality. If you want to monitor specific websites, you would have to add each HTTP sensor with the particular target address manually. Using the generic meta-scan, you can write a program that retrieves target URLs and returns them in the expected XML format to PRTG, telling your device template which websites are to monitor. Then you can run an auto-discovery with this template and PRTG will add all HTTP sensors for each address automatically.

The device template you can use for HTTP sensors and necessary adjustments are described above. Only if you want to implement a generic meta-scan for other sensors, you will have to change the sensor “kind” in the provided template.

Now write your program that retrieves (for example, from a CSV data file) and returns a list of webpages which you want to monitor. For the XML output of the program, you need to define the items for the sensor. You can look up available items in an existing device template, as described above.

If you run an auto-discovery now with your device template (My Generic Meta Scan in this example) that executes your generic meta-scan executable (mysensor.exe in this example), PRTG will create two new HTTP sensors:

An HTTP sensor named Http Paessler that monitors the URL http://paessler.com

An HTTP sensor named Http Google that monitors the URL http://google.com

0

thanks for the explanation, it's a very useful feature, i'm very happy for it!

i'm trying to use a custom meta scan to create Custom Performance Counter Sensors (PerfCounter Custom) but having the following issue with it:
the sensors get created, but only the first channel is used, only the first counter finds its way into the sensor.
I'm using the same syntax as in exported templates when i manually created a PerfCounter Custom Sensor using multiple Counters (&#x0d; as delimiter between counters) as you can see in the meta scan result below. the other counters are not visible in the sensor settings.
the order of counter doesn't seem to matter, it's always the first counter which is used, the others are ignored. when i output an actual "Carriage Return" in the XML, all counters are visible in the sensor settings but it doesn't work. errors about can't connect to performance counter or buffer errors appear.

Notice, instead of the XML Code for Carriage Return(&#x0d;) to seperate the counters it actually puts them in multiple lines. this is the way to insert them in the sensor settings when created manually, but when i create a device template from it, the new lines get replaced by the XML Code, that's why i used the same syntax for the meta scan result.

how does the meta scan output has to look like to create PerfCounter Custom Sensors with multiple Counters?

when i put the <counters> section in a template it works, but not with the meta scan, it seems like the issue is PRTG not interpreting the <counters> section correctly or what i see is not what PRTG actually receives. is there a way to debug this? or do you have an example that works for you?

seems like it does not interpret the codes as seperators, it's just one long string and the sensor fails with:
There is more data to return than would fit in the supplied buffer. Allocate a larger buffer and call the function again. (Performance Counter error 0x800007D2)

This template will deploy the SNMP Memory Sensor but instead of deploying sensors both for Memory: Physical Memory and Memory: Virtual Memory it will only create the sensor for Memory: Physical Memory.

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.