Example #1
0
        public NodeSettings GetNodeSettings(string node, Category c)
        {
            var s = PerNodeSettings?.FirstOrDefault(n => n.PatternRegex.IsMatch(node));

            // Grab setting from node, then category, then global
            Func <Func <INodeSettings, decimal?>, decimal?> getVal = f => (s != null ? f(s) : null) ?? f(c) ?? f(this);

            return(new NodeSettings
            {
                CPUWarningPercent = getVal(i => i.CPUWarningPercent),
                CPUCriticalPercent = getVal(i => i.CPUCriticalPercent),
                MemoryWarningPercent = getVal(i => i.MemoryWarningPercent),
                MemoryCriticalPercent = getVal(i => i.MemoryCriticalPercent),
                DiskWarningPercent = getVal(i => i.DiskWarningPercent),
                DiskCriticalPercent = getVal(i => i.DiskCriticalPercent),
                PrimaryInterfacePatternRegex = s?.PrimaryInterfacePatternRegex ?? c.PrimaryInterfacePatternRegex
            });
        }
Example #2
0
 public NodeSettings GetNodeSettings(string node) =>
 PerNodeSettings?.FirstOrDefault(n => n.PatternRegex.IsMatch(node)) ?? NodeSettings.Empty;