aboutsummaryrefslogtreecommitdiffstats
path: root/LoadAverageMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /LoadAverageMeter.c
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'LoadAverageMeter.c')
-rw-r--r--LoadAverageMeter.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c
index 850f802..d292a7c 100644
--- a/LoadAverageMeter.c
+++ b/LoadAverageMeter.c
@@ -8,51 +8,37 @@ in the source distribution for its full text.
#include "LoadAverageMeter.h"
#include "CRT.h"
-
-#include <assert.h>
+#include "Platform.h"
/*{
#include "Meter.h"
}*/
int LoadAverageMeter_attributes[] = {
- LOAD_AVERAGE_FIFTEEN, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_ONE
+ LOAD_AVERAGE_ONE, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_FIFTEEN
};
int LoadMeter_attributes[] = { LOAD };
-static inline void LoadAverageMeter_scan(double* one, double* five, double* fifteen) {
- int activeProcs, totalProcs, lastProc;
- *one = 0; *five = 0; *fifteen = 0;
- FILE *fd = fopen(PROCDIR "/loadavg", "r");
- if (fd) {
- int total = fscanf(fd, "%32lf %32lf %32lf %32d/%32d %32d", one, five, fifteen,
- &activeProcs, &totalProcs, &lastProc);
- (void) total;
- assert(total == 6);
- fclose(fd);
- }
-}
-
static void LoadAverageMeter_setValues(Meter* this, char* buffer, int size) {
- LoadAverageMeter_scan(&this->values[2], &this->values[1], &this->values[0]);
- snprintf(buffer, size, "%.2f/%.2f/%.2f", this->values[2], this->values[1], this->values[0]);
+ Platform_getLoadAverage(&this->values[0], &this->values[1], &this->values[2]);
+ snprintf(buffer, size, "%.2f/%.2f/%.2f", this->values[0], this->values[1], this->values[2]);
}
static void LoadAverageMeter_display(Object* cast, RichString* out) {
Meter* this = (Meter*)cast;
char buffer[20];
- sprintf(buffer, "%.2f ", this->values[2]);
- RichString_write(out, CRT_colors[LOAD_AVERAGE_FIFTEEN], buffer);
+ sprintf(buffer, "%.2f ", this->values[0]);
+ RichString_write(out, CRT_colors[LOAD_AVERAGE_ONE], buffer);
sprintf(buffer, "%.2f ", this->values[1]);
RichString_append(out, CRT_colors[LOAD_AVERAGE_FIVE], buffer);
- sprintf(buffer, "%.2f ", this->values[0]);
- RichString_append(out, CRT_colors[LOAD_AVERAGE_ONE], buffer);
+ sprintf(buffer, "%.2f ", this->values[2]);
+ RichString_append(out, CRT_colors[LOAD_AVERAGE_FIFTEEN], buffer);
}
static void LoadMeter_setValues(Meter* this, char* buffer, int size) {
double five, fifteen;
- LoadAverageMeter_scan(&this->values[0], &five, &fifteen);
+ Platform_getLoadAverage(&this->values[0], &five, &fifteen);
if (this->values[0] > this->total) {
this->total = this->values[0];
}
@@ -79,6 +65,7 @@ MeterClass LoadAverageMeter_class = {
.attributes = LoadAverageMeter_attributes,
.name = "LoadAverage",
.uiName = "Load average",
+ .description = "Load averages: 1 minute, 5 minutes, 15 minutes",
.caption = "Load average: "
};
@@ -94,5 +81,6 @@ MeterClass LoadMeter_class = {
.attributes = LoadMeter_attributes,
.name = "Load",
.uiName = "Load",
+ .description = "Load: average of ready processes in the last minute",
.caption = "Load: "
};

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