diff options
| author | nasr <nsrddyn@gmail.com> | 2025-12-01 00:18:20 +0100 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2025-12-01 00:18:20 +0100 |
| commit | 82b1d78a309ac189df45877846e74587f214ac10 (patch) | |
| tree | d314adf4394741159cb3f0333f713083e1cae84a /src | |
| parent | a9b5026b5a1fc3f042d82ed25c6769ebef15efc2 (diff) | |
feature: added methods for gathering temporary system information
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/main/infrastructure/Resources.scala | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/src/main/scala/main/infrastructure/Resources.scala b/src/main/scala/main/infrastructure/Resources.scala index 1b51003..8d05b27 100644 --- a/src/main/scala/main/infrastructure/Resources.scala +++ b/src/main/scala/main/infrastructure/Resources.scala @@ -8,23 +8,36 @@ import zio._ class Resources { - // Top levle instance - val sysInfo: SystemInfo = new SystemInfo + /** + * + * Creating instances for gathering the data + * + */ + private val sysInfo: SystemInfo = new SystemInfo + private val hardware = sysInfo.getHardware + private val memory = hardware.getMemory + private val sensors = hardware.getSensors + private val cpu = hardware.getProcessor - 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") + /** + * + * Platform Mehtods + * */ def getPlatform: ZIO[Any, Throwable, Unit] = { ZIO.attempt { - println(SysInfo.getHardware) + println(sysInfo.getHardware) }.catchAll { error => Console.printError(s"failed :$error")} } - def getCpuFrequency: ZIO[Any, Throwable, Unit] = { + /** + * + * CPU methods + * + * */ + def getCpuInfo: ZIO[Any, Throwable, Unit] = { ZIO.attempt { /* * 227 oshi/hardware/CentralProcessor.java @@ -34,14 +47,28 @@ class Resources { println("logical cores: " + cpu.getLogicalProcessorCount()) println("cores: " + cpu.getPhysicalProcessorCount()) println("temperature: " + sensors.getCpuTemperature()) + + + // TODO: assign the information in here to a method } } - def getMemoryUsage: ZIO[Any, Throwable, Unit] = { - + /** + * + * Memory specific methods + * + * */ - } + def getRamInfo: ZIO[Any, Throwable, Unit] = { - // TODO: add method for viewing threads + ZIO.attempt { + + memory.getTotal() + val totalMemory = memory.getTotal() + println("total memory" +totalMemory) + }.catchAll { error => Console.printError(s"failed: $error")} + } } + +// TODO: add method for viewing threads |
