The snapshot of current sampled health metrics for any monitored process. Collected and gossiped at regular intervals for dynamic cluster management strategies. Equality of NodeMetrics is based on its Address.
 /// <summary>
 /// Returns the most recent data
 /// </summary>
 public NodeMetrics Merge(NodeMetrics that)
 {
     if (Address != that.Address)
     {
         throw new ArgumentException(string.Format("NodeMetrics.merge is only allowed for the same address. {0} != {1}", Address, that.Address));
     }
     if (Timestamp >= that.Timestamp)
     {
         return(this);                             //that is older
     }
     return(new NodeMetrics(Address, that.Timestamp, that.Metrics.Union(Metrics)));
 }
            public static SystemMemory ExtractSystemMemory(NodeMetrics nodeMetrics)
            {
                var used      = nodeMetrics.Metric(ClrProcessMemoryUsed);
                var available = nodeMetrics.Metric(SystemMemoryAvailable);

                if (used == null || available == null)
                {
                    return(null);
                }
                var max = nodeMetrics.Metric(SystemMemoryAvailable) != null ? (long?)Convert.ToInt64(nodeMetrics.Metric(SystemMemoryMax).SmoothValue) : null;

                return(new SystemMemory(nodeMetrics.Address, nodeMetrics.Timestamp,
                                        Convert.ToInt64(used.SmoothValue), Convert.ToInt64(available.SmoothValue), max));
            }
            /// <summary>
            /// Given a <see cref="NodeMetrics"/> it returns the <see cref="Cpu"/> data of the nodeMetrics
            /// contains the necessary cpu metrics.
            /// </summary>
            public static Cpu ExtractCpu(NodeMetrics nodeMetrics)
            {
                var processors = nodeMetrics.Metric(Processors);

                if (processors == null)
                {
                    return(null);
                }
                var systemLoadAverage = nodeMetrics.Metric(SystemLoadAverage) != null ? (double?)nodeMetrics.Metric(SystemLoadAverage).SmoothValue : null;
                var cpuCombined       = nodeMetrics.Metric(CpuCombined) != null
                    ? (double?)nodeMetrics.Metric(CpuCombined).SmoothValue
                    : null;

                return(new Cpu(nodeMetrics.Address, nodeMetrics.Timestamp, Convert.ToInt32(processors.Value), systemLoadAverage, cpuCombined));
            }
            /// <summary>
            /// Given a <see cref="NodeMetrics"/> it returns the <see cref="Cpu"/> data of the nodeMetrics
            /// contains the necessary cpu metrics.
            /// </summary>
            public static Cpu ExtractCpu(NodeMetrics nodeMetrics)
            {
                var processors = nodeMetrics.Metric(Processors);
                if (processors == null) return null;
               var systemLoadAverage = nodeMetrics.Metric(SystemLoadAverage) != null ? (double?)nodeMetrics.Metric(SystemLoadAverage).SmoothValue : null;
               var cpuCombined = nodeMetrics.Metric(CpuCombined) != null
                    ? (double?)nodeMetrics.Metric(CpuCombined).SmoothValue
                    : null;

                return new Cpu(nodeMetrics.Address, nodeMetrics.Timestamp, Convert.ToInt32(processors.Value), systemLoadAverage, cpuCombined);
            }
 public static SystemMemory ExtractSystemMemory(NodeMetrics nodeMetrics)
 {
     var used = nodeMetrics.Metric(ClrProcessMemoryUsed);
     var available = nodeMetrics.Metric(SystemMemoryAvailable);
     if (used == null || available == null) return null;
     var max = nodeMetrics.Metric(SystemMemoryAvailable) != null ? (long?)Convert.ToInt64(nodeMetrics.Metric(SystemMemoryMax).SmoothValue) : null;
     return new SystemMemory(nodeMetrics.Address, nodeMetrics.Timestamp, 
         Convert.ToInt64(used.SmoothValue), Convert.ToInt64(available.SmoothValue), max);
 }
 /// <summary>
 /// Returns the most recent data
 /// </summary>
 public NodeMetrics Merge(NodeMetrics that)
 {
     if(Address != that.Address) throw new ArgumentException(string.Format("NodeMetrics.merge is only allowed for the same address. {0} != {1}", Address, that.Address));
     if (Timestamp >= that.Timestamp) return this; //that is older
     return new NodeMetrics(Address, that.Timestamp, that.Metrics.Union(Metrics));
 }
 protected bool Equals(NodeMetrics other)
 {
     return Address.Equals(other.Address);
 }
 protected bool Equals(NodeMetrics other)
 {
     return(Address.Equals(other.Address));
 }