summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-11-23 17:34:44 +1100
committerNathan Scott <nathans@redhat.com>2020-11-23 17:34:44 +1100
commit003f2c06a4a346ecfcc9272700a6fa71d381c43e (patch)
tree03ac4388ba32e929e392e234dd99a19674295ac2 /linux
parent17eeb7573abe504a63e10621d67cae65e2f620aa (diff)
parent82a69ee87af4aec4b5520d55c4949f287f4e6708 (diff)
Merge branch 'cleanup-init-done' into master
Diffstat (limited to 'linux')
-rw-r--r--linux/Platform.c22
-rw-r--r--linux/Platform.h8
2 files changed, 26 insertions, 4 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;
diff --git a/linux/Platform.h b/linux/Platform.h
index dbd6bb46..280b997c 100644
--- a/linux/Platform.h
+++ b/linux/Platform.h
@@ -26,10 +26,14 @@ extern const SignalItem Platform_signals[];
extern const unsigned int Platform_numberOfSignals;
-void Platform_setBindings(Htop_Action* keys);
-
extern const MeterClass* const Platform_meterTypes[];
+void Platform_init(void);
+
+void Platform_done(void);
+
+void Platform_setBindings(Htop_Action* keys);
+
int Platform_getUptime(void);
void Platform_getLoadAverage(double* one, double* five, double* fifteen);

© 2014-2024 Faster IT GmbH | imprint | privacy policy