Class SystemResources
- Namespace
- Arc4u.Diagnostics.Monitoring
- Assembly
- Arc4u.Diagnostics.dll
Monitor and log the information about the Process Cpu and Memory usage!
[Obsolete("Logging the CPU and memory usage is deprecated and will be removed in a future major version. Collect the .NET runtime and process metrics with OpenTelemetry instead (see https://arc4u-org.github.io/Arc4u/guides/diagnostics/index.html#log-cpu-and-memory-usage).")]
public sealed class SystemResources : IHostedService, IDisposable
- Inheritance
-
SystemResources
- Implements
- Inherited Members
Constructors
SystemResources(ILogger<SystemResources>, uint)
Initializes a new instance of the SystemResources class.
public SystemResources(ILogger<SystemResources> logger, uint internalPeriodInSeconds = 10)
Parameters
loggerILogger<SystemResources>The logger used to write the monitoring entries.
internalPeriodInSecondsuintThe interval, in seconds, between two measures. Must be greater than 0.
Exceptions
- ArgumentNullException
loggeris null.- ArgumentException
internalPeriodInSecondsis 0.
Properties
StartMonitoringDelayInSeconds
Define the delay the system will wait before starting the monitoring. Default is 10.
public uint StartMonitoringDelayInSeconds { get; set; }
Property Value
Methods
Dispose()
Releases the timer.
public void Dispose()
StartAsync(CancellationToken)
Starts the timer that collects and logs the CPU and memory usage, after StartMonitoringDelayInSeconds seconds and then every interval.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenNot used.
Returns
- Task
A completed task.
StopAsync(CancellationToken)
Stops the timer.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenNot used.
Returns
- Task
A completed task.