public void Print(MetricsCollection metricsCollection, int top)
 {
     lock (sync)
     {
         PrintInternal(metricsCollection, top);
     }
 }
Esempio n. 2
0
        public void Save(MetricsCollection collection)
        {
            var serializedSize = Serializer.GetEstimatedSerializedSize(collection);

            using (var stream = StreamPool.Get(serializedSize))
            {
                Serializer.Serialize(collection, stream);
                targetStream.Write(BitConverter.GetBytes((int)stream.Value.Length), 0, sizeof(int));
                stream.Value.CopyToAsync(targetStream);
            }
        }
 private static void PrintInternal(MetricsCollection collection, int top)
 {
     Console.Clear();
     Console.SetCursorPosition(0, 0);
     Console.WriteLine($"Machine: {collection.MachineName}, Uptime: {collection.Uptime}, Timestamp: {collection.Timestamp}");
     ConsoleTable.From(
         collection
         .ProcessMetricsCollection
         .OrderByDescending(x => x.WorkingSet)
         .Take(top)
         .Select(x => new ProcessMetricsModel(x)))
     .Write(Format.MarkDown);
 }
Esempio n. 4
0
        private void Collect()
        {
            var processes         = Process.GetProcesses();
            var processMetrics    = processes.Select(x => new ProcessMetrics(x)).ToArray();
            var upTime            = uptimeProvider.GetValue();
            var metricsCollection = new MetricsCollection
            {
                ProcessMetricsCollection = processMetrics,
                Timestamp   = DateTime.UtcNow,
                Uptime      = upTime,
                MachineName = Environment.MachineName
            };

            Task.Run(() => MetricsAvailable(this, metricsCollection));
        }