acknowledge all active alerts

Find and share HowTos to various installations / configurations!
4 posts • Page 1 of 1
Mgiacome
Posts:21
Joined: Thu Sep 26, 2024 1:35 pm

acknowledge all active alerts

Post by Mgiacome »

I'm trying to ack all active alerts relative to a DP, with control script, not with AES

So I get alerts with the following query

Code: Select all

dpQuery ("SELECT '_alert_hdl.._act_state' FROM '"+dp+"*' WHERE '_alert_hdl.._class' == \"System1:alert.\" & '_alert_hdl.._act_state'==1 | '_alert_hdl.._class' == \"System1:alert.\" & '_alert_hdl.._act_state'==2 | '_alert_hdl.._class' == \"System1:alert.\" & '_alert_hdl.._act_state'==3 |'_alert_hdl.._class' == \"System1:alert.\" & '_alert_hdl.._act_state'==4", _alerts);

Then, in a for loop I check the alert state again with alertGet

Code: Select all

// get state of alert. CAME unack, CAME ack, WENT unack, No alert
  alertGet(t, getACount(At), dpe+":_alert_hdl.._act_state", state); 
  
 
  if ( (state==DPATTR_ALERTSTATE_APP_NOT_ACK) || (state==DPATTR_ALERTSTATE_DISAPP_NOT_ACK) ) {
    alertSetWait(t, getACount(At), dpe+":_alert_hdl.._ack_state", DPATTR_ACKTYPE_SINGLE); // single-acknowledge alert 
  } else {
    DebugN("CANNOT Acknowledge Dpe state", dpe, state);
  }
  
But the state I get with alertGet is different from the state got with dpQuery ! For example qith dpQuery I get ack_state 2 or 3, but with alertGet I get always act_state = 0

And also, if I skip the check of current state, system get me a SEVERE error

WCCOAui0:WCCOAui (4), 2024.12.06 08:41:41.704, PARAM,SEVERE, 23, Setting/modifying attributes failed, DP: System1:XXXXXX:_alert_hdl.._ack_state, MAN: (SYS: 1 Ui -num 4 CONN: 1), USER: 0
WCCOAui0:]

Do you have some suggestion ?

Ty

EDIT: corrected act_state.
Last edited by Mgiacome on Thu Dec 12, 2024 8:41 am, edited 1 time in total.

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: acknowledge all active alerts

Post by leoknipp »

Your description does not match the code parts. In the code you are reading _act_state and the description refers to _ack_state.
Which attribute are you talking about?

If you want to acknowledge an alert you must use the attribute _alert_hdl.._ack.

Please keep in mind the system names must not be used in a query string.

Best Regards
Leopold Knipp
Senior Support Specialist

Mgiacome
Posts:21
Joined: Thu Sep 26, 2024 1:35 pm

Re: acknowledge all active alerts

Post by Mgiacome »

Sorry there was a typo.

I check act_state in order to understand if is possible to acknowledge that alert ( DPATTR_ALERTSTATE_APP_NOT_ACK or DPATTR_ALERTSTATE_DISAPP_NOT_ACK). Still get different values between dpQuery and alertGet

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: acknowledge all active alerts

Post by leoknipp »

Have you tried to use the attribute _ack_possible to check if an alert can be acknowledged?
Maybe this attribute can be used to fulfil your requirements.

Best Regards
Leopold Knipp
Senior Support Specialist

4 posts • Page 1 of 1