neuralfraud / grafana-prtg

A PRTG Datasource plugin for Grafana
179 stars 75 forks source link

Sensor Factory - SingleStat Panel reports same value for all channels #119

Open SoarinFerret opened 5 years ago

SoarinFerret commented 5 years ago

The Problem

Trying to pull different channels from the same factory sensor, all return with the exact same data when using the SingleStat panel. I have seen these issues, #65 and #78, but the work around on those did not seem to work for me.

Anyone have any ideas on how I could alter the metrics query below to accommodate this? Otherwise, I might make a pull request trying to fix it if I can hack something together, but I am not particularly great at JavaScript.

Additional Details

I'm monitoring a Hyper-V Failover Cluster with PRTG. I have SNMP CPU and SNMP Physical Memory sensors on each node in the cluster, but since I would like to monitor them as a group instead of individually, I used a Sensor Factory sensor to total up all the results.

Query URL:

"api/datasources/proxy/1/historicdata.xml?username=removed&passhash=00000000&id=6245&sdate=2018-12-13-16-24-53&edate=2018-12-13-16-29-53&avg=0&pctshow=false&pctmode=false"

Response Data:

"<?xml version="1.0" encoding="UTF-8"?>
 <histdata totalcount="5" listend="1">
 <prtg-version>18.3.43.2323</prtg-version>
 <item>
 <datetime>12/13/2018 4:24:53 PM</datetime>
 <datetime_raw>43447.9339467593</datetime_raw>
 <value channel="Total CPU Usage" channelid="1"/>
 <value channel="Percent Available Memory" channelid="2"/>
 <value channel="Total Memory Available" channelid="3"/>
 <value channel="Total Cluster Memory" channelid="4"/>
 <coverage>0 %</coverage>
 <coverage_raw>0000000000</coverage_raw>
 </item>
 <item>
 <datetime>12/13/2018 4:25:53 PM</datetime>
 <datetime_raw>43447.9346412037</datetime_raw>
 <value channel="Total CPU Usage" channelid="1">1 %</value>
 <value_raw channel="Total CPU Usage" channelid="1">1.2500</value_raw>
 <value channel="Percent Available Memory" channelid="2">32 %</value>
 <value_raw channel="Percent Available Memory" channelid="2">32.3102</value_raw>
 <value channel="Total Memory Available" channelid="3">169,274 MByte</value>
 <value_raw channel="Total Memory Available" channelid="3">177496522752.0000</value_raw>
 <value channel="Total Cluster Memory" channelid="4">523,899 MByte</value>
 <value_raw channel="Total Cluster Memory" channelid="4">549348179968.0000</value_raw>
 <coverage>100 %</coverage>
 <coverage_raw>0000010000</coverage_raw>
 </item>
 <item>
 <datetime>12/13/2018 4:26:53 PM</datetime>
 <datetime_raw>43447.9353356482</datetime_raw>
 <value channel="Total CPU Usage" channelid="1">1 %</value>
 <value_raw channel="Total CPU Usage" channelid="1">1.0000</value_raw>
 <value channel="Percent Available Memory" channelid="2">32 %</value>
 <value_raw channel="Percent Available Memory" channelid="2">31.9082</value_raw>
 <value channel="Total Memory Available" channelid="3">167,168 MByte</value>
 <value_raw channel="Total Memory Available" channelid="3">175287894016.0000</value_raw>
 <value channel="Total Cluster Memory" channelid="4">523,899 MByte</value>
 <value_raw channel="Total Cluster Memory" channelid="4">549348179968.0000</value_raw>
 <coverage>100 %</coverage>
 <coverage_raw>0000010000</coverage_raw>
 </item>
 <item>
 <datetime>12/13/2018 4:27:53 PM</datetime>
 <datetime_raw>43447.9360300926</datetime_raw>
 <value channel="Total CPU Usage" channelid="1">2 %</value>
 <value_raw channel="Total CPU Usage" channelid="1">2.0000</value_raw>
 <value channel="Percent Available Memory" channelid="2">32 %</value>
 <value_raw channel="Percent Available Memory" channelid="2">31.9066</value_raw>
 <value channel="Total Memory Available" channelid="3">167,159 MByte</value>
 <value_raw channel="Total Memory Available" channelid="3">175279374336.0000</value_raw>
 <value channel="Total Cluster Memory" channelid="4">523,899 MByte</value>
 <value_raw channel="Total Cluster Memory" channelid="4">549348179968.0000</value_raw>
 <coverage>100 %</coverage>
 <coverage_raw>0000010000</coverage_raw>
 </item>
 <item>
 <datetime>12/13/2018 4:28:53 PM</datetime>
 <datetime_raw>43447.9367245370</datetime_raw>
 <value channel="Total CPU Usage" channelid="1">1 %</value>
 <value_raw channel="Total CPU Usage" channelid="1">1.2500</value_raw>
 <value channel="Percent Available Memory" channelid="2">32 %</value>
 <value_raw channel="Percent Available Memory" channelid="2">31.9058</value_raw>
 <value channel="Total Memory Available" channelid="3">167,155 MByte</value>
 <value_raw channel="Total Memory Available" channelid="3">175275048960.0000</value_raw>
 <value channel="Total Cluster Memory" channelid="4">523,899 MByte</value>
 <value_raw channel="Total Cluster Memory" channelid="4">549348179968.0000</value_raw>
 <coverage>100 %</coverage>
 <coverage_raw>0000010000</coverage_raw>
 </item>
 </histdata>"

Screenshots

Ignore the fact that the first two sensors data is slightly different, I just didn't screenshot them in time.

SingleStat Panel Trying to Pull Memory Usage as a Percentage:

image

SingleStat Panel Trying to Pull Memory Usage in MB:

image

Dashboard showing all values being the same

image

mizike2 commented 5 years ago

I am having the same issue. All the channels in Grafana show the same results of only Channel #1.

SoarinFerret commented 5 years ago

I ended up created separate factory sensors for each channel. Not ideal, but its what I have working right now.

I started working on a fork of this that I intended to submit as a pull request, but I'm not terribly proficient in JavaScript and am having issues getting it all working properly. Also, not going to lie, haven't looked at it in awhile either.

I'll update here if I ever get anywhere with it

bkeifer commented 5 years ago

+1 on this. Creating tons of factories is getting, shall we say... old. =)