I have created a logic to read the alarm data triggered via correlation.
https://docs.dataminer.services/dataminer/Functions/Automation_module/FAQ/How_do_I_parse_Correlation_Alarm_Info_data.html?q=alarm%20correlation
But I need a way to get the root time of the alarm. I can only see the rootalarmid param on the above document. Is there a way to get the root time of the alarm on an automation script
Hi Ramesh,
I could not find in the documentation a way to get the root time from the alarm that triggered the correlation rule. Find below a snippet that should allow you to retrieve the root time:
using System;
using System.Collections.Generic;
using System.Linq;
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net;
using Skyline.DataMiner.Net.Filters;
using Skyline.DataMiner.Net.Helper;
using Skyline.DataMiner.Net.Messages;public class Script
{
public static void Run(IEngine engine)
{
try
{
RunSafe(engine);
}
catch (ScriptAbortException)
{
// Catch normal abort exceptions (engine.ExitFail or engine.ExitSuccess)
throw; // Comment if it should be treated as a normal exit of the script.
}
catch (ScriptForceAbortException)
{
// Catch forced abort exceptions, caused via external maintenance messages.
throw;
}
catch (ScriptTimeoutException)
{
// Catch timeout exceptions for when a script has been running for too long.
throw;
}
catch (InteractiveUserDetachedException)
{
// Catch a user detaching from the interactive script by closing the window.
// Only applicable for interactive scripts, can be removed for non-interactive scripts.
throw;
}
catch (Exception e)
{
engine.ExitFail("Run|Something went wrong: " + e);
}
}private static void RunSafe(IEngine engine)
{
ScriptParam paramCorrelationAlarmInfo = engine.GetScriptParam(65006);
string alarmInfo = paramCorrelationAlarmInfo.Value;
string[] parts = alarmInfo.Split('|');
int alarmID = Tools.ToInt32(parts[0]);
int dmaID = Tools.ToInt32(parts[1]);
int elementID = Tools.ToInt32(parts[2]);
int rootAlarmID = Tools.ToInt32(parts[5]);DateTime rootTime = GetRootTimeFromAlarm(engine, dmaID, elementID, rootAlarmID);
engine.GenerateInformation($"[INFO]|Run|RootTime:{rootTime}");
}public static DateTime GetRootTimeFromAlarm(IEngine engine, int dataminerId, int elementId, int rootAlarmId)
{
// Get the alarm tree ID for the given root alarm ID
AlarmTreeID alarmTreeID = new AlarmTreeID(dataminerId, elementId, rootAlarmId);// Preparing the message
GetAlarmTreeDetailsMessage getAlarmTreeDetailsMessage = new GetAlarmTreeDetailsMessage(alarmTreeID);// Send the message and get the response
AlarmEventMessage response = (AlarmEventMessage)engine.SendSLNetSingleResponseMessage(getAlarmTreeDetailsMessage);return response.RootTime;
}
Hope it helps.
Do you use the AlarmTreeID?
Far from a full answer, but if you specifically want the Alarm Console’s Root time column behavior, querying the root alarm and reading its "Time" might work in your scenario.
Subscribing to get more suggestions from the community