From d5a9237b42cd1751e8f353cbee0f01e974d6dfc4 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sun, 30 Nov 2025 17:30:25 +0100 Subject: checkpoint: started adding memory measurments --- src/main/scala/main/infrastructure/Resources.scala | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/scala/main/infrastructure/Resources.scala b/src/main/scala/main/infrastructure/Resources.scala index 0915d3b..1b51003 100644 --- a/src/main/scala/main/infrastructure/Resources.scala +++ b/src/main/scala/main/infrastructure/Resources.scala @@ -8,15 +8,18 @@ import zio._ class Resources { - val si: SystemInfo = new SystemInfo - val sensors = si.getHardware.getSensors - val cpu = si.getHardware.getProcessor + // Top levle instance + val sysInfo: SystemInfo = new SystemInfo + + val hardware = SysInfo.getHardware() + val sensors = SysInfo.getHardware.getSensors + val cpu = SysInfo.getHardware.getProcessor def failSafe: Unit = while (true) do if sensors.getCpuTemperature > 80 then println("overheat") def getPlatform: ZIO[Any, Throwable, Unit] = { ZIO.attempt { - println(si.getHardware) + println(SysInfo.getHardware) }.catchAll { error => Console.printError(s"failed :$error")} } @@ -27,13 +30,18 @@ class Resources { * 227 oshi/hardware/CentralProcessor.java * method takes long value as delay * */ - // println("load: " + cpu.getSystemCpuLoad(1000) * 1000) - // println("logical cores: " + cpu.getLogicalProcessorCount()) - // println("cores: " + cpu.getPhysicalProcessorCount()) - // println("temperature: " + sensors.getCpuTemperature()) + println("load: " + cpu.getSystemCpuLoad(1000) * 1000) + println("logical cores: " + cpu.getLogicalProcessorCount()) + println("cores: " + cpu.getPhysicalProcessorCount()) + println("temperature: " + sensors.getCpuTemperature()) } } + def getMemoryUsage: ZIO[Any, Throwable, Unit] = { + + + } + // TODO: add method for viewing threads } -- cgit v1.2.3-70-g09d2