DX Infrastructure Manager

Expand all | Collapse all

LUA script - Send email if alert is not assigned to anyone

Jump to Best Answer
  • 1.  LUA script - Send email if alert is not assigned to anyone

    Posted 03-02-2015 05:54 PM
      |   view attached

    Hi all,

     

    I have an old script that can be manipulated to send an alarm if there is no note attached, but is over a certain age old..

     

    I'm after a script that will look to see if the alert is assigned to anyone and if not, send an email.  Coupled with an AO profile I can then automate an escalation procedure.

     

    I'd be very grateful if someone could take a look at the above script and amend it :smileyhappy:

     

    Thanks in advance!

    Sam

     

    (Attaching script as attachment)

    Attachment(s)

    txt
    LUA_Script.txt   783B 1 version


  • 2.  Re: LUA script - Send email if alert is not assigned to anyone

    Posted 03-02-2015 06:10 PM
      |   view attached

    Think I have the beginning of this..

     

    Script attached

    Attachment(s)

    txt
    LUA_Script_1.txt   803B 1 version


  • 3.  Re: LUA script - Send email if alert is not assigned to anyone
    Best Answer

    Posted 03-03-2015 05:27 PM

    A working script!

     

    a = alarm.get("CK46146697-15655")
    print(a.notes)
    --Is the alarm assigned?
    if a.assigned_to ~= nil then
    assigned_to = true
    else
    assigned_to = false
    end

    require ("library/html-alarms-lib")

    recipient    = "sam.g@cem.com"
    title        = "Non Acknowledged Alarm"
    msg          = " Nimsoft alarm: "..a.message
    msg1         = " --- from "..a.hostname

    buf = ""
    buf = buf .. html_start (title)
    buf = buf .. html_alarm_message(msg)
    buf = buf .. html_alarm_message(msg1)
    buf = buf .. html_end ()

    print("Is this alarm assigned?  ")
    if assigned_to == true then print("yes") else print("no") end

    arrival = a.arrival                        --Sets arrival as the alarm arrival time at the NAS
     
    b = timestamp.diff(arrival, "minutes")     --Sets b as the difference in minutes between arrival and NOW (default)
    print("\n Difference between alarm arrival and now = "..b.." min")

    --if b (time from arrival till now) is more than 1hr and is not assigned then do something:

    if (b >= 60 and assigned_to == false) then action.email(recipient,title,buf)
                 
    else print("This alert has been accepted")

    end