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

If then else statements on maps

Votes:

0

I'd like to hide my sensors on my map when they are green and have them show up when yellow or red when not in edit mode

Here's an example that works for both edit mode and viewing mode:

<#sensor type="colorclassofstate" id="<@objectid>" var="status">
  <#objectproperty type="nodename" id="<@objectid>" var="nodename">
<p style="<#if value="@status" contains="@containsred" then="font-size:20;" else="display:none" varexpand="value,contains">" text-anchor="middle">this text only shows when red</p>

What I'd love to do, is check if we are in edit mode and therefore always show the text. If we're not in edit mode, only show when red; so pseudocode it would look like: if edit mode then display the text else if sensor is red (or yellow)then display the text

or we could write the last line above as (preferably) if sensor isn't green, then display the text

That way, I can design the map just fine and always see my text. But then when it's actually on display for end users, the text only shows up when there is an alert

Can't find much in the documentation about the if then else stuff nor whether i can use the <@editmode> variable in some way

thanks!

custom-map-object map-designer maps maps-editor prtg

Created on Jul 5, 2018 4:57:44 AM

Last change on Jul 5, 2018 10:04:19 AM by  Stephan Linke [Paessler Support]



5 Replies

Votes:

0

Why not use the alarm table and filter it for the corresponding tree node, depending on the customer/end user group? :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 5, 2018 12:38:05 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

That would work but when there are no alarms it would just be a blank white box. Basically at the moment I have a background picture of an aerial view of our campus which is in colour. It would be nice to just have the aerial view there until there was a fault at which point we could have a box or traffic light with text show up. If I have the alarms table it would have the white box over the top of the background all the time

Is there any documentation for the if then else clauses and or anything I could reference as to what variables are made available?

Created on Jul 6, 2018 12:10:41 AM



Votes:

0

I'm pretty certain that we cannot discern between being in edit and live mode. How about using Grafana?


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 6, 2018 7:06:48 AM by  Stephan Linke [Paessler Support]



Votes:

0

All good I figured it out. Here's how I did for those that may stumble across this

Here's a background color status related sensor:

<!--Custom Map Objects: Sensor (status-related background)-->
<div class="map_object map_icon2 map_icon_large <#sensor type="colorclassofstate" prefix="map_iconcolor_" id="<@objectid>">" id="<@itemid>" objectid="<@objectid>" subid="<@subid>" style="<#mapobject type="coordinates" subid="<@subid>" mode="<@editmode>">">
	<#mapobject type="objectgrip" mode="<@editmode>">
	<#mapobject type="htmlbefore" subid="<@subid>">
  <#checkobjecttype objecttype="sensor" nicemessage="true" id="<@objectid>">

  <div style="display:block;width:<@width>px;height:<@height>px;border:2px solid black;padding-top:2px"><span class="label"><#objectproperty name="Name" id="<@objectid>"></span></div>
  


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

Now simply add in the following javascript in the empty block above:

<script type="text/javascript"><![CDATA[
	var editmode="<@editmode>";
	if (editmode !== "edit") {
		
		var element = document.getElementById("<@itemid>");
		element.parentNode.removeChild(element);
		
	}
	]]>
</script> 

so it will now look like this:

<!--Custom Map Objects: Sensor (status-related background)-->
<div class="map_object map_icon2 map_icon_large <#sensor type="colorclassofstate" prefix="map_iconcolor_" id="<@objectid>">" id="<@itemid>" objectid="<@objectid>" subid="<@subid>" style="<#mapobject type="coordinates" subid="<@subid>" mode="<@editmode>">">
	<#mapobject type="objectgrip" mode="<@editmode>">
	<#mapobject type="htmlbefore" subid="<@subid>">
  <#checkobjecttype objecttype="sensor" nicemessage="true" id="<@objectid>">

  <div style="display:block;width:<@width>px;height:<@height>px;border:2px solid black;padding-top:2px"><span class="label"><#objectproperty name="Name" id="<@objectid>"></span></div>
  <script type="text/javascript"><![CDATA[
	var editmode="<@editmode>";
	if (editmode !== "edit") {
		var element = document.getElementById("<@itemid>");
		element.parentNode.removeChild(element);	
	}
	]]></script> 
  <#mapobject type="htmlafter" subid="<@subid>">
</div>

This will then remove the green status related sensors when in view mode only. That way you can see them properly in edit mode and they hide away when on a display

Created on Jul 9, 2018 7:03:08 AM

Last change on Jul 10, 2018 4:34:09 AM by  Sven Roggenhofer [Paessler Technical Support]



Votes:

0

Thanks for sharing :)

Created on Jul 9, 2018 7:11:09 AM by  Stephan Linke [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.