Total Alert Count

Find and share HowTos to various installations / configurations!
4 posts • Page 1 of 1
hakan
Posts:28
Joined: Wed Nov 24, 2010 9:38 am

Total Alert Count

Post by hakan »

This script is getting total alert count. We want to share it.

Code: Select all

const int CAME_UNACK = 1; 
const int CAME_ACK = 2;
const int WENT_UNACK = 3;
const int CAME_WENT_UNACK = 4;
const int NO_ALARM=0;
mapping alertsStatusmap;

main()
{
 dpQueryConnectSingle("work", 1, "ident", "SELECT ALERT '_alert_hdl.._ackable' FROM '*'"+"" ) ;
     
}
    
work(string ident, dyn_dyn_anytype tab)
{
  int                   i, PriorRange, actState;
  string                dpElement;
  time                  ti;
  unsigned            ranges;
  dyn_time            times;
  dyn_int              ackState, realAckState, oldestAck, counts;
  dyn_string          dpes;
  int ack_range;
  int direct,prior;

  
  for (i = 2; i

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

Re: Total Alert Count

Post by leoknipp »

I had a look at the script and I have a few questions and remarks.
-- What is the purpose of the script and what is the result?

-- Attributes which are needed in the work function shall be used in the query string (if possible). Then there is no need to do a dpGet() in the work function.
-- If a dpGet() is called in a work function the result is probably not "correct"
E.g. if the alert state changes between calling the work function and doing a dpGet() the values read by dpGet() do not fit the values received in the hotlink
-- Instead of single dpGet() calls one dpGet() with all attributes shall be made
-- The result of reading the attribute _online.._stime is not used in the script
-- It is the same for the result of doing a dpGet() for _alert_hdl.._num_ranges, _alert_hdl."+PriorRange+"._prior", _alert_hdl.._direction
-- The last characters in the query string +"" are not needed

Best Regards
Leopold Knipp
Senior Support Specialist

adaneau
Posts:310
Joined: Tue Feb 21, 2012 9:49 am

Re: Total Alert Count

Post by adaneau »

Hi,

For this we are using sum alarm and the count attribute :) Fast and easy if your alarms are well organized.

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: Total Alert Count

Post by fmulder »

Your code is 'faulty'

* You have a for-next loop with a variable 'i'. Inside this loop you again use an 'int i'. When you decide to nest a for-next lop then at least use a different character
* You count the alarms by going through a global mapping 'i

4 posts • Page 1 of 1