Hello DataMiner Community,
I'm working on a project where I need to dynamically retrieve elements based on alarm information in DataMiner. Currently, I'm using the following code to extract the alarm information,The parts
array contains the necessary properties such as dmaID
and elementID
.(How do I parse Correlation Alarm Info data? | DataMiner Docs):
Now, I want to use these dmaID
and elementID
or anyother properties to dynamically retrieve the associated elements using the available methods in the DataMiner Automation API and then try to set a certain parameter of the element. I noticed there are methods like FindElement
and FindElementByKey
in the DataMiner Automation API documentation, but I'm not sure how to properly use them in my scenario, a method to retrieve the element ID - so I can initialize my target variable to the value I retrieve.
.Could you please guide me on how to utilize these methods or any other relevant methods to retrieve elements dynamically based on the any properties from the alarm information? the element id extracted is of the alarm generated but element key of the component is different. Currently my script works when I provide static values of the element key in the Findelement method
Any help or example code snippets would be greatly appreciated!
Thank you in advance.
Assuming you have set the correlation rule correctly and it gets triggered by an alarm then I would do this:
int elementID = Tools.ToInt32(parts[2]); // Gets the Element ID
int dmaID = Tools.ToInt32(parts[1]); // Gets the Dma ID
Element myElement = engine.FindElement(dmaID,elementID);
myElement.SetParameter();
that should be what your looking for.
*** Edit ***
Correlation rule set
Hi,
I have justed tested it multiple time with different elements and different DMAs and it runs perfectly fine no matter which element triggers it
namespace test_1
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net.Messages.SLDataGateway;
///
/// Represents a DataMiner Automation script.
///
public class Script
{
///
/// The script entry point.
///
/// Link with SLAutomation process.
public void Run(IEngine engine)
{
ScriptParam paramCorrelationAlarmInfo = engine.GetScriptParam(65006);
string alarmInfo = paramCorrelationAlarmInfo.Value;
string[] parts = alarmInfo.Split(‘|’);
int elementID = Int32.Parse(parts[2]); // Gets the Element ID
int dmaID = Int32.Parse(parts[1]); // Gets the Dma ID
Element myElement = engine.FindElement(dmaID, elementID);
myElement.SetParameter(7,0);
}
}
}
check the update for the correltaion rule in the answer.
One thing that can be causing the issue is if some dlls are missing.
Appreciate your detailed help Amer ,Will keep on testing with these edits.
current update : the script and correlation rule works for one element and breaks and prints exception message for another. Somethings I edited from run(Engine engine) to run(Iengine engine).Also added the last dataminer package as your sample.
Hi Amer ,
Yes I have set the correlation rule correctly with the special key aswell,which prints out the alarm properties.
I have tried this logic , the dmaID and the elementID that is found by the correlation rule is of the alarm and I would like to use any of the alarm properties to find the associated element key (DMAID/ElementID) of the element in the driver affected by the alarm and then set parameter of a component of that element. My correlation rule would work on multiple elements (if active) so need the use dynamic values of dmaID and elementID