Hello everyone,

i want to create a custom object that shows RX and TX values of a SNMP traffic sensor. I already created the object, but how do I get the data for the RX and TX values?

As I can see from the api guide this must somehow be done with json. What is to do to accomplish this task?

This are the channels I'd like to read out and show:

<value channel="Datenverkehr eingehend (Geschwindigkeit)" channelid="0">1 Mbit/Sek.</value>

<value channel="Datenverkehr ausgehend (Geschwindigkeit)" channelid="1">3 Mbit/Sek.</value>

This is the object which I created:

<!--Custom Icons: Sensor Statistiken RX-/TX-->

<div align="center" class="map_object" id="<@itemid>" objectid="<@objectid>" subid="<@subid>" style="<#mapobject type="topleftcoordinates" subid="<@subid>" mode="<@editmode>">"> <#checkobjecttype objecttype="sensor" nicemessage="true" id="<@objectid>"> <#mapobject type="objectgrip" mode="<@editmode>"> <#mapobject type="htmlbefore" subid="<@subid>"> <h2><b><u><#objectproperty name="ParentDevice" show="text" id="<@objectid>"></b></u></h2> <p><#objectproperty name="Name" id="<@objectid>"></p> <#objectstatus name="downsens" id="<@objectid>"> <p> <b>RX:</b> <#objectstatus name="lastvalue" id="<@objectid>"> <br> <b>TX:</b> <#objectstatus name="lastvalue" id="<@objectid>"> </p>

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


Article Comments

Hello,

thank you very much for using PRTG. I'm very much afraid this is not possible. Map Objects can only access the value of the one Primary Channel of a sensor. Please instead consider placing a graph of the sensor in question onto the map as well. to see the values of all channels.

best regards.


Aug, 2014 - Permalink

Hello,

I found a solution myself.

I updated the "jquery.js" in "webroot/javascript/lib" to the latest version and builded the following map object:

<div align="center" class="map_object" id="<@itemid>" objectid="<@objectid>" subid="<@subid>" style="<#mapobject type="topleftcoordinates" subid="<@subid>" mode="<@editmode>">">
<#checkobjecttype objecttype="sensor" nicemessage="true" id="<@objectid>">
<#mapobject type="objectgrip" mode="<@editmode>">
<#mapobject type="htmlbefore" subid="<@subid>">
  <h2><b><u><#objectproperty name="ParentDevice" show="text" id="<@objectid>"></b></u></h2>
  <p><#objectproperty name="Name" id="<@objectid>"></p>
  <#objectstatus name="downsens" id="<@objectid>">
  
  <div id="dvContent"></div>
  
<script>
$(document).ready(function(){
  $.ajax({
    type: "GET",
    url: "https://URL_OF_YOUR_PRTG_SERVER/api/table.xml?content=values&output=xml&columns=datetime,value_,coverage&count=1&id=<@objectid>",
    dataType: "xml",
    success: function(xml){
    $(xml).find('item').each(function(){
      var sRX = $(this).find('value[channel="Eingehend (Geschwindigkeit)"]').text();
	  var sTX= $(this).find('value[channel="Ausgehend (Geschwindigkeit)"]').text();
      $("<p></p>").html("<b>RX:</b> " + sRX).appendTo("#dvContent");
	  $("<p></p>").html("<b>TX:</b> " + sTX).appendTo("#dvContent");
    });
  },
  error: function() {
    alert("An error occurred while processing XML file.");
  }
  });
});
</script>
  
  <#mapobject type="htmlafter" subid="<@subid>">
</div>

Yet this just works for one sensor, I think it's because of the "id=<@objectid>" in "url:", but I think this should give everyone a basic idea how to accomplish this.


Aug, 2014 - Permalink

Could you please delete the URL in the post I sent after my initial one? Thank you really much.


Aug, 2014 - Permalink