<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GetAvgDCIValue not working?]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">I've tried to get an average value for the last 3600 seconds (1 hour) of my temperature sensor, but it doesn't seem like the GetAvgDCIValue is returning the value that I'm expecting. I've more or less copied the example from the <a href="http://wiki.netxms.org/wiki/NXSL:GetAvgDCIValue" rel="nofollow ugc">wiki</a> and made a few adjustments.</p>
<p dir="auto">I've made a dummy DCI with the following transformation script that runs every 60 seconds:</p>
<pre><code>sub main()
{
   startTime = time() - 3600;
   return GetAvgDCIValue(FindObject("TEMPNODE01"), 176, startTime, time());
}
</code></pre>
<p dir="auto">The average value that GetAvgDCIValue is returning is between: 1 and 2, while the temperature DCI (integer) has values between 80 and 200 during that hour, which in my world also should return an average value in that range.</p>
<p dir="auto">I appreciate any help you can give on this.</p>
<p dir="auto">// Anders</p>
]]></description><link>https://forum.netxms.org/topic/1879/getavgdcivalue-not-working</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 18:51:12 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/1879.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Aug 2012 06:26:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 11 Oct 2013 13:36:28 GMT]]></title><description><![CDATA[<pre><code>mysql&gt; SELECT * FROM idata_134 WHERE item_id=26;
+---------+-----------------+-------------+
| item_id | idata_timestamp | idata_value |
+---------+-----------------+-------------+
|      26 |      1381494998 | 22          |
|      26 |      1381495238 | 22          |
|      26 |      1381495478 | 22          |
|      26 |      1381495718 | 22          |
|      26 |      1381495958 | 22          |
|      26 |      1381496198 | 22          |
|      26 |      1381496438 | 22          |
|      26 |      1381496678 | 22          |
|      26 |      1381496918 | 22          |
|      26 |      1381497158 | 22          |
|      26 |      1381497398 | 22          |
|      26 |      1381497638 | 22          |
|      26 |      1381497878 | 22          |
|      26 |      1381498118 | 22          |
+---------+-----------------+-------------+
14 rows in set (0.00 sec)
</code></pre>
<pre><code>mysql&gt; SELECT avg(coalesce(idata_value,0)) FROM idata_134 WHERE item_id=26 and idata_timestamp between 1381494998 and 1381497638;
+------------------------------+
| avg(coalesce(idata_value,0)) |
+------------------------------+
|                           22 |
+------------------------------+
1 row in set (0.00 sec)
</code></pre>
<p dir="auto">Script:</p>
<pre><code>startTime = 1381494998;
stopTime = 1381497638;
object = FindNodeObject(null,"TERM1");
trace(0, "*** VALUE: " . GetAvgDCIValue(object, FindDCIByDescription(object,"npThermoValue"), startTime, stopTime));
trace(0, "*** MAX: " . GetMaxDCIValue(object, FindDCIByDescription(object,"npThermoValue"), startTime, stopTime));
trace(0, "*** MIN: " . GetMinDCIValue(object, FindDCIByDescription(object,"npThermoValue"), startTime, stopTime));
</code></pre>
<p dir="auto">Result:</p>
<pre><code>[11-Oct-2013 17:34:24.413] [INFO ] *** VALUE: 2.000000
[11-Oct-2013 17:34:24.414] [INFO ] *** MAX: 22.000000
[11-Oct-2013 17:34:24.414] [INFO ] *** MIN: 22.000000
</code></pre>
]]></description><link>https://forum.netxms.org/post/11517</link><guid isPermaLink="true">https://forum.netxms.org/post/11517</guid><dc:creator><![CDATA[wonderboy]]></dc:creator><pubDate>Fri, 11 Oct 2013 13:36:28 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 11 Oct 2013 13:14:07 GMT]]></title><description><![CDATA[<p dir="auto">So strange... Can you please post actual results from SQL query and some plain values (with all spaces, etc. - I suppose that maybe results are parsed incorrectly)?</p>
]]></description><link>https://forum.netxms.org/post/11516</link><guid isPermaLink="true">https://forum.netxms.org/post/11516</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 11 Oct 2013 13:14:07 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 11 Oct 2013 11:06:03 GMT]]></title><description><![CDATA[<p dir="auto">I've made dummy internal integer dci with random numbers and it's working fine.</p>
]]></description><link>https://forum.netxms.org/post/11515</link><guid isPermaLink="true">https://forum.netxms.org/post/11515</guid><dc:creator><![CDATA[wonderboy]]></dc:creator><pubDate>Fri, 11 Oct 2013 11:06:03 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 11 Oct 2013 10:03:19 GMT]]></title><description><![CDATA[<pre><code>startTime = time() - 3600;
trace(0, "*** TIME: " . startTime);
object = FindNodeObject(null,"log1");

