Dear Dojo,
I have created this part of a script which will scan for duplicates and report the outcome via e-mail. In the staging is working perfectly (DataMiner (10.2.0.0-11517)) and when I transferred it on the production it does no work any more (DataMiner (10.1.0.0-11319-CU11)).
The code is the following:
public class Script
{
public void Run(Engine engine)
{
engine.GenerateInformation("Collecting duplicate elements: Started");
Element[] elements = engine.FindElementsInView(-1);
var List = elements.Where(x => x.IsActive);
var duplicateKeys = List.GroupBy(x => x.PollingIP)
.Where(group => group.Count() > 1)
.SelectMany(group => group.Select(gg => gg))
.Where(x => !string.IsNullOrEmpty(x.PollingIP))
.ToList();
}
}
After this I am using a foreach loop to gather the info I need and send-it via email.
This is the part in which I think I have the problem.
The error from the production is the following:
2022/04/06 12:33:13.162|SLAutomation.exe 10.1.2046.9494|29308|38336|CSharp|DBG|-1|(Script Element Duplication Notification Live Test/2) (Code: 0x80131500) Skyline.DataMiner.Net.Exceptions.DataMinerException: Create Dummy Failed: 0x80004005
at CManagedAutomation.RunWrapped(CManagedAutomation* , Int32 iCookie, IUnknown* pIAutomation, tagVARIANT* varParameters, tagVARIANT* pvarReturn, String scriptName)
at CManagedAutomation.Run(CManagedAutomation* , Int32 iCookie, Char* bstrScriptName, IUnknown* pIAutomation, tagVARIANT* varParameters, tagVARIANT* varEntryPoint, tagVARIANT* pvarReturn) (CSharp; 0x80131500h):
2022/04/06 12:33:13.645|SLAutomation.exe
Can you point me in the right direction ?
Thank you
Catalin
Hi Catalin,
"Create Dummy Failed" in the logging could indicate that you need to re-add or re-configure one of the script dummies to reference the correct elements in your production system.
I don’t immediately see a cause for the reported error in your script.
A possible explanation for the difference in behavior between 10.1.0.0 and 10.2.0.0 could be the switch to .Net4.8 (see https://community.dataminer.services/documentation/dataminer-v10-2-0-release-notes/#31120), but then I would expect your script not to run at all. Do you get any errors or warnings when validating the script on the production system?
I did not get any errors when validating it in DM
Hi Catalin, I was able to successfully run your script on a 10.1.0.0-11655 DMA, so it is possibly due to an issue specific to your setup. I think Wouters’ suggestion to wrap the x.IsActive() call in a try/catch is certainly worth a try to check if this would be caused by a specific element.
Thank you, I will check it and reply.
Hi,
You might be able to find out more info about the error in the Automation log file (Cube > System Center > Logging > DataMiner > Automation. Or SLAutomation.txt on the server)
An error "Create Dummy Failed: 0x80004005" typically indicates that the automation module doesn't know about a specific element, which might indicate an incorrect in-memory state of that module. Restarting the DataMiner agent could help if this is the case.
I suspect the internal dummy instance gets created implicitly on the x.IsActive call. Using try/catch around this call could be a workaround.
The above error is directly from SLAutomation.txt
Well, I did not create any dummy,
Here is all the code so you can have a greater picture.
public class Script
{
public void Run(Engine engine)
{
engine.GenerateInformation(“Collecting duplicate elements: Started”);
Element[] elements = engine.FindElementsInView(-1);
var List = elements.Where(x => x.IsActive);
var duplicateKeys = List.GroupBy(x => x.PollingIP)
.Where(group => group.Count() > 1)
.SelectMany(group => group.Select(gg => gg))
.Where(x => !string.IsNullOrEmpty(x.PollingIP))
.ToList();
//var nbOfItems = duplicateKeys.Count(x => x.PollingIP == x.PollingIP);
string message = “”;
Element lastElement = elements.Last();
foreach (Element element in duplicateKeys)
{
if (element.PollingIP.Equals(lastElement.PollingIP))
{
message += ” ” + ” – ” + element.ElementName + ” – ” + element.GetPropertyValue(“Department”) + ” – ” + element.GetPropertyValue(“JIRA_DeviceObjectKey”) + “”;
}
else
{
message += “”;
message += “——————————————————-” + “”;
message += “There are ” + duplicateKeys.Where(x => x.PollingIP == element.PollingIP).Count() + ” elements with this IP : ” + element.PollingIP.ToString() + “”;
message += “——————————————————-” + “”;
message += “”;
message += ” – ” + element.ElementName + ” – ” + element.GetPropertyValue(“Department”) + ” – ” + “”;
}
lastElement = element;
}
//
EmailOptions emailOptions = new EmailOptions
{
// Note that it is possible to specify multiple destinations by using a semi-colon as separator.
// Also, it’s possible to specify a specific DataMiner user or group with following format “USER:admin” or “GROUP:myGroup”.
// E.g. “Jon@DataMiner.be;USER:administrator;GROUP:operators”
TO = “test@test.com”,
//CC = “”,
//BCC = “”,
Title = “Duplicate Elements in DMS”,
Message = message,
// Uncomment the line below to send a plain text message instead of HTML
//SendAsPlainText = true
};
// Send out the actual mail
engine.SendEmail(emailOptions);
engine.GenerateInformation(“Elements gathering finished, Email sent!”);
}
}