diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/main/infrastructure/Resources.scala | 24 |
1 files changed, 16 insertions, 8 deletions
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 } |
