Hello Dojo Community !
I have an use case to build an automation script that would take the input of a period (by date) and then check the system for any warning or minor alarms raised in the system and clear them an automated way. Currently we do this buy right clicking on the alarm and click on the 'clear alarm' option . The Minor and warning alarms we are deleting are ones created internally by the correlation engine so we are not losing important traps just doing some house keeping.
I was investigating and found this : Code example - Take alarm ownership - DataMiner Dojo , and wanted to know if a method for clearing alarms existed (which I couldn't see in the documents site) , if so could you please guide me to it ?
Hi,
I made a small code snippet and published it on our Skyline Communications Github. You can view it from this link and also copy it over to your Automation module in DataMiner if you want: SkylineCommunications/SLC-AS-ClearNoticeAlarmsOlderThanAWeek: Example Automation Script that clears all notice alarms that are older than a week. (github.com) .
The code is getting all Active Alarms and filtering on rootCreationTime (clearing the ones older than one week ago) and severity. But I am not sure if you're restrictive enough, and I think it's wise to be careful to not clear more alarms than intended.
Therfore, before trying this out, I would maybe start by trying out the GetActiveAlarmsMessage with the SLNetClientTestTool and based on the response, you can check which alarms that are returned and on which fields you can filter them.
In below, I added inline two screenshots from a test that I did on an internal test system to visualize how you can do that.
Another option is for example the "DisplayValue", in this snippet that would be "if alarm.DisplayValue.Contains("...")" for example.
Hopefully this gets you further and if there are questions, please comment and we try to guide you further to the solution you want. 😊
Kind regards,
Joachim
Hi A B M,
I updated my answer, and I think this will help clarifying. The ClientTestTool is just there to test, the actual work is done in the Automation Script that I now included in the repo. You do not need to add or include other libraries than the ones that DataMiner already has available. The only thing is that you need the “usings” of “Skyline.DataMiner.Automation” and “Skyline.DataMiner.Net.Messages” . If you copy over the script from this file, you’re all set. https://github.com/SkylineCommunications/SLC-AS-ClearNoticeAlarmsOlderThanAWeek/blob/master/ClearNoticeAlarmsOlderThanAWeek_1/ClearNoticeAlarmsOlderThanAWeek_1.cs
Kind regards,
Joachim
Thank you very much Joachim , I am downloading the ZIP and pushing it to our test environment with VS pro- DIS . I used the SLNet client tool to get more alarm information , and thought of adding an extra bit of logic to clear only minor and warning alarms older than a week.
You’re welcome. That was indeed the goal of my explanation: that you could understand it yourself, use the shared automation script as a solid foundation, and then fine-tune it to your preferences. 🙂
Sorry for bothering again with a minor issue , I’m encountering an issue with the SetAlarmStateMessage constructor in a DataMiner Automation script.
“SetAlarmStateMessage setAlarmStateMessage = new SetAlarmStateMessage(alarm.TreeID, Skyline.DataMiner.Net.Enums.AlarmUserStatus.Clear, clearingMessage);”
I get this error : “There is no argument given that corresponds to the required formal parameter ‘value’ of SetAlarmStateMessage.SetAlarmStateMessage(int, int, int, string).”
From my SLNetclient test , i observed we don’t have ‘treeID’ comming in from the alarms , so instead i changed the treeID to take elementID and rootalarmID instead , as it required 4 args.
so now it tries to run this :
// Prepare to clear the alarm using SetAlarmStateMessage
SetAlarmStateMessage setAlarmStateMessage = new SetAlarmStateMessage(alarm.ElementID,
alarm.RootAlarmID,
(int)Skyline.DataMiner.Net.Enums.AlarmUserStatus.Clear,
clearingMessage);
The script executes successfully on the pop up , then in the automation logs and the informational events i can see an exception thrown , its usually a Port connection issue ,
port 751 or 440 (
Something went wrong: No connection with 751.
Server stack trace:
at Skyline.DataMiner.Net.RemoteAccess.Forward(MessageTarget target, DMSMessage[] messages)
at Skyline.DataMiner.Net.RemoteAccess.ForwardImpersonated(IConnectionInfo connInfo, Int32 dataMinerID, TargetedClientRequestMessage message)
at Skyline.DataMiner.Net.Facade.HandleClientRequestMessage(IConnectionInfo connInfo, ClientRequestMessage oneMsg, Boolean canQueue)
at Skyline.DataMiner.Net.Facade.HandleMessageInternal(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.Facade.HandleMessage(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.BaseFacade.HandleMessages(IConnectionInfo connInfo, DMSMessage[] msgs)
at Skyline.DataMiner.Net.Facade.HandleImpersonateMessage(IConnectionInfo originalConnInfo, ImpersonateMessage im)
at Skyline.DataMiner.Net.Facade.HandleMessageInternal(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.Facade.HandleMessage(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.BaseFacade.HandleMessages(IConnectionInfo connInfo, DMSMessage[] msgs)
at Skyline.DataMiner.Net.Facade.HandleMessagesForClient(IConnectionInfo connInfo, DMSMessage[] messages)
at Skyline.DataMiner.Net.Transport.Remoting.InternalHandleMessages(ConnectionToken token, DMSMessage[] inputMessages, ConnectionTransportType ctt)
at Skyline.DataMiner.Net.Transport.Remoting.HandleMessages(ConnectionToken token, DMSMessage[] inputMessages, ConnectionTransportType ctt)
at Skyline.DataMiner.Net.Transport.Remoting.HandleMessages(ConnectionToken token, DMSMessage[] inputMessages)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Skyline.DataMiner.Net.ISLNet.HandleMessages(ConnectionToken token, DMSMessage[] inputMessages)
at Skyline.DataMiner.Net.LegacyRemotingConnection.TransportSpecificHandleMessage(ConnectionToken tok, DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.Connection.InternalHandlePackedMessages(ConnectionToken tok, DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.Connection.InternalHandleUnpackedMessages(DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.Connection.HandleMessages(DMSMessage[] msgs, Int32 timeout)
at Skyline.DataMiner.Net.PersistentConnectionContainer.SendMessages(DMSMessage[] messages)
at Skyline.DataMiner.Automation.Engine.SendSLNetMessages(DMSMessage[] messages)
at Skyline.DataMiner.Automation.Engine.SendSLNetMessage(DMSMessage message)
at ClearNoticeAlarmsOlderThanAWeek_1.Script.RunSafe(IEngine engine) (Script ‘Clear Notice Alarms Older Than A Week’)
Thank you for the Code Snippet, will try it out as you suggested by seeing the outputs of the alarm information retrieved ! I was not aware that we could use SLNet message client tool to run automation scripts. Will look into it . Wouldn’t it require to have the correct libraries for the methods in SLNet client tool ?