diff --git a/src/sys.cpp b/src/sys.cpp index 157464e..124ea89 100644 --- a/src/sys.cpp +++ b/src/sys.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -51,10 +52,18 @@ void sys::getNetwork(Network* net, const std::string& device) { } void sys::detectHwmon(sysSensors* s, const std::string& platform) { - s->hwmon = getFirstDir("/sys/devices/platform/" + platform + "/hwmon"); + // we dont really need getFirstDir since its a static folder, but its useful for try/catch + try { + s->hwmon = getFirstDir("/sys/devices/platform/" + platform + "/hwmon"); + } catch (...) { + log(LOG::ERR, "sys::detectHwmon", "Can't open sys hwmon. Module loaded? Kernel params added?"); + return; + } } void sys::updateSensors(sysSensors* s) { + if(s->hwmon.length() < 1) + return; static char buf[8]; fastReadNum(s->hwmon + "/fan2_input", s->fan_speed[0]); fastReadNum(s->hwmon + "/fan7_input", s->fan_speed[1]);