Advanced Custom PRTG MAP Objects

UTM advanced guide to custom map object

If you are not familiar with the basic structure of a map object, jump over to our Basic Guide to map objects.

 

In this guide, we will go over some more advanced tag names. This is intended to get you started making your own map objects based on pre-existing PRTG objects. The aim is to copy a map object that is similar to what you need to customise and understand the structure, concept and tag names.

 

Lets look at UTM’s “OK, Warning, Down & Pause” object map. This was originally created form the “Status Icons: Traffic light” map object.

Map Object Placeholders

Below is the full htm file of the “OK, Warning, Down & Pause”  map object.  We start by renaming the map object to “NetworkTools OWDP Status”. We will go over the code after the <#mapobject type=”htmlbefore” subid=”<@subid>”> which was covered in the basic guide. 

<!--Custom: UTM OWDP Status-->

<div class="map_object" id="<@itemid>" objectid="<@objectid>" subid="<@subid>" style="<#mapobject type="coordinates" subid="<@subid>" mode="<@editmode>">">
  <#mapobject type="objectgrip" mode="<@editmode>">
  <#mapobject type="htmlbefore" subid="<@subid>">
  
  <#sensor type="colorclassofstate" id="<@objectid>" var="status">
  <#objectproperty type="nodename" id="<@objectid>" var="nodename">
  <#if value="@nodename" is="sensor" then="sensr" else="hasred" varexpand="value" var="containsred">
  <#if value="@nodename" is="sensor" then="sensy" else="hasyellow hasnored" varexpand="value" var="containsyellow">
  <#if value="@nodename" is="sensor" then="sensg" else="hasgreen hasnoyellow hasnored" varexpand="value" var="containsgreen">
  <#if value="@nodename" is="sensor" then="sensb" else="hasblue hasnogreen hasnoyellow hasnored" varexpand="value" var="containsblue">
  

  <#if value="@status" contains="@containsred" then="<p style='color:red;font-weight: bold;font-size: 42px'>Down</p>" else="" varexpand="value,contains">
  <#if value="@status" contains="@containsyellow" then="<p style='color:orange;font-weight: bold;font-size: 42px'>Warning</p>" else="" varexpand="value,contains">
  <#if value="@status" contains="@containsgreen" then="<p style='color:green;font-weight: bold;font-size: 42px'>OK</p>" else="" varexpand="value,contains">
  <#if value="@status" contains="@containsblue" then="<p style='color:blue;font-weight: bold;font-size: 42px'>Pause</p>" else="" varexpand="value,contains">
  
  <div style="position:relative;margin-top:-20%">

    <#mapobject type="htmlafter" subid="<@subid>">
  </div>
</div> 

Get the object status

We create a “status” variable with the sensor’s “colorclassofstate”

 

If the object is not a sensor, for example it’s a device or group, the result is a value such as “hasnored hasnopartialred hasnoack hasnoyellow hasnoorange hasnoblack hasblue hasnogreen

 

If the object is a sensor the result is one of

 

  • sensg (Green)
  • sensy  (Yellow)
  • sensr (Red)
  • sensb (Blue)
  • senso (Acknowledge) 
  • sensp (Orange)
  • sensx (Black/Unknown)
  <#sensor type="colorclassofstate" id="<@objectid>" var="status"> 
  <#objectproperty type="nodename" id="<@objectid>" var="nodename"> 

We create a “nodename” variable from the sensor’s objectproperty.

 

The values returns one of the following: 

  • group
  • probenode
  • device
  • sensor
  <#if value="@nodename" is="sensor" then="sensr" else="hasred" varexpand="value" var="containsred">
  <#if value="@nodename" is="sensor" then="sensy" else="hasyellow hasnored" varexpand="value" var="containsyellow">
  <#if value="@nodename" is="sensor" then="sensg" else="hasgreen hasnoyellow hasnored" varexpand="value" var="containsgreen">
  <#if value="@nodename" is="sensor" then="sensb" else="hasblue hasnogreen hasnoyellow hasnored" varexpand="value" var="containsblue"> 

If the nodename = sensor then we know the colour status, sensor etc, otherwise we need to check if the group, probenode or device has a specific status. 

 

We write this to a variable depending on the status 

 

  • containsred
  • containsyellow
  • containsgreen
  • containsblue

Display the status and colour.

<#if value="@status" contains="@containsred" then="<p style='color:red;font-weight: bold;font-size: 42px'>Down</p>" else="" varexpand="value,contains">
<#if value="@status" contains="@containsyellow" then="<p style='color:orange;font-weight: bold;font-size: 42px'>Warning</p>" else="" varexpand="value,contains">
<#if value="@status" contains="@containsgreen" then="<p style='color:green;font-weight: bold;font-size: 42px'>OK</p>" else="" varexpand="value,contains">
<#if value="@status" contains="@containsblue" then="<p style='color:blue;font-weight: bold;font-size: 42px'>Pause</p>" else="" varexpand="value,contains"> 

With simple if statements, we check if the status variable we got earlier contains the values in our contains color variables. 

If @status contains the value in the @containsred variable.  Display: Down

If @status contains the value in the @containsyellow variable.  Display: Warning

If @status contains the value in the @containsgreen variable.  Display: OK

If @status contains the value in the @containsblue variable.  Display: Pause


We have not taken into account unknows/black or unusual/orange status.