Condition to auto close these alerts

Hi Team,

We have a customized Windows Event log policy alert for which we don’t get the closed event, so due to required customization we need to auto close these alerts with below conditions;

 

Alert Event Name : Wireless Access Point goes down

 

Required Condition to auto close these alerts;

 

Close the alert if the “Received Time” (shown in attached screen shot) is more than 15 minutes from the current time.

Can someone please help us to achieve this. Apologies for the ignorance as I am  very new to OBM tool.

Parents Reply Children
  • 0 in reply to   

    It has a option for Groovy script, but where can we get that script which will fulfil this requirement? I tried below script, but its not working

    import com.hp.ov.nms.*
    import java.text.SimpleDateFormat
    import java.util.concurrent.TimeUnit

    // Define the time threshold (15 minutes)
    def timeThreshold = 15 * 60 * 1000 // 15 minutes in milliseconds

    // Get the current time
    def currentTime = System.currentTimeMillis()

    // Define the date format for parsing the received time
    def dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")

    // Function to convert a date string to milliseconds
    def parseDateToMillis(String dateStr) {
    try {
    return dateFormat.parse(dateStr).getTime()
    } catch (ParseException e) {
    e.printStackTrace()
    return 0
    }
    }

    // Fetch all open events
    def openEvents = Event.getEvents([status: "Open"])

    openEvents.each { event ->
    def receivedTime = event.getReceivedTime()
    def receivedTimeMillis = parseDateToMillis(receivedTime)

    if (currentTime - receivedTimeMillis > timeThreshold) {
    // Close the event
    event.close("Automatically closed due to 15-minute inactivity")
    println("Event ${event.getId()} closed due to 15-minute inactivity.")
    }
    }