We have over 100 miners at our location. I want to create a rule so I get a single notification if 10 or more miners are offline all at the same time. How do I do that?
Thanks
Hi again,Thanks
You can create a trigger of the type "C# script" and use the script below to detect if the number of miners offline is 10 or more. You can then add any action you want for this rule, for example a Notification.
Code:
public class TriggerScript
{
private ContextProvider Context = ScriptManager.Context;
public List<IMinerBase> Check(List<IMinerBase> minerList)
{
const int TriggerIfNumberOffline = 10;
List<IMinerBase> triggerList = new List<IMinerBase>();
foreach (IMinerBase miner in minerList)
{
if (miner.IsRunningState == false)
triggerList.Add(miner);
}
if (triggerList.Count >= TriggerIfNumberOffline)
return triggerList;
return null;
}
}
I used this script and set a notification as an action. When I do that, I immediately get 72 notifications from the rule. It's always the same miners that trigger the rule. When I check my list of miners, everything says it's online and working fine.
How can I use this so it only sends me a notification if all the miners have been off for 10 minutes or longer?