Metric() public method

Return the metric that matches key. Returns null if not found.
public Metric ( string key ) : Metric
key string
return Metric
            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);
 }