Custom Event Messaging
-
I have a data point with a string for a value that represents an alarm message from another system. To get notification in Mango Events I added an Event Detector which is working as planned. The Message that appears in list of events seems to come from the Alias of the Change Detector.
The question I have is can this Event Message be changed to use the value of the data point instead of the alias of the Event Detector?Thank you
-
have you tried leaving the Alias blank? If it's blank, Mango will auto-generate an event message that might be closer to what you want.
-
Hi Wingnut2.0,
Generally the answer is probably no. As Joel suggested you could remove the alias and see if that's closer to the message you are looking for, but the only way I can think of to easily do what you're describing would be to have an set point event handler set a virtual alphanumeric point with a change detector to the string you would like reported on the events page. Then you can turn the log level of the original event down, and the change events for the alphanumeric point will be the interesting things in the events list.
But, that would have the disadvantage of not returning to normal and whatnot (if you use the same alphanumeric point to pump out other alarm messages too. If not, you could use a regex detector of
.+
and set the alphanumeric point back to "" with the inactive action of the first event but it would have to be a one to one mapping. -
Thank you, Joel. It’s certainly closer, but I was wondering if there is a way to possibly parse the incoming notification (datapoint.value) via a script and have the result passed to the event notification?
-
Ah, I have a perhaps better solution:
Create an SQL data source with credentials to the Mango database, then create a point that updates tables only with SQL like the following,
update events set message=? where id=(select id from events where typeName='DATA_POINT' and typeRef1=? and typeRef2=? order by id desc limit 1);
and parameters like,
- String
- Integer
- Integer
then create a set point handler from the event in question to this SQL point, and add the original point that raised the event into the set point hander's script context. Our script will look like,
return "('common.default|Point value changed to " + p.value + "|'," + event.getReferenceId1() + "," + event.getReferenceId2() + ")";
'common.default' is a translation key for literals. The format of the message column appears to be messageKey|arg1|arg2|arg3|...| so I'm setting the message to
"Point value changed to " + p.value
in this example.If necessary, I can demonstrate it with the script on the email handler, then you could also set the subject line from there and it'll all be consistent (if you're emailing it too).
-
Works perfectly. Thank you.
-
I have a similar requirement in the event detectors. I would like to pass the point value that triggered the event detector the the process (in my case a bash script on a linux server) I can trigger the bash script with parameters, but I cannot give it the point value as a parameter. Is this at all possible? Event detectors seems to be the best way to do server side stuff such as running rsync to a remote device.
-
Hi glamprecht,
Generally it is better to ask a new question in a new thread and link to the old thread that you think it may be related to. That way it has a specific title and whatnot.
Anyway, I would use a set point handler to solve that. You would have the option of setting your command to an alphanumeric SSH data point or mimicking the process handler's job by calling,
// point that raised event is in context as p com.serotonin.m2m2.rt.maint.work.ProcessWorkItem.executeProcessCommand("myprogram " + p.value, 39 /* process timeout */); return UNCHANGED;