/// <summary> /// Method that is called when the GUI statistics should be updated /// </summary> private void UpdateGuiStatistics(RamUsage ramUsage) { Dispatcher.Invoke(() => { string ramTotal = (ramUsage.RamTotal / 1024 / 1024 / 1024).ToString("F2") + " GB"; string ramAvailable = (ramUsage.TotalUsed / 1024 / 1024 / 1024).ToString("F2") + " GB"; CgRamUsage.Scales[0].Pointers[0].Value = ramUsage.UsagePercentage; CgRamUsage.GaugeHeader = ((string)Application.Current.FindResource("GaugeRamUsage"))?.Replace("%", ramUsage.UsagePercentage.ToString("F2") + "%"); LblTotalPhysicalMemory.Content = ramTotal; LblAvailablePhysicalMemory.Content = ramAvailable; _warningBrush.Color = ramUsage.UsagePercentage >= Properties.Settings.Default.WarningLevel ? Colors.Red : Colors.Green; if (!Properties.Settings.Default.NotifyIconStatistics) { return; } string tooltipText = "MemPlus"; tooltipText += Environment.NewLine; tooltipText += (string)Application.Current.FindResource("TotalPhysicalMemory") + " " + ramTotal; tooltipText += Environment.NewLine; tooltipText += (string)Application.Current.FindResource("UsedPhysicalMemory") + " " + ramAvailable; TbiIcon.ToolTipText = tooltipText; }); }
/// <summary> /// Method that is called when a RamUsage object was removed /// </summary> /// <param name="ramUsage">The RamUsage object that was removed</param> private void RamUsageRemovedEvent(RamUsage ramUsage) { Dispatcher.Invoke(() => { LsvStatistics.Items.Remove(ramUsage); }); }
public static async Task LogThresholdReached(RamUsage ramUsage, IBaseServerEventLogger serverEventLogger) { var server = ramUsage.Server; var usageInPercentage = RamUsageController.GetRAMUsageInPercent(ramUsage).ToString("#.#"); await serverEventLogger.LogEvent( $@"RAM threshold reached for {server.Name} server", $@"{server.Name} server reached RAM usage threshold. Current RAM usage is {usageInPercentage}%", EventType.RAMUsageThresholdReached, server ); }
/// <summary> /// Method that is called when a RamUsage object was added /// </summary> /// <param name="ramUsage">The RamUsage object that was added</param> private void RamUsageAddedEvent(RamUsage ramUsage) { Dispatcher.Invoke(() => { LsvStatistics.Items.Add(ramUsage); if (!_autoScroll) { return; } LsvStatistics.ScrollIntoView(LsvStatistics.Items[LsvStatistics.Items.Count - 1]); }); }
public async Task RamUsageTest() { var widget = new RamUsage(); var request = MetricQueryRequest.Create(widget); var handler = new RamUsageQuery(); await handler.Handle(request, CancellationToken.None).ConfigureAwait(false); Assert.AreEqual(State.Ok, widget.State); Assert.IsTrue(widget.Value > 0); }
private async Task RAMEventLoggerChecker(RamUsage ramUsage) { var notificationThreshold = await _unitOfWork.NotificationThresholds.Get( q => q.ServerId == ramUsage.ServerId ); if (notificationThreshold == null) { return; } if (GetRAMUsageInPercent(ramUsage) >= notificationThreshold.RamUsageThresholdInPercentage) { await RAMServerEventLogger.LogThresholdReached(ramUsage, _baseServerEventLogger); } }
public override Embed Render() { var builder = new EmbedBuilder() { Color = Color.Green, Description = "(¬ ¬ ) Q-queste statistiche n-non sono p-per te b-baka." }; builder.WithAuthor(Name, Avatar); builder.AddField("CPU usage", Utils.Formatting.BarChart(44, (int)CpuUsage)); builder.AddInlineField("RAM usage", RamUsage.ToString("00.##" + " mb")); builder.AddInlineField("Disk usage", DiskUsage.ToString("##0.00") + " IOPS"); builder.AddInlineField("Status", "I love cats!"); builder.AddInlineField("Other info", "I'm a loli."); builder.AddInlineField("Other info", "I'm a loli."); builder.AddInlineField("Other info", "I'm a loli."); return(builder.Build()); }
public void Start() { _clients = new List <TcpClient>(); _webSocket = new WebSocketServer(5050); _webSocket.ClientDisconnected += _webSocket_ClientDisconnected; _webSocket.NewMessage += _webSocket_NewMessage; _webSocket.Start(); _cpuLoad = new CpuLoad(); _cpuLoad.Update += _cpuLoad_Update; _ramUsage = new RamUsage(); _ramUsage.Update += _ramUsage_Update; _diskActivity = new DiskActivity(); _diskActivity.Update += _diskActivity_Update; _httpServer = new CCHttpServer(); }
public static double GetRAMUsageInPercent(RamUsage ramUsage) { return((ramUsage.UsageInBytes / ramUsage.TotalAvailableInBytes) * 100); }