Thresholds -Diff with Strings

Started by Spheron, August 08, 2025, 09:26:50 AM

Previous topic - Next topic

Spheron

 
Hello @all,
 
i have a DCI which collect Date/Time via Powershell every hour. For Example here the last Values from the history of this DCI:
 
"Timestamp","Value","Raw value"
"08.08.2025 06:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"08.08.2025 05:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"08.08.2025 04:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"08.08.2025 03:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"08.08.2025 02:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"08.08.2025 01:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"08.08.2025 00:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 23:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 22:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 21:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 20:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 19:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 18:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 17:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 16:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00"
"07.08.2025 15:25:56","03.08.2025 18:00:00","03.08.2025 18:00:00" 


I created a Threshold to get an alarm if the value NOT change in the last 24h:

Function: "Diff with previous value" 
Sample: 24
Operation: "> : greater than"
Value: 0
Activation Event: <Type Warning>
Dectivation Event: <Type Normal>
 
But the threshold throws no alarm, even if change the sample count to 1 or 2.
 
Is this the false threshold function to compare a string? But in the NetXMS Documentation for Thresholds this function should work with strings...

---
Diff with previous value
Delta between the last and previous values will be used. If DCI data type is string and the last and previous values match, system will use 0, and if they don't - 1.
---- 
 
Where are my fault?  I am thankful for any hint...
 
Greetings
Marco
 
 
 

Filipp Sudanov

Hi, 

Sorry, vacation time here so answering was delayed. 

Setting number of samples to 24 means that all 24 samples should return "true". It would trigger only if 24 consecutive data collections will return different value. So not what we need here. 

We don't have built-in thing for "no changes within given time", so we will use a bit of scripting. In the Transformation page of your DCI put the following: 

oldValue = GetDCIRawValue($node, $dci.id);

if (oldValue != $1) {
  $node.setCustomAttribute("lastChangeTime", time());
}

lastChangeTime = $node.getCustomAttribute("lastChangeTime");
if (lastChangeTime == null) lastChangeTime = 0;

return time() - lastChangeTime;

Set Data type after transformation to Integer (this is relatively new feature, if you don't have it, upgrade to 5.x).

On the General page set Units to Uptime.


This should be it. Now how it works - in the transformation script we compare new value to the previous raw walue. If they differ we save timestamp into custom attribute on the node. And we subtract value of this custom attribute from current time - so result of the DCI is time in seconds since last change of the value. You can just set a treshold > 86400 and it should work.