pass NULL to sensors_init() when the standard files exist in /etc/ (#19744)
Costa Tsaousis committed
Mar 2, 2025 at 15:27 UTC
e523030594bd829480afed8638627796044637c6
1 file changed
+8
-5
src/collectors/debugfs.plugin/module-libsensors.c
+8
-5
@@ -1217,11 +1217,14 @@ static int libsensors_update_every = 1;
1217
void *libsensors_thread(void *ptr __maybe_unused) {
1218
int update_every = libsensors_update_every;
1219
1220
- // first try the default directory for libsensors
1221
- FILE *fp = fopen("/etc/sensors3.conf", "r");
1222
- if(!fp) fp = sensors_open_file("NETDATA_CONFIG_DIR", CONFIG_DIR, "../sensors3.conf");
1223
- if(!fp) fp = sensors_open_file("NETDATA_CONFIG_DIR", CONFIG_DIR, "sensors3.conf");
1224
- if(!fp) fp = sensors_open_file("NETDATA_STOCK_CONFIG_DIR", LIBCONFIG_DIR, "sensors3.conf");
1220
+ FILE *fp = NULL;
1221
+ if(access("/etc/sensors3.conf", R_OK) != 0 &&
1222
+ access("/etc/sensors.conf", R_OK) != 0 &&
1223
+ access("/etc/sensors.d", R_OK | X_OK) != 0) {
1224
+ fp = sensors_open_file("NETDATA_CONFIG_DIR", CONFIG_DIR, "../sensors3.conf");
1225
+ if(!fp) fp = sensors_open_file("NETDATA_CONFIG_DIR", CONFIG_DIR, "sensors3.conf");
1226
+ if(!fp) fp = sensors_open_file("NETDATA_STOCK_CONFIG_DIR", LIBCONFIG_DIR, "sensors3.conf");
1227
+ }
1228
1229
if (sensors_init(fp) != 0) {
1230
nd_log(NDLS_COLLECTORS, NDLP_ERR, "cannot initialize libsensors - disabling sensors monitoring");