Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

updated OS telemetry sample #89

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Source/OS/OS_Telemetry/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Meadow;
using Meadow.Devices;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace OS_Telemetry;
Expand All @@ -14,19 +16,27 @@ public override async Task Run()
{
// This is F7-specific
var memoryInfo = (Device.PlatformOS as F7PlatformOS)?.GetMemoryAllocationInfo();
var gcAlloc = GC.GetTotalMemory(false);

if (memoryInfo.HasValue)
{
Resolver.Log.Info($" Memory");
Resolver.Log.Info($" Total memory: {memoryInfo.Value.Arena}");
Resolver.Log.Info($" Total allocated: {memoryInfo.Value.TotalAllocated}");
Resolver.Log.Info($" Total free: {memoryInfo.Value.TotalFree}");
Resolver.Log.Info($" Total memory: {memoryInfo.Value.Arena:n0}");
Resolver.Log.Info($" Total allocated: {memoryInfo.Value.TotalAllocated:n0}");
Resolver.Log.Info($" Total free: {memoryInfo.Value.TotalFree:n0}");
Resolver.Log.Info($" GC Allocated: {gcAlloc:n0}");
}

var load = (Device.PlatformOS as F7PlatformOS)?.ProcessorLoad();

var load = Device.PlatformOS?.GetProcessorUtilization().Average();
Resolver.Log.Info($" Processor");
Resolver.Log.Info($" Usage: {load}%");

var storage = Device.PlatformOS?.GetStorageInformation();
Resolver.Log.Info($" Storage");
Resolver.Log.Info($" {storage[0].SpaceAvailable.MegaBytes:0.00}/{storage[0].Size.MegaBytes:0.0}MB");
Resolver.Log.Info($"\r\n");

await Task.Delay(5000);
}
}
Expand Down
Loading