diff options
author | Nathan Scott <nathans@redhat.com> | 2020-11-23 17:34:44 +1100 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2020-11-23 17:34:44 +1100 |
commit | 003f2c06a4a346ecfcc9272700a6fa71d381c43e (patch) | |
tree | 03ac4388ba32e929e392e234dd99a19674295ac2 /linux/Platform.c | |
parent | 17eeb7573abe504a63e10621d67cae65e2f620aa (diff) | |
parent | 82a69ee87af4aec4b5520d55c4949f287f4e6708 (diff) |
Merge branch 'cleanup-init-done' into master
Diffstat (limited to 'linux/Platform.c')
-rw-r--r-- | linux/Platform.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index ff20d133..aab2f45e 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -61,11 +61,12 @@ in the source distribution for its full text. #include "zfs/ZfsArcStats.h" #include "zfs/ZfsCompressedArcMeter.h" +#ifdef HAVE_LIBSENSORS +#include <sensors/sensors.h> +#endif ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; -//static ProcessField defaultIoFields[] = { PID, IO_PRIORITY, USER, IO_READ_RATE, IO_WRITE_RATE, IO_RATE, COMM, 0 }; - int Platform_numberOfFields = LAST_PROCESSFIELD; const SignalItem Platform_signals[] = { @@ -112,6 +113,23 @@ static time_t Platform_Battery_cacheTime; static double Platform_Battery_cacheLevel = NAN; static ACPresence Platform_Battery_cacheIsOnAC; +void Platform_init(void) { + if (access(PROCDIR, R_OK) != 0) { + fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR); + exit(1); + } + +#ifdef HAVE_LIBSENSORS + sensors_init(NULL); +#endif +} + +void Platform_done(void) { +#ifdef HAVE_LIBSENSORS + sensors_cleanup(); +#endif +} + static Htop_Reaction Platform_actionSetIOPriority(State* st) { Panel* panel = st->panel; |