Hi Dojo,
Does someone has example code for getting all the active alarms for all elements using a specific connector in Automation?
Hi all,
Based on the answer of João I found a way to get all the alarms with just a single call.
var switchProtocols = new List<string>
{
"Generic Switch/Production",
};GetActiveAlarmsMessage gaam = new GetActiveAlarmsMessage
{
Filter = new Skyline.DataMiner.Net.Filters.AlarmFilter
{
FilterItems = new Skyline.DataMiner.Net.Filters.AlarmFilterItem[] {
new AlarmFilterItemString
{
Field = AlarmFilterField.Protocol,
Values = switchProtocols.ToArray(),
},
},
},
};var response = (ActiveAlarmsResponseMessage)engine.SendSLNetSingleResponseMessage(gaam);
Hi Jens,
To start you can use the FindElementsByProtocol call to retrieve your elements.
You can use it with just a connector name
Element[] elements = engine.FindElementsByProtocol("Protocol Name");
or with the version as well
Element[] elements = engine.FindElementsByProtocol("Connector Name", "Connector Version");
You can then use the GetActiveAlarmMessage to request the alarms for each of your elements in a loop
var request = new GetActiveAlarmsMessage(dmaId, elemId);
var response = (ActiveAlarmsResponseMessage)engine.SendSLNetSingleResponseMessage(request);
AlarmEventMessage[] alarms = response.ActiveAlarms;
This will return you a collection with the alarms for that given element.
This should work for your use case but I do have to add a disclaimer here that these kinds of SLNet calls are internal calls and typically not recommended to use since there is no official support and may be subject to change in the future.
If you only need the alarm count but not the alarm content itself then you could use Class Library and the GetActiveAlarmCount call.
Just to add a documented alternative for reference:
So not directly in automation, but you could use the wepAPI to GetElementsForProtocol | DataMiner Docs and then similarly iterate them and then GetActiveAlarmsForElement | DataMiner Docs.