Can't get a solution with automatic PushAgent increase

Started by gannet, April 28, 2020, 08:18:58 PM

Previous topic - Next topic

gannet

Hello! I'm trying to get cumulative metrics by tracking daily renewing one. So every increase of a daily metric raises an event. Then this increase must be appended to cumulative metric's meaning and ... I just can't give arguments to adding script. I checked:
1. script is working with arguments in server console and works with defined one
2. arguments are right because email action can recognize them
3. selecting Run NXSL Script give has no result in case of arguments addition to script name even if the last one does not use arguments at all. I'm very sad...
4. any walked roundabout way of script execution doesn't work
5. I haven't found a way to get current value of PushAgent characteristics from .bat command file
6. script can't get any object reference another way but arguments OR may be I'm wrong?
Quoteobj = FindObject($1); //get object
cur = GetDCIValue(obj, FindDCIByName(obj, "TotalCount")); //get current value
if (cur == null)
   cur = 0;
PushDCIData(obj, FindDCIByName(obj, "TotalCount"), cur + $2); //increase it
Can you suggest any way to push increase of cumulative metric, please? I have no right ideas

Tursiops

Not sure how your original daily metric is done exactly, but if the idea is to update the Push DCI every time the daily one is polled, you can add your code into the daily DCI's transformation script directly.


dci=FindDCIByName($node,"TotalCount");
cur=GetDCIValue($node,dci);
if (cur == null ) cur=0;
PushDCIData($node,dci,cur+$1);
return $1;


This will get the Push DCI object, get its current value, set to 0 if null, then push the data from the DCI that's actually been polled and add it to the Push DCI.
The script will run every time the original DCI is polled. No event, action, separate script, etc. required.
You may want to add some logic to ensure $1 (i.e. the value of the original DCI) is actually an integer/float before you do the addition.
You could also add code to create the PushDCI itself if it doesn't exist yet.

gannet

Thank You Tursiops!
Your solution is obviously logical and simple instead of my search for a roundabout way. By using simple difference value I get this:
Quoteif ($1 != 0){
   dci=FindDCIByName($node,"TotalCount");
   cur=GetDCIValue($node,dci);
   if (cur == null ) cur=0;
   PushDCIData($node,dci,cur+$1);
}
return GetDCIValue($node,$dci->id) + $1;