News:

We really need your input in this questionnaire

Main Menu

DCI question

Started by gmonk63, January 22, 2016, 03:23:38 AM

Previous topic - Next topic

gmonk63

Is it possible to setup a threshold based on multiple DCI values ?  So if I have four DCI's and I want to sum the values provided by all four and only trigger and alarm if the sum of those four DCI values is >= 50   


Thanks




tomaskir

#1
Create a script DCI and collect the combined value of the DCIs into the script DCI.

Then make the threshold on that DCI.

Sample script attached below.
Save it to script library and call it from the script DCI.

val1 = GetDCIValueByDescription($node, "DCI1 description");
val2 = GetDCIValueByDescription($node, "DCI2 description");
val3 = GetDCIValueByDescription($node, "DCI3 description");
val4 = GetDCIValueByDescription($node, "DCI4 description");

if (val1 == null || val2 == null || val3 == null || val4 == null)
  return 0;

return val1 + val2 + val3 + val4;

gmonk63

tomaskir,


Im almost succesfull at what im trying to achieve but im stuck on figuring out a way to reset values after the polling interval  I have four DCI's that collect and increment the values every minute and using your code created an internal DCI which will sum those values every 15min and i want to trigger an alarm based on the totals of the internal DCI  but how do I reset the values  the DCI's  after every poll interval instead of permanently incrementing

tomaskir

I dont understand exactly what you are trying to achieve, but maybe look at the delta functionality for the DCI.
It will automatically calculate the change of the DCI for the time period, and show you the value the DCI changed by.

gmonk63

Does any one  have any examples of a dci threshold script ? Im trying to trigger a threshold event but only if the threshold is met and secondary dci is true.. example

if (current dci >= 100 and secondary dci is true)
{

trigger event

}

else
{
keep on going
}



* Does the threshold script need to return a boolean  or integer to be evaluated

tomaskir

I really recommend reading the script hints, they are available since 2.0+.
Regarding reading another DCI, see this:
https://wiki.netxms.org/wiki/NXSL:GetDCIValueByDescription
https://wiki.netxms.org/wiki/NXSL:GetDCIValueByName

Here is an example... this is a threshold on disk % usage, depending on the size of the disk.
If disk is smaller then 1GB - 80% threshold.
1GB-1TB - 90% threshold.
1TB+ - 95% threshold.
storageSize = AgentReadParameter($node, "FileSystem.Total(" . $dci->instance . ")");
if (storageSize == null)
  return false;

if (storageSize < 1099511627776) {
  // for storageSize under 1TB
  if (storageSize < 1073741824) {
    // for storageSize under 1GB, 80%
    usageThreshold  = 80;
  } else {
    // for storageSize between 1GB and 1TB, 90%
    usageThreshold  = 90;
  }
} else {
  // for storageSize above 1TB, 95% threshold
  usageThreshold  = 95;
}

if ($1 > usageThreshold)
  return true;

return false;

gmonk63

Thanks,  Ive read the hints but wasnt sure how it pertained to triggering events weather the script needed to return a boolean or value  but from your script i see it needs to return a boolean in order to generate the event ... Thanks for your help