public Dictionary <int, string> ObtainInstanceNames() { lock (sync) { var observations = processIdPerfCounter.Observe(); return(BuildProcessIdToInstanceNameMap(observations)); } }
private DiskMetrics[] GetDiskMetricsInternal() { var observations = counter.Observe(); var data = new DiskMetrics[observations.Length]; for (var i = 0; i < observations.Length; i++) { data[i] = observations[i].Value; data[i].Drive = observations[i].Instance; } return(data); }
private DiskMetrics GetDiskMetricsInternal() { return(new DiskMetrics { QueueLength = (int)queueLengthCounter.Observe(), Load = Math.Max(0, (100 - idleTimeCounter.Observe()) / 100), ReadBytesPerSecond = (long)readBytesPerSecondCounter.Observe(), WriteBytesPerSecond = (long)writeBytesPerSecondCounter.Observe(), ReadLatency = TimeSpan.FromSeconds(readLatencyCounter.Observe()), WriteLatency = TimeSpan.FromSeconds(writeLatencyCounter.Observe()), ReadsPerSecond = (int)readsPerSecondCounter.Observe(), WritesPerSecond = (int)writesPerSecondCounter.Observe(), Drive = driveName }); }
/// <summary> /// Returns info about GC and heap for the process specified in the constructor. /// <para> /// Gen1 collection also triggers gen0, and gen2 collection triggers both gen1 and gen0. /// </para> /// <para> /// That's why after gen2 collection all /// <see cref="GarbageCollectionInfo.Gen0CollectionsSinceStart"/>, /// <see cref="GarbageCollectionInfo.Gen1CollectionsSinceStart"/> and /// <see cref="GarbageCollectionInfo.Gen2CollectionsSinceStart"/> /// will increment. /// </para> /// </summary> public ManagedMemoryInfo GetManagedMemoryInfo() { var value = counter.Observe(); if (pid == ProcessUtility.CurrentProcessId) { value.GC.Gen0CollectionsSinceStart = GC.CollectionCount(0); value.GC.Gen1CollectionsSinceStart = GC.CollectionCount(1); value.GC.Gen2CollectionsSinceStart = GC.CollectionCount(2); } value.GC.Gen0CollectionsDelta = Math.Max(0, value.GC.Gen0CollectionsSinceStart - previous.Gen0CollectionsSinceStart); value.GC.Gen1CollectionsDelta = Math.Max(0, value.GC.Gen1CollectionsSinceStart - previous.Gen1CollectionsSinceStart); value.GC.Gen2CollectionsDelta = Math.Max(0, value.GC.Gen2CollectionsSinceStart - previous.Gen2CollectionsSinceStart); previous = value.GC; return(value); }
public NetworkUsageMetrics GetNetworkMetrics() { var upInterfaces = ActiveNetworkInterfaceCache.Instance.GetUpInterfaces(); return(new NetworkUsageMetrics( counter .Observe() .Where(x => upInterfaces.Contains(ActiveNetworkInterfaceCache.GetAdapterIdentity(x.Instance))) .Select( x => { var val = x.Value; val.Interface = x.Instance; return val; }) .ToArray())); }
public static bool TryObserve <T>(this IPerformanceCounter <T> counter, out T value, Action <Exception> logError = null) { try { value = counter.Observe(); return(true); } catch (Exception e) { try { logError?.Invoke(e); } catch { // ignored } value = default; return(false); } }
private DiskMetrics GetDiskMetricsInternal() => counter.Observe();
public GlobalMemoryInfo GetGlobalMemoryInfo() { return(counter.Observe()); }
public int GetDotNetPhysicalThreadsCount() { return((int)physicalThreadsCounter.Observe()); }