PRTG Manual: Define Lookups
PRTG uses lookups for some sensor types with custom channels. In general, lookups map status values as returned by a device (usually integers) to more informative expressions that show you the status of a monitored device as a clear message. Additionally, lookups can define the sensor status that will be shown for certain status codes (similar as sensor channel limits can define a sensor status, too). For example, for a printer, PRTG can show a sensor in a yellow Warning status with channel values like "Toner Low" instead of simple status codes.
Lookups can be customized individually; you can define your own texts that will be shown in a sensor's channel.
Note: Lookups do not change data in PRTG's database, but they merely change the way sensor channels are shown. Any change to lookup definition files will apply to historic as well as live data.
Lookups Directory and Format
Lookups are defined in XML format in files ending in .ovl. PRTG's standard lookup files are located in the PRTG program directory in a sub folder named lookups. These files are maintained by PRTG itself. In each of the files lookups are defined for one or more sensors. Furthermore, the lookups folder contains a sub folder named custom to store your customized lookups.
The files follow a basic principle: For each numeric value you can define:
- A message that will be looked up and shown instead of the value
- The status the sensor will show
Example
The following code illustrates the lookup definition for the toner status of the SNMP HP LaserJet Hardware sensor:
<?xml version="1.0" encoding="UTF-8"?>
<ValueLookup id="oid.paessler.hplaserjet.tonerstatus" Primary="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
<Lookups>
<SingleInt state="Ok" value="0">
Toner Okay
</SingleInt>
<SingleInt state="Warning" value="1">
Toner Low
</SingleInt>
<SingleInt state="Error" value="2">
No Toner Cartridge Loaded
</SingleInt>
</Lookups>
</ValueLookup>
The schema in the example provides an insight how lookups are defined:
- The <?xml> tag in the first line defines the content as XML.
- The <ValueLookup> tag in the second line contains:
- The ID which will be shown in the Sensor Channels Settings.
- The Primary attribute contains the value which will be used for the calculation of the "Coverage". In this example, 1 is defined.
- The xsi attributes refer to PRTG's predefined XML schema definitions (which allow easy editing of lookup files with supported editors). We recommend using the default value.
- Between the tags <Lookups> and </Lookups> the particular lookups for the sensor data are defined:
- A lookup entry starts with a tag containing the type of the status value, the lookup type (in this example, this is always <SingleInt>).
- Separated by whitespace, the state attribute defines the status the sensor will show. Allowed values are: Ok, Warning, Error, and None ("None" will trigger no status change).
- The value attribute defines which numeric value will trigger the lookup. This is the value that PRTG will receive from the device.
- The text defines the substitution text that will be shown instead of the value. For example, a status message.
- The same way all other possible lookups are defined. The lookup definitions are closed by the tag </Lookups>. The file closes with </ValueLookup>.
In our example, the lookup file will have the following effect:
Value as Reported from HP Printer |
Value Shown in PRTG (Sensor Channel) |
Sensor Status Shown by PRTG |
|
0 |
Toner Okay |
Up |
|
1 |
Toner Low |
Warning |
|
2 |
No Toner Cartridge Loaded |
Down |
The XML Schema
An overall schema of the XML files containing the lookups definitions can be sketched like this:
<?xml version="1.0" encoding="UTF-8"?>
<ValueLookup id="..." primary="..." xmlns="..." xsi="...">
<Lookups>
<LookupType state="..." value="...">
status text
</LookupType>
[several other lookup definitions]
</Lookups>
</ValueLookup>
Element |
Description |
Attributes, Value Assignment, and Content |
<?xml> |
This is the XML declaration. Every XML file begins with it. |
|
<ValueLookup> |
Defines the ID of the channel, what primary is used, and links to PRTG's predefined schema definitions, which allow easy editing of lookup files with supported editors. |
|
<Lookups> |
Defines the particular lookups for the sensor data. |
|
<LookupType> |
Defines a lookup entry. Several other entries in this form can follow. The LookupType is either SingleInt, BitFieldType, or Range. |
|
Since all the XML files containing lookup definitions are delivered in a pre-given schema as indicated above, it will be easy and comprehensible for you to customize lookups.
Customizing Lookups
There is a subfolder named lookups\custom located in the PRTG program directory. To customize lookups copy the desired lookup file from the lookups folder to the custom folder or create a new file there. When using the same ID in the ValueLookup tag, the files in the lookups\custom folder have a higher priority than the original files in the lookups folder. This way, your customizations will be handled preferably by PRTG instead of the original lookup settings.
Open the file with an XML editor and edit the lookups following your personal preferences. You can define your own messages as well as you can customize sensor states for the particular return values. For example, if you do not want an "Error" status (i.e. a sensor Down status) for the return value "2" but only a warning, then you can replace "Error" with "Warning".
Note: The possible states are given in the LookupState.xsd file in the custom directory. Following the schema of the XML files that are delivered with PRTG enables you to edit the lookups in a safe way.
It is necessary to define a "primary value" called Primary in the lookup files. The primary value corresponds to a status value triggering a lookup. PRTG calculates the percentage of time this specific state has been monitored. The result is displayed for all data tables and graphs that show averaged values.
Considering the example above where the primary is "1", PRTG will calculate the percentage of time the toner status has been "Warning". If in a time span of five minutes four of five sensor scans returned a "Warning" status, PRTG would show an average of 80% for this time span, because in 80% of the time the sensor showed a "Warning".
Lookup Types: SingleInt, BitFieldType, Range
Beside the lookup type SingleInt as seen above, there are two other lookup types: BitFieldType and Range. Using these types you can define lookup values beyond simple integers.
Lookup Type |
Description |
Syntax |
SingleInt |
Uses an integer to define a lookup for one status value. |
value="int" |
BitFieldType |
Uses a bitfield for multiple status values. |
Should only be used if you have basic knowledge about bitmasks. Please see More below for a general introduction. |
Range |
Uses an inter range from-to to define a lookup for several status values. |
from="int" to="int" |
Note: You can use only one kind of lookup type in one lookup file. For example, only SingleInts, BitFieldTypes, or Ranges. Different lookup types in one file are not allowed.
Define Lookup Files in Sensor Channel Settings
For each sensor with a custom channel you can define a lookup file that will be used. This is done in a sensor's channel settings with an option called "Value Lookup". This option is visible for many SNMP sensors, some application sensors, and always for the following sensor types:
- EXE/Script Sensor
- EXE/Script Advanced Sensor (if a Custom unit is defined)
- SNMP Custom Sensor
For details, please see the Sensor Channel Settings section.
Loading Lookups
You can (re)load the defined lookups in the custom folder by clicking the Load Lookups button. This button can be found in PRTG under Setup | System Administration | Administrative Tools.
Debugging--What will happen if...?
- A return value is defined in the lookups that never will be returned by a device because the value is not assigned: The value will never be triggered, so PRTG will simply ignore this entry.
- PRTG receives a return value that is not defined for lookups: No substituion message can be found. PRTG will just show the return value.
- Different lookup types are in one lookup file: This is not allowed. PRTG will not consider different types.
Wikipedia: Masks (computing)
Keywords: Lookups,SNMP,SNMP Lookups,Value Mapping,Value Mapping Lookups