It's not actually that hard to do.
One of the things that's difficult to get your head around is figuring out what event causes the changes to occur.
Probes like CDM make this easy because you get an event every interval - the easy probes are identified by the cases where the count steadily increases while the event is happening. I'm hoping your temperature sensor is like that - where every time it checks the temp it sends an alarm with a priority that matches the wrongness of the temperature measured.
Assuming it is, with probe messaging like this, you set up an AO profile that essentially answers the question of whether or not that message should be visible or if it should create create a new message or not. And it needs to be set "On Arrival" so that it fires every time.
You use the trigger to collect the alarms that match the event. So yes, it can be expensive to query the alarm table for matching alarms if you have 10k active alarms. If you have a trigger already, that trigger has effectively already run the query so it's very fast to "ask the trigger" which alarms matched it.
you also use a second trigger (if you want) to collect the existence of the "all four happening" alarm.
If I understood your problem correctly, you have a situation where if there's less than four temperature alerts, the alerts should be invisible. If there are four alerts then you want them to be visible and to create a new alarm reflecting the condition.
So your AO profile script for the temperature alert looks something like:
Get alarm contents for teh temp alert
request list of matching temperature alarms from trigger
request list of matching "All Four temperature alarms" alarms from second trigger
if count of matching temperature alerts = 4 and visibility = no
Set visibility to yes
update alarm
if count of all four temperature alarms = 0
create "All four temps bad" alarm using rawalarm with level > 0 (not clear)
end
else if level = clear
if count of all four temperature alarms alarms > 0
create "All four temps bad" alarm using rawalarm with level = 0 (clear) to close the all four alarm
end
else if count of matching alerts < 4 and visibility = yes
set visibility to no
update alarm
if count of all four temperature alarms > 0
create "All four temps bad" alarm using rawalarm with level = 0 (clear) to close the all four alarm
end
end
The other thing to note is that when you update an alarm it goes back on the bus so the script will process that alarm almost immediately a second time so you need to make sure that your script doesn't update the alarm if it is "Right".
There is some delay in the way the script would work because it is dependent on the next event from the temperature probe to come in to to make the alert decide if it is visible or not.
I may have missed some of the logic and it is a real pain to test but it is a satisfying mental challenge.
-Garin