profesorfalken / jsensors Goto Github PK
View Code? Open in Web Editor NEWMonitorize all the hardware sensors of your PC using Java
License: Apache License 2.0
Monitorize all the hardware sensors of your PC using Java
License: Apache License 2.0
Hi, your download link https://github.com/profesorfalken/profesorfalken.github.io/raw/master/files/jSensors-2.2-jar-with-dependencies.jar
in README is leading to private repo and unavailable
This function is called when the sensors lib is not exist in Linux OS then jSensor will create a Lib on a temp path from JAR resource. On Red Hat Enterprise Linux, the created file does not exist after some time. It can be fixed as the below code.
public static String generateLibTmpPath(String path, String libName) {
if (tempFile == null || !tempFile.exists()) {
InputStream in = SensorsUtils.class.getResourceAsStream(path + libName);
try {
tempFile = File.createTempFile(libName, "");
tempFile.deleteOnExit();
byte[] buffer = new byte[1024];
int read;
FileOutputStream fos = new FileOutputStream(tempFile);
while ((read = in.read(buffer)) != -1) {
fos.write(buffer, 0, read);
}
fos.close();
in.close();
} catch (IOException ex) {
LOGGER.error("Cannot generate temporary file", ex);
return "";
}
}
return tempFile.getAbsolutePath();
}
I want to monitor hardware resources and output the values (temp, fan, load) onto a screen in realtime, which means fresh values at least every second. But I am wondering when I use
JSensors.get.components();
it takes around 5 seconds or more. When I output values in realtime without calling JSensors.get.components();
every time the values are not refreshing...
Is it not possible to stream hardware statistics in realtime?
It detects the cpu and gpu names but not showing gpu temperature.
cpu - i5 11400
gpu - Rx 6400
works fine with cpu .
i have even added new openhardware.dll file
These 2 lines use a deprecated JNA method com.sun.jna.Native.loadLibrary(String,Class). It can be replaced with the com.sun.jna.Native.load(String,Class) method.
fun main() {
val components = JSensors.get.components()
val cpus = components.cpus
if (cpus != null) {
for (cpu in cpus) {
println("Found CPU component: " + cpu.name)
if (cpu.sensors != null) {
println("Sensors: ")
//Print temperatures
val temps = cpu.sensors.temperatures
for (temp in temps) {
println(temp.name + ": " + temp.value + " C")
}
//Print fan speed
val fans = cpu.sensors.fans
for (fan in fans) {
println(fan.name + ": " + fan.value + " RPM")
}
}
}
}
}
ouput
Found CPU component: AMD Ryzen 5 3600X 6-Core Processor
Sensors:
Found CPU component: AMD Ryzen 5 3600X 6-Core Processor
Sensors:
I've been running the code from readme.md but i got cpus and gpus list size equals to 0.
CPU: AMD Athlon 64
GPU: GTX 950 Strix
What's the problem, man? 😄
Hello, I tried to use jSensors for a university project, but I always get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.profesorfalken.jsensors.SensorsConfig.(SensorsConfig.java:33)
at com.profesorfalken.jsensors.JSensors.(JSensors.java:51)
at com.profesorfalken.jsensors.JSensors.(JSensors.java:41)
at monitoradordetemperatura.MonitoradorDeTemperatura.main(MonitoradorDeTemperatura.java:25)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
C:\Users\YiazmaT\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
FALHA NA CONSTRUÇÃO (tempo total: 1 segundo)
Any Ideas on how to solve it? I'm just running the basic tests on README.
It says that the problem is on this line:
Components components = JSensors.get.components();
Thanks!
i copy-past this code from main page
` Components components = JSensors.get.components();
List<Cpu> cpus = components.cpus;
if (cpus != null) {
for (final Cpu cpu : cpus) {
System.out.println("Found CPU component: " + cpu.name);
if (cpu.sensors != null) {
System.out.println("Sensors: ");
//Print temperatures
List<Temperature> temps = cpu.sensors.temperatures;
for (final Temperature temp : temps) {
System.out.println(temp.name + ": " + temp.value + " C");
}
//Print fan speed
List<Fan> fans = cpu.sensors.fans;
for (final Fan fan : fans) {
System.out.println(fan.name + ": " + fan.value + " RPM");
}
}
}
}`
but output is this:
` Found CPU component: Intel Core i7-7700HQ
Sensors:
Process finished with exit code 0`
if i chek size of cpu.sensors.temperatures and cpu.sensors.fan are 0
any suggestion?
The jar file is not executable anymore and I can't even find the GUI class.
I'm running a basic piece of code to get the GPU's temps, but it never finishes running, here is the code:
import java.util.Date;
import java.util.List;
import com.profesorfalken.jsensors.JSensors;
import com.profesorfalken.jsensors.model.components.Components;
import com.profesorfalken.jsensors.model.components.Cpu;
import com.profesorfalken.jsensors.model.components.Gpu;
import com.profesorfalken.jsensors.model.sensors.Temperature;
public class App {
public static void main(String[] args) {
Components components = JSensors.get.components();
List<Gpu> gpus = components.gpus;
if (gpus != null) {
List<Temperature> temps = gpus.get(0).sensors.temperatures;
System.out.println(temps.size());
for (Temperature temp : temps) {
System.out.println(temp.name + ": " + temp.value);
}
}
System.out.println("At the end");
}
}
It prints "At the end", but never stops running.
I have an i5 8600K, which gets recognized by the software. It shows the Load of each core but not the Temperature?
Is there something I or you can do to help me?
??
This would add support for modern CPUs and AMD Cpus
https://github.com/LibreHardwareMonitor/LibreHardwareMonitor Fixing #15
java.lang.ArrayIndexOutOfBoundsException: 1
at com.profesorfalken.jsensors.manager.SensorsManager.getSensors(SensorsManager.java:100)
at com.profesorfalken.jsensors.manager.SensorsManager.getCpu(SensorsManager.java:66)
at com.profesorfalken.jsensors.manager.SensorsManager.getComponents(SensorsManager.java:54)
at com.profesorfalken.jsensors.SensorsLocator.getComponents(SensorsLocator.java:34)
at com.profesorfalken.jsensors.JSensors.components(JSensors.java:73)
at org.jutils.jhardware.util.TemperatureUtils.getCpuTemperatureByjSensors(TemperatureUtils.java:41)
at org.jutils.jhardware.util.TemperatureUtils.getCpuTemperatureForWindows(TemperatureUtils.java:59)
at org.jutils.jhardware.info.processor.windows.WindowsProcessorInfo.parseInfo(WindowsProcessorInfo.java:54)
at org.jutils.jhardware.info.processor.AbstractProcessorInfo.getInfo(AbstractProcessorInfo.java:29)
at org.jutils.jhardware.info.processor.AbstractProcessorInfo.getInfo(AbstractProcessorInfo.java:25)
at org.jutils.jhardware.HardwareInfo.getProcessorInfo(HardwareInfo.java:52)
I execute this:
`Components components = JSensors.get.components();
List<Cpu> cpus = components.cpus;
if (cpus != null) {
for (final Cpu cpu : cpus) {
System.out.println("Found CPU component: " + cpu.name);
if (cpu.sensors != null) {
System.out.println("Sensors: ");
//Print temperatures
List<Temperature> temps = cpu.sensors.temperatures;
for (final Temperature temp : temps) {
System.out.println(temp.name + ": " + temp.value + " C");
}
//Print fan speed
List<Fan> fans = cpu.sensors.fans;
for (final Fan fan : fans) {
System.out.println(fan.name + ": " + fan.value + " RPM");
}
}
}
}`
and i take this:
[main] INFO com.profesorfalken.jsensors.manager.unix.UnixSensorsManager - Cannot find library in system, using embedded one [main] ERROR com.profesorfalken.jsensors.manager.unix.UnixSensorsManager - Cannot initialize sensors
I use Debian 11.
jSensors can't find any temperature data for a Ryzen 5 3600, usages are reported but sensor data is not found even when jSensors is run as admin with this CPU
ok i opened this project in intelij, but theres no public static boid main and u cant run it :/
There is a new version of OpenHardwareMonitor available.
http://openhardwaremonitor.org/
can't read the templature, output is
"
Found CPU component: Intel Core i5-3320M
Sensors:
Temp CPU Core #1: 0.0 C
Temp CPU Core #2: 0.0 C
Temp CPU Package: 0.0 C
Load CPU Core #1: 35.22728
Load CPU Core #2: 26.13636
Load CPU Total: 30.68182
Load Memory: 74.63326
Found disk component: Generic Hard Disk
Sensors:
Load Used Space: 83.86135
", my OS is window 10
i added jSensors as a maven dependecy to my project and i am trying to get temp's in a rest controller, so when i run my applicatioin with intellij idea, i get this message
2019-07-13 23:31:11.881 WARN 18120 --- [nio-8080-exec-1] com.profesorfalken.jsensors.JSensors : You have not executed jSensors in Administrator mode, so CPU temperature sensors will not be detected.
how could i solve?
I've updated the latest version of OpenHardwareMonitorLib (the 0.8.0 version) in the jar file, but still the code fails to detect the temperature. I can understand if this is not supported by my computer, but when I run the actual Open Hardware Monitor executable, it picks up the temperatures.
How can I know if my computer can support this?
how do i get RPM from the fan connected to cpu fan?
thank you.
@profesorfalken
I include all .jar files and try to run example code which is
List cpus = components.cpus;
if (cpus != null) {
for (final Cpu cpu : cpus) {
System.out.println("Found CPU component: " + cpu.name);
if (cpu.sensors != null) {
System.out.println("Sensors: ");//Print temperatures List<Temperature> temps = cpu.sensors.temperatures; for (final Temperature temp : temps) { System.out.println(temp.name + ": " + temp.value + " C"); } //Print fan speed List<Fan> fans = cpu.sensors.fans; for (final Fan fan : fans) { System.out.println(fan.name + ": " + fan.value + " RPM"); } } } }
cpus.size() getting 0;
But there is no ouput also there is no error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.