same threshold on multiple dci

Started by MarcusH, October 31, 2016, 03:11:04 PM

Previous topic - Next topic

MarcusH

Hi,

Is there any way to mass update thresholds like with templates?
I have alot of DCI that uses same threshold but each time this threshold needs to be tweaked i need to update each DCI one by one.

MarcusH

#1
Solved my problem with script, though i have one problem i can't seem to figure out

28 DCI with name starting with IntQ that collects data every 5 sec
1 DCI that runs the script every minute

What this script does is that it will trigger event and set alarm if any of the DCI values do not go down under 15 min (900sec)
and if values goes down and alarm exists trigger event to terminate alarm

MAIL_ALL event has create alarm with key ALARM-%1
MAIL_ALL_RESET event has terminate alarm with key ALARM-%1

The logic works it will trigger the events and create alarm correctly but the termination of the alarm in MAIL_ALL_RESET does not work and the alarm will remain, i can not see why this should not work.

Any help in this would be very appreciated.

foreach(adci : FindAllDCIs($node,"IntQ*"))
{
eventtrigger = 1;
oldval=0;

// Check DCI values if they are going down within time period.
foreach(dcivalue : GetDCIValues($node, adci->id, time() - 900, time()))
{
if((oldval > dcivalue) || (dcivalue == 0)){eventtrigger = 0;}
oldval = dcivalue;
}

alarm = FindAlarmByKey("ALARM-".adci->name);

// Trigger event, and set alarm so mail action is only triggered once.
if(eventtrigger == 1)
{
if(alarm == null)
{
PostEvent($node, "MAIL_ALL", null, adci->name, adci->description, null, GetDCIValue($node, adci->id));
}
}

// Reset event alarm
if(eventtrigger == 0)
{
if(alarm != null)
{
PostEvent($node, "MAIL_ALL_RESET", adci->name, adci->description, null, GetDCIValue($node, adci->id));
}
}
}


Edit: Even tried terminating alarm via method terminate still nothing.

Victor Kirhenshtein

Hi,

in second PostEvent you pass DCI name as tag, not as first event parameter. You have to insert null there (as in first PostEvent call).

Best regards,
Victor

MarcusH

oh my god that's just... i stared hours on that and was 110% sure i copy pasted everything and just changed event name.

Many thanks  :D

MarcusH

Found another problem in that it is loops newest value first so the check from oldvalue is wrong.
Is there any method for reversing arrays?

Experimenting with for loop with array size, though just reversing array using foreach would be nice