protected async Task OnIsDue(LoadConfiguration configuration, CancellationToken cancellationToken) { if (LoadCollector == null) { // not supported MeasurementTimingService.ResetDue(configuration); return; } var loadAverage = await LoadCollector.GetLoadAverage(cancellationToken); if (loadAverage == null) { // N/A MeasurementTimingService.ResetDue(configuration); return; } await Mediator.Publish(new OutboundMeasurement() { Name = "load", Item = new LoadMeasurement() { Timestamp = DateTime.UtcNow, Hostname = System.Net.Dns.GetHostName(), LastOneMinute = loadAverage.OneMinute, LastFiveMinutes = loadAverage.FiveMinutes, LastFifteenMinutes = loadAverage.FifteenMinutes, }, }, cancellationToken); MeasurementTimingService.ResetDue(configuration); }
protected override void OnApplicationStartRequested() { base.OnApplicationStartRequested(); if (!Configuration.Enable) { return; } MeasurementTimingService.Register(Configuration, OnIsDue); // if on windows, start collector switch (Environment.OSVersion.Platform) { case PlatformID.Unix: LoadCollector = new LinuxLoadCollector(); break; case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.WinCE: case PlatformID.Win32NT: LoadCollector = new WindowsLoadCollector(); break; case PlatformID.MacOSX: // not supported default: break; } LoadCollector?.Start(); }