<?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[Tranform and Condition Scripts]]></title><description><![CDATA[<p dir="auto">Hi Guys,</p>
<p dir="auto">I was wondering if anyone could share a non-trivial script for the DCI transform or the condition.<br />
Based on the formal declaration of NXSL i can only get basic expressions and function calls to work.  If i define a function or use any if, switch statements the script seems to not function.</p>
<p dir="auto">I imagine that i must be doing something wrong but any help would be appreciated.</p>
<p dir="auto">For example in the condition script i'm trying to do something like:</p>
<p dir="auto">if ($1&gt;5) return min($2, $3);</p>
<p dir="auto">Another issue i've encountered is using the PDH.countervalue for data collection.  This seems to work fine for some counters but not others.</p>
<p dir="auto">I tried: '\Memory\Committed Bytes' and this seems to work just fine<br />
but when i tried<br />
'\PhysicalDisk(_Total)\Disk Write Bytes/sec' this always returns 0.</p>
<p dir="auto">if anyone can shed some light on this, that would great.</p>
<p dir="auto">-mike</p>
]]></description><link>https://forum.netxms.org/topic/88/tranform-and-condition-scripts</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 09:43:57 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/88.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 10 Aug 2007 01:44:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tranform and Condition Scripts on Thu, 28 May 2009 07:53:23 GMT]]></title><description><![CDATA[<p dir="auto">Yes, you can use extended form of PDH.CounterValue:</p>
<p dir="auto"><strong>PDH.CounterValue("counter name",1)</strong></p>
<p dir="auto">If second argument is present in PDH.CounterValue and set to non-zero, then agent will get two samples with 1 second interval, and use them to calculate resulting value.</p>
]]></description><link>https://forum.netxms.org/post/3015</link><guid isPermaLink="true">https://forum.netxms.org/post/3015</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Thu, 28 May 2009 07:53:23 GMT</pubDate></item><item><title><![CDATA[Reply to Tranform and Condition Scripts on Wed, 27 May 2009 14:13:06 GMT]]></title><description><![CDATA[<p dir="auto">Is it possible to use other multi-sample counters (like "\PhysicalDisk(_Total)\Disk Write Bytes/sec") via interface, not via client's config?</p>
]]></description><link>https://forum.netxms.org/post/3006</link><guid isPermaLink="true">https://forum.netxms.org/post/3006</guid><dc:creator><![CDATA[Anth0ny]]></dc:creator><pubDate>Wed, 27 May 2009 14:13:06 GMT</pubDate></item><item><title><![CDATA[Reply to Tranform and Condition Scripts on Fri, 10 Aug 2007 16:37:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jdlds" aria-label="Profile: jdlds">@<bdi>jdlds</bdi></a> said in <a href="/post/379">Tranform and Condition Scripts</a>:</p>
<blockquote>
<p dir="auto">Another issue i've encountered is using the PDH.countervalue for data collection.  This seems to work fine for some counters but not others.</p>
<p dir="auto">I tried: '\Memory\Committed Bytes' and this seems to work just fine<br />
but when i tried<br />
'\PhysicalDisk(_Total)\Disk Write Bytes/sec' this always returns 0.</p>
<p dir="auto">if anyone can shed some light on this, that would great.</p>
</blockquote>
<p dir="auto">Some counters (like physical disk counter you mention or CPU utilization counters) requires at least two samples to be taken to calculate value. Such counters should be polled in background by agent. To configure agent to do so, use <strong>Counter</strong> parameter in <strong>WinPerf</strong> section, like below:</p>
<p dir="auto">*WinPerf<br />
Counter = DiskWriteBytes:"\PhysicalDisk(_Total)\Disk Write Bytes/sec":60:A:INT:Average number of bytes per second written to disk for last minute</p>
<p dir="auto">There are several fields separated by colons (:). First is the name for new parameter (DiskWriteBytes in our example); second is counter path; third is number of samples to calculate average value - minimum is 2, and in our example it's 60 (because we need average value for last minute); fourth field is a collection class - it can be either A (collect values every second), B (collect values every 5 seconds), or C (collect values every 30 seconds); fifth field is a data type - it's only a hint for "select parameter" dialog in console and is not used by agent; and sixth field is a parameter description which will be shown in parameter selection dialog.</p>
<p dir="auto">After you define your new counter, you can access new parameter on agent by using name specified in the first field.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/381</link><guid isPermaLink="true">https://forum.netxms.org/post/381</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 10 Aug 2007 16:37:47 GMT</pubDate></item><item><title><![CDATA[Reply to Tranform and Condition Scripts on Fri, 10 Aug 2007 16:26:13 GMT]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">If you write non-trivial scripts (i.e. something more than single expression like $1/1024) you should define main() function. So you script should looks like this:</p>
<p dir="auto">sub main()<br />
{<br />
   if ($1&gt;5) return min($2, $3);<br />
}</p>
<p dir="auto">btw, you should return something also in case  when $1&gt;5 is false, so final form will be</p>
<p dir="auto">sub main()<br />
{<br />
   if ($1&gt;5)<br />
      return min($2, $3);<br />
   return 0; // Or any other default value<br />
}</p>
<p dir="auto">Best regars,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/380</link><guid isPermaLink="true">https://forum.netxms.org/post/380</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 10 Aug 2007 16:26:13 GMT</pubDate></item></channel></rss>