trace(0, "*** VALUE: " . GetAvgDCIValue(object, FindDCIByDescription(object,"Total number of threads"), startTime, time()));
trace(0, "*** MAX: " . GetMaxDCIValue(object, FindDCIByDescription(object,"Total number of threads"), startTime, time()));
trace(0, "*** MIN: " . GetMinDCIValue(object, FindDCIByDescription(object,"Total number of threads"), startTime, time()));
</code></pre>
<p dir="auto">It's interested to note that MAX and MIN are showing correct numbers, however GetAvg still results to strange</p>
<pre><code>[11-Oct-2013 14:00:55.172] [INFO ] *** TIME: 1381482055
[11-Oct-2013 14:00:55.173] [INFO ] *** VALUE: 4.000000
[11-Oct-2013 14:00:55.173] [INFO ] *** MAX: 369.000000
[11-Oct-2013 14:00:55.174] [INFO ] *** MIN: 359.000000
</code></pre>
<p dir="auto">PS. I did direct Mysql query like you provided above and result was good value.</p>
]]></description><link>https://forum.netxms.org/post/11511</link><guid isPermaLink="true">https://forum.netxms.org/post/11511</guid><dc:creator><![CDATA[wonderboy]]></dc:creator><pubDate>Fri, 11 Oct 2013 10:03:19 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 11 Oct 2013 08:49:02 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">That's very strange. I just install MySQL 5.1 server, create new database, create dummy DCI of type "integer" with transformation script</p>
<pre><code>return 22;
</code></pre>
<p dir="auto">If I run the following script from console:</p>
<pre><code>startTime = time() - 1800;
object = FindNodeObject(null,"HP8570W");
trace(0, "*** VALUE: " . GetAvgDCIValue(object, FindDCIByDescription(object,"TEST"), startTime, time()));
</code></pre>
<p dir="auto">I got expected results:</p>
<pre><code>netxmsd: exec avg
[11-Oct-2013 11:46:17.797] [INFO ] *** VALUE: 22.000000
INFO: Script finished with rc=0
</code></pre>
<p dir="auto">Can you re-test it with some another DCI?</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/11505</link><guid isPermaLink="true">https://forum.netxms.org/post/11505</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 11 Oct 2013 08:49:02 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Thu, 10 Oct 2013 14:02:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi!<br />
After one year passed, the problem still exist.</p>
<pre><code>startTime = time() - 1800;
object = FindNodeObject(null,"TERM1");
trace(0, "*** VALUE: " . GetAvgDCIValue(FindNodeObject(null,"TERM1"), FindDCIByDescription(FindNodeObject(null,"TERM1"),"npThermoValue"), startTime, time()));
</code></pre>
<p dir="auto">All DCI values in history are 22  (integer).</p>
<p dir="auto">And the script output is:</p>
<pre><code>*** VALUE: 2.000000
</code></pre>
]]></description><link>https://forum.netxms.org/post/11500</link><guid isPermaLink="true">https://forum.netxms.org/post/11500</guid><dc:creator><![CDATA[wonderboy]]></dc:creator><pubDate>Thu, 10 Oct 2013 14:02:59 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 31 Aug 2012 04:59:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">It seems like there is some sort of issue between NetXMS and MySQL, the output I get after executing the script is:</p>
<blockquote>
<p dir="auto">*** VALUE: 1.000000</p>
</blockquote>
<p dir="auto">Regards</p>
<p dir="auto">Anders</p>
]]></description><link>https://forum.netxms.org/post/8306</link><guid isPermaLink="true">https://forum.netxms.org/post/8306</guid><dc:creator><![CDATA[Anders]]></dc:creator><pubDate>Fri, 31 Aug 2012 04:59:01 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Thu, 30 Aug 2012 12:03:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">I test this on Oracle and PostgreSQL - everything works as expected. Now I want to try this on MySQL.<br />
You can try to create script in script library which will print received values to log:</p>
<pre><code>startTime = time() - 3600;
trace(0, "*** VALUE: " . GetAvgDCIValue(FindObject("TEMPNODE01"), 176, startTime, time()));
</code></pre>
<p dir="auto">and run it from server's console with exec command. What value it will show in log?</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/8297</link><guid isPermaLink="true">https://forum.netxms.org/post/8297</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Thu, 30 Aug 2012 12:03:57 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Thu, 30 Aug 2012 06:48:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">Sorry for nagging, I'm just curious to know if you can see any solution to my problem, or if I can assist with some additional data / information to solve this problem?</p>
<p dir="auto">Regards</p>
<p dir="auto">Anders</p>
]]></description><link>https://forum.netxms.org/post/8294</link><guid isPermaLink="true">https://forum.netxms.org/post/8294</guid><dc:creator><![CDATA[Anders]]></dc:creator><pubDate>Thu, 30 Aug 2012 06:48:37 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Fri, 24 Aug 2012 11:43:23 GMT]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">Sorry for the delay. I'm running a MySQL 5.1 server. I tried to execute the SQL query that you suggested and the result is: 104.7 which seems to be about the result that I'm expecting.</p>
<p dir="auto">Regards</p>
<p dir="auto">Anders</p>
]]></description><link>https://forum.netxms.org/post/8247</link><guid isPermaLink="true">https://forum.netxms.org/post/8247</guid><dc:creator><![CDATA[Anders]]></dc:creator><pubDate>Fri, 24 Aug 2012 11:43:23 GMT</pubDate></item><item><title><![CDATA[Reply to GetAvgDCIValue not working? on Wed, 22 Aug 2012 15:22:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">What database you are using? Basically all that GetAvgDCIValue does is SQL query like this:</p>
<p dir="auto">SELECT avg(coalesce(idata_value,0)) FROM idata_&lt;node_id&gt; WHERE item_id=&lt;dci_id&gt; and idata_timestamp between &lt;time_from&gt; and &lt;time_to&gt;</p>
<p dir="auto">If possible, try to run such query by hand and check the output for correctness.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/8216</link><guid isPermaLink="true">https://forum.netxms.org/post/8216</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Wed, 22 Aug 2012 15:22:26 GMT</pubDate></item></channel></rss>