mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-15 21:44:36 +03:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
0384613450 | |||
649419abe5 | |||
2c4d730403 | |||
538d29b3f6 | |||
3e4f06d101 | |||
4a93a7e962 | |||
ef5b27f33a | |||
cc5af25e11 | |||
b10821aae9 |
36
CPUMeter.c
36
CPUMeter.c
@ -19,14 +19,14 @@ in the source distribution for its full text.
|
||||
#include <assert.h>
|
||||
|
||||
int CPUMeter_attributes[] = {
|
||||
CPU_NICE, CPU_NORMAL, CPU_KERNEL
|
||||
CPU_NICE, CPU_NORMAL, CPU_KERNEL, CPU_IOWAIT, CPU_IRQ, CPU_SOFTIRQ
|
||||
};
|
||||
|
||||
MeterType CPUMeter = {
|
||||
.setValues = CPUMeter_setValues,
|
||||
.display = CPUMeter_display,
|
||||
.mode = BAR_METERMODE,
|
||||
.items = 3,
|
||||
.items = 6,
|
||||
.total = 100.0,
|
||||
.attributes = CPUMeter_attributes,
|
||||
.name = "CPU",
|
||||
@ -71,10 +71,22 @@ void CPUMeter_setValues(Meter* this, char* buffer, int size) {
|
||||
ProcessList* pl = this->pl;
|
||||
int processor = this->param;
|
||||
double total = (double) pl->totalPeriod[processor];
|
||||
double cpu;
|
||||
this->values[0] = pl->nicePeriod[processor] / total * 100.0;
|
||||
this->values[1] = pl->userPeriod[processor] / total * 100.0;
|
||||
if (pl->expandSystemTime) {
|
||||
this->values[2] = pl->systemPeriod[processor] / total * 100.0;
|
||||
double cpu = MIN(100.0, MAX(0.0, (this->values[0]+this->values[1]+this->values[2])));
|
||||
this->values[3] = pl->ioWaitPeriod[processor] / total * 100.0;
|
||||
this->values[4] = pl->irqPeriod[processor] / total * 100.0;
|
||||
this->values[5] = pl->softIrqPeriod[processor] / total * 100.0;
|
||||
this->type->items = 6;
|
||||
cpu = MIN(100.0, MAX(0.0, (this->values[0]+this->values[1]+this->values[2]+
|
||||
this->values[3]+this->values[4]+this->values[5])));
|
||||
} else {
|
||||
this->values[2] = pl->systemAllPeriod[processor] / total * 100.0;
|
||||
this->type->items = 3;
|
||||
cpu = MIN(100.0, MAX(0.0, (this->values[0]+this->values[1]+this->values[2])));
|
||||
}
|
||||
snprintf(buffer, size, "%5.1f%%", cpu );
|
||||
}
|
||||
|
||||
@ -85,6 +97,23 @@ void CPUMeter_display(Object* cast, RichString* out) {
|
||||
sprintf(buffer, "%5.1f%% ", this->values[1]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], ":");
|
||||
RichString_append(out, CRT_colors[CPU_NORMAL], buffer);
|
||||
if (this->pl->expandSystemTime) {
|
||||
sprintf(buffer, "%5.1f%% ", this->values[2]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "sy:");
|
||||
RichString_append(out, CRT_colors[CPU_KERNEL], buffer);
|
||||
sprintf(buffer, "%5.1f%% ", this->values[0]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "ni:");
|
||||
RichString_append(out, CRT_colors[CPU_NICE], buffer);
|
||||
sprintf(buffer, "%5.1f%% ", this->values[3]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "wa:");
|
||||
RichString_append(out, CRT_colors[CPU_IOWAIT], buffer);
|
||||
sprintf(buffer, "%5.1f%% ", this->values[4]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "hi:");
|
||||
RichString_append(out, CRT_colors[CPU_IRQ], buffer);
|
||||
sprintf(buffer, "%5.1f%% ", this->values[4]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "si:");
|
||||
RichString_append(out, CRT_colors[CPU_SOFTIRQ], buffer);
|
||||
} else {
|
||||
sprintf(buffer, "%5.1f%% ", this->values[2]);
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "sys:");
|
||||
RichString_append(out, CRT_colors[CPU_KERNEL], buffer);
|
||||
@ -92,6 +121,7 @@ void CPUMeter_display(Object* cast, RichString* out) {
|
||||
RichString_append(out, CRT_colors[METER_TEXT], "low:");
|
||||
RichString_append(out, CRT_colors[CPU_NICE], buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void AllCPUsMeter_init(Meter* this) {
|
||||
int processors = this->pl->processorCount;
|
||||
|
22
CRT.c
22
CRT.c
@ -93,6 +93,9 @@ typedef enum ColorElements_ {
|
||||
CPU_NORMAL,
|
||||
CPU_KERNEL,
|
||||
HELP_BOLD,
|
||||
CPU_IOWAIT,
|
||||
CPU_IRQ,
|
||||
CPU_SOFTIRQ,
|
||||
LAST_COLORELEMENT
|
||||
} ColorElements;
|
||||
|
||||
@ -160,6 +163,7 @@ void CRT_done() {
|
||||
int CRT_readKey() {
|
||||
nocbreak();
|
||||
cbreak();
|
||||
nodelay(stdscr, FALSE);
|
||||
int ret = getch();
|
||||
halfdelay(CRT_delay);
|
||||
return ret;
|
||||
@ -250,6 +254,9 @@ void CRT_setColors(int colorScheme) {
|
||||
CRT_colors[CHECK_BOX] = A_BOLD;
|
||||
CRT_colors[CHECK_MARK] = A_NORMAL;
|
||||
CRT_colors[CHECK_TEXT] = A_NORMAL;
|
||||
CRT_colors[CPU_IOWAIT] = A_BOLD;
|
||||
CRT_colors[CPU_IRQ] = A_BOLD;
|
||||
CRT_colors[CPU_SOFTIRQ] = A_BOLD;
|
||||
} else if (CRT_colorScheme == COLORSCHEME_BLACKONWHITE) {
|
||||
CRT_colors[RESET_COLOR] = ColorPair(Black,White);
|
||||
CRT_colors[DEFAULT_COLOR] = ColorPair(Black,White);
|
||||
@ -302,6 +309,9 @@ void CRT_setColors(int colorScheme) {
|
||||
CRT_colors[CHECK_BOX] = ColorPair(Blue,White);
|
||||
CRT_colors[CHECK_MARK] = ColorPair(Black,White);
|
||||
CRT_colors[CHECK_TEXT] = ColorPair(Black,White);
|
||||
CRT_colors[CPU_IOWAIT] = ColorPair(Yellow,White);
|
||||
CRT_colors[CPU_IRQ] = ColorPair(Blue,White);
|
||||
CRT_colors[CPU_SOFTIRQ] = ColorPair(Blue,White);
|
||||
} else if (CRT_colorScheme == COLORSCHEME_BLACKONWHITE2) {
|
||||
CRT_colors[RESET_COLOR] = ColorPair(Black,Black);
|
||||
CRT_colors[DEFAULT_COLOR] = ColorPair(Black,Black);
|
||||
@ -354,6 +364,9 @@ void CRT_setColors(int colorScheme) {
|
||||
CRT_colors[CHECK_BOX] = ColorPair(Blue,Black);
|
||||
CRT_colors[CHECK_MARK] = ColorPair(Black,Black);
|
||||
CRT_colors[CHECK_TEXT] = ColorPair(Black,Black);
|
||||
CRT_colors[CPU_IOWAIT] = ColorPair(Yellow,Black);
|
||||
CRT_colors[CPU_IRQ] = A_BOLD | ColorPair(Blue,Black);
|
||||
CRT_colors[CPU_SOFTIRQ] = ColorPair(Blue,Black);
|
||||
} else if (CRT_colorScheme == COLORSCHEME_MIDNIGHT) {
|
||||
CRT_colors[RESET_COLOR] = ColorPair(White,Blue);
|
||||
CRT_colors[DEFAULT_COLOR] = ColorPair(White,Blue);
|
||||
@ -406,6 +419,9 @@ void CRT_setColors(int colorScheme) {
|
||||
CRT_colors[CHECK_BOX] = ColorPair(Cyan,Blue);
|
||||
CRT_colors[CHECK_MARK] = A_BOLD | ColorPair(White,Blue);
|
||||
CRT_colors[CHECK_TEXT] = A_NORMAL | ColorPair(White,Blue);
|
||||
CRT_colors[CPU_IOWAIT] = A_BOLD | ColorPair(Yellow,Blue);
|
||||
CRT_colors[CPU_IRQ] = A_BOLD | ColorPair(Black,Blue);
|
||||
CRT_colors[CPU_SOFTIRQ] = ColorPair(Black,Blue);
|
||||
} else if (CRT_colorScheme == COLORSCHEME_BLACKNIGHT) {
|
||||
CRT_colors[RESET_COLOR] = ColorPair(Cyan,Black);
|
||||
CRT_colors[DEFAULT_COLOR] = ColorPair(Cyan,Black);
|
||||
@ -458,6 +474,9 @@ void CRT_setColors(int colorScheme) {
|
||||
CRT_colors[CHECK_BOX] = ColorPair(Green,Black);
|
||||
CRT_colors[CHECK_MARK] = A_BOLD | ColorPair(Green,Black);
|
||||
CRT_colors[CHECK_TEXT] = ColorPair(Cyan,Black);
|
||||
CRT_colors[CPU_IOWAIT] = ColorPair(Yellow,Black);
|
||||
CRT_colors[CPU_IRQ] = A_BOLD | ColorPair(Blue,Black);
|
||||
CRT_colors[CPU_SOFTIRQ] = ColorPair(Blue,Black);
|
||||
} else {
|
||||
/* Default */
|
||||
CRT_colors[RESET_COLOR] = ColorPair(White,Black);
|
||||
@ -511,5 +530,8 @@ void CRT_setColors(int colorScheme) {
|
||||
CRT_colors[CHECK_BOX] = ColorPair(Cyan,Black);
|
||||
CRT_colors[CHECK_MARK] = A_BOLD;
|
||||
CRT_colors[CHECK_TEXT] = A_NORMAL;
|
||||
CRT_colors[CPU_IOWAIT] = ColorPair(Cyan,Black);
|
||||
CRT_colors[CPU_IRQ] = ColorPair(Yellow,Black);
|
||||
CRT_colors[CPU_SOFTIRQ] = ColorPair(Magenta,Black);
|
||||
}
|
||||
}
|
||||
|
3
CRT.h
3
CRT.h
@ -95,6 +95,9 @@ typedef enum ColorElements_ {
|
||||
CPU_NORMAL,
|
||||
CPU_KERNEL,
|
||||
HELP_BOLD,
|
||||
CPU_IOWAIT,
|
||||
CPU_IRQ,
|
||||
CPU_SOFTIRQ,
|
||||
LAST_COLORELEMENT
|
||||
} ColorElements;
|
||||
|
||||
|
11
ChangeLog
11
ChangeLog
@ -1,4 +1,15 @@
|
||||
|
||||
What's new in version 0.6.4
|
||||
|
||||
* Add an option to split the display of kernel time
|
||||
in the CPU meter into system, IO-wait, IRQ and soft-IRQ.
|
||||
(thanks to Philipp Richter)
|
||||
* --sort-key flag in the command-line, overriding the
|
||||
saved setting in .htoprc for the session.
|
||||
(thanks to Rodolfo Borges)
|
||||
* BUGFIX: Fixed string overflow on uptime display.
|
||||
(thanks to Marc Cahalan)
|
||||
|
||||
What's new in version 0.6.3
|
||||
|
||||
* Performance improvements: uses much less CPU than the
|
||||
|
@ -44,6 +44,15 @@ void ColumnsPanel_delete(Object* object) {
|
||||
free(this);
|
||||
}
|
||||
|
||||
int ColumnsPanel_fieldNameToIndex(const char* name) {
|
||||
for (int j = 1; j <= LAST_PROCESSFIELD; j++) {
|
||||
if (String_eq(name, Process_fieldNames[j])) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ColumnsPanel_update(Panel* super) {
|
||||
ColumnsPanel* this = (ColumnsPanel*) super;
|
||||
int size = Panel_getSize(super);
|
||||
@ -53,12 +62,9 @@ void ColumnsPanel_update(Panel* super) {
|
||||
this->settings->pl->fields = (ProcessField*) malloc(sizeof(ProcessField) * (size+1));
|
||||
for (int i = 0; i < size; i++) {
|
||||
char* text = ((ListItem*) Panel_get(super, i))->value;
|
||||
for (int j = 1; j <= LAST_PROCESSFIELD; j++) {
|
||||
if (String_eq(text, Process_fieldNames[j])) {
|
||||
int j = ColumnsPanel_fieldNameToIndex(text);
|
||||
if (j > 0)
|
||||
this->settings->pl->fields[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this->settings->pl->fields[size] = 0;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr);
|
||||
|
||||
void ColumnsPanel_delete(Object* object);
|
||||
|
||||
int ColumnsPanel_fieldNameToIndex(const char* name);
|
||||
|
||||
void ColumnsPanel_update(Panel* super);
|
||||
|
||||
HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch);
|
||||
|
@ -38,6 +38,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Split System Time into System/IO-Wait/Hard-IRQ/Soft-IRQ"), &(settings->pl->expandSystemTime)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,10 @@ in the source distribution for its full text.
|
||||
#define MAX_READ 2048
|
||||
#endif
|
||||
|
||||
#ifndef PER_PROCESSOR_FIELDS
|
||||
#define PER_PROCESSOR_FIELDS 20
|
||||
#endif
|
||||
|
||||
}*/
|
||||
|
||||
/*{
|
||||
@ -71,16 +75,27 @@ typedef struct ProcessList_ {
|
||||
int totalTasks;
|
||||
int runningTasks;
|
||||
|
||||
// Must match number of PER_PROCESSOR_FIELDS constant
|
||||
unsigned long long int* totalTime;
|
||||
unsigned long long int* userTime;
|
||||
unsigned long long int* systemTime;
|
||||
unsigned long long int* systemAllTime;
|
||||
unsigned long long int* idleTime;
|
||||
unsigned long long int* niceTime;
|
||||
unsigned long long int* ioWaitTime;
|
||||
unsigned long long int* irqTime;
|
||||
unsigned long long int* softIrqTime;
|
||||
unsigned long long int* stealTime;
|
||||
unsigned long long int* totalPeriod;
|
||||
unsigned long long int* userPeriod;
|
||||
unsigned long long int* systemPeriod;
|
||||
unsigned long long int* systemAllPeriod;
|
||||
unsigned long long int* idlePeriod;
|
||||
unsigned long long int* nicePeriod;
|
||||
unsigned long long int* ioWaitPeriod;
|
||||
unsigned long long int* irqPeriod;
|
||||
unsigned long long int* softIrqPeriod;
|
||||
unsigned long long int* stealPeriod;
|
||||
|
||||
unsigned long long int totalMem;
|
||||
unsigned long long int usedMem;
|
||||
@ -102,6 +117,7 @@ typedef struct ProcessList_ {
|
||||
bool treeView;
|
||||
bool highlightBaseName;
|
||||
bool highlightMegabytes;
|
||||
bool expandSystemTime;
|
||||
#ifdef DEBUG
|
||||
FILE* traceFile;
|
||||
#endif
|
||||
@ -173,6 +189,16 @@ static inline int ProcessList_xread(ProcessList* this, vxscanf fn, void* buffer,
|
||||
|
||||
#endif
|
||||
|
||||
static inline void ProcessList_allocatePerProcessorBuffers(ProcessList* this, int procs) {
|
||||
unsigned long long int** bufferPtr = &(this->totalTime);
|
||||
unsigned long long int* buffer = calloc(procs * PER_PROCESSOR_FIELDS, sizeof(unsigned long long int));
|
||||
for (int i = 0; i < PER_PROCESSOR_FIELDS; i++) {
|
||||
*bufferPtr = buffer;
|
||||
bufferPtr++;
|
||||
buffer += procs;
|
||||
}
|
||||
}
|
||||
|
||||
ProcessList* ProcessList_new(UsersTable* usersTable) {
|
||||
ProcessList* this;
|
||||
this = malloc(sizeof(ProcessList));
|
||||
@ -198,16 +224,9 @@ ProcessList* ProcessList_new(UsersTable* usersTable) {
|
||||
} while (String_startsWith(buffer, "cpu"));
|
||||
fclose(status);
|
||||
this->processorCount = procs - 1;
|
||||
this->totalTime = calloc(procs, sizeof(long long int));
|
||||
this->userTime = calloc(procs, sizeof(long long int));
|
||||
this->systemTime = calloc(procs, sizeof(long long int));
|
||||
this->niceTime = calloc(procs, sizeof(long long int));
|
||||
this->idleTime = calloc(procs, sizeof(long long int));
|
||||
this->totalPeriod = calloc(procs, sizeof(long long int));
|
||||
this->userPeriod = calloc(procs, sizeof(long long int));
|
||||
this->systemPeriod = calloc(procs, sizeof(long long int));
|
||||
this->nicePeriod = calloc(procs, sizeof(long long int));
|
||||
this->idlePeriod = calloc(procs, sizeof(long long int));
|
||||
|
||||
ProcessList_allocatePerProcessorBuffers(this, procs);
|
||||
|
||||
for (int i = 0; i < procs; i++) {
|
||||
this->totalTime[i] = 1;
|
||||
this->totalPeriod[i] = 1;
|
||||
@ -228,6 +247,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable) {
|
||||
this->treeView = false;
|
||||
this->highlightBaseName = false;
|
||||
this->highlightMegabytes = false;
|
||||
this->expandSystemTime = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -238,16 +258,9 @@ void ProcessList_delete(ProcessList* this) {
|
||||
Vector_delete(this->processes2);
|
||||
Process_delete((Object*)this->prototype);
|
||||
|
||||
// Free first entry only;
|
||||
// other fields are offsets of the same buffer
|
||||
free(this->totalTime);
|
||||
free(this->userTime);
|
||||
free(this->systemTime);
|
||||
free(this->niceTime);
|
||||
free(this->idleTime);
|
||||
free(this->totalPeriod);
|
||||
free(this->userPeriod);
|
||||
free(this->systemPeriod);
|
||||
free(this->nicePeriod);
|
||||
free(this->idlePeriod);
|
||||
|
||||
#ifdef DEBUG
|
||||
fclose(this->traceFile);
|
||||
@ -596,7 +609,7 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
|
||||
}
|
||||
|
||||
void ProcessList_scan(ProcessList* this) {
|
||||
unsigned long long int usertime, nicetime, systemtime, idletime, totaltime;
|
||||
unsigned long long int usertime, nicetime, systemtime, systemalltime, idletime, totaltime;
|
||||
unsigned long long int swapFree;
|
||||
|
||||
FILE* status;
|
||||
@ -656,22 +669,37 @@ void ProcessList_scan(ProcessList* this) {
|
||||
}
|
||||
// Fields existing on kernels >= 2.6
|
||||
// (and RHEL's patched kernel 2.4...)
|
||||
systemtime += ioWait + irq + softIrq + steal;
|
||||
totaltime = usertime + nicetime + systemtime + idletime;
|
||||
systemalltime = systemtime + ioWait + irq + softIrq + steal;
|
||||
totaltime = usertime + nicetime + systemalltime + idletime;
|
||||
assert (usertime >= this->userTime[i]);
|
||||
assert (nicetime >= this->niceTime[i]);
|
||||
assert (systemtime >= this->systemTime[i]);
|
||||
assert (idletime >= this->idleTime[i]);
|
||||
assert (totaltime >= this->totalTime[i]);
|
||||
assert (systemalltime >= this->systemAllTime[i]);
|
||||
assert (ioWait >= this->ioWaitTime[i]);
|
||||
assert (irq >= this->irqTime[i]);
|
||||
assert (softIrq >= this->softIrqTime[i]);
|
||||
assert (steal >= this->stealTime[i]);
|
||||
this->userPeriod[i] = usertime - this->userTime[i];
|
||||
this->nicePeriod[i] = nicetime - this->niceTime[i];
|
||||
this->systemPeriod[i] = systemtime - this->systemTime[i];
|
||||
this->systemAllPeriod[i] = systemalltime - this->systemAllTime[i];
|
||||
this->idlePeriod[i] = idletime - this->idleTime[i];
|
||||
this->ioWaitPeriod[i] = ioWait - this->ioWaitTime[i];
|
||||
this->irqPeriod[i] = irq - this->irqTime[i];
|
||||
this->softIrqPeriod[i] = softIrq - this->softIrqTime[i];
|
||||
this->stealPeriod[i] = steal - this->stealTime[i];
|
||||
this->totalPeriod[i] = totaltime - this->totalTime[i];
|
||||
this->userTime[i] = usertime;
|
||||
this->niceTime[i] = nicetime;
|
||||
this->systemTime[i] = systemtime;
|
||||
this->systemAllTime[i] = systemalltime;
|
||||
this->idleTime[i] = idletime;
|
||||
this->ioWaitTime[i] = ioWait;
|
||||
this->irqTime[i] = irq;
|
||||
this->softIrqTime[i] = softIrq;
|
||||
this->stealTime[i] = steal;
|
||||
this->totalTime[i] = totaltime;
|
||||
}
|
||||
float period = (float)this->totalPeriod[0] / this->processorCount;
|
||||
|
@ -54,6 +54,10 @@ in the source distribution for its full text.
|
||||
#define MAX_READ 2048
|
||||
#endif
|
||||
|
||||
#ifndef PER_PROCESSOR_FIELDS
|
||||
#define PER_PROCESSOR_FIELDS 20
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -71,16 +75,27 @@ typedef struct ProcessList_ {
|
||||
int totalTasks;
|
||||
int runningTasks;
|
||||
|
||||
// Must match number of PER_PROCESSOR_FIELDS constant
|
||||
unsigned long long int* totalTime;
|
||||
unsigned long long int* userTime;
|
||||
unsigned long long int* systemTime;
|
||||
unsigned long long int* systemAllTime;
|
||||
unsigned long long int* idleTime;
|
||||
unsigned long long int* niceTime;
|
||||
unsigned long long int* ioWaitTime;
|
||||
unsigned long long int* irqTime;
|
||||
unsigned long long int* softIrqTime;
|
||||
unsigned long long int* stealTime;
|
||||
unsigned long long int* totalPeriod;
|
||||
unsigned long long int* userPeriod;
|
||||
unsigned long long int* systemPeriod;
|
||||
unsigned long long int* systemAllPeriod;
|
||||
unsigned long long int* idlePeriod;
|
||||
unsigned long long int* nicePeriod;
|
||||
unsigned long long int* ioWaitPeriod;
|
||||
unsigned long long int* irqPeriod;
|
||||
unsigned long long int* softIrqPeriod;
|
||||
unsigned long long int* stealPeriod;
|
||||
|
||||
unsigned long long int totalMem;
|
||||
unsigned long long int usedMem;
|
||||
@ -102,6 +117,7 @@ typedef struct ProcessList_ {
|
||||
bool treeView;
|
||||
bool highlightBaseName;
|
||||
bool highlightMegabytes;
|
||||
bool expandSystemTime;
|
||||
#ifdef DEBUG
|
||||
FILE* traceFile;
|
||||
#endif
|
||||
|
@ -139,6 +139,8 @@ bool Settings_read(Settings* this, char* fileName) {
|
||||
this->pl->highlightMegabytes = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "header_margin")) {
|
||||
this->header->margin = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "expand_system_time")) {
|
||||
this->pl->expandSystemTime = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "delay")) {
|
||||
this->delay = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "color_scheme")) {
|
||||
@ -195,6 +197,7 @@ bool Settings_write(Settings* this) {
|
||||
fprintf(fd, "highlight_megabytes=%d\n", (int) this->pl->highlightMegabytes);
|
||||
fprintf(fd, "tree_view=%d\n", (int) this->pl->treeView);
|
||||
fprintf(fd, "header_margin=%d\n", (int) this->header->margin);
|
||||
fprintf(fd, "expand_system_time=%d\n", (int) this->pl->expandSystemTime);
|
||||
fprintf(fd, "color_scheme=%d\n", (int) this->colorScheme);
|
||||
fprintf(fd, "delay=%d\n", (int) this->delay);
|
||||
fprintf(fd, "left_meters=");
|
||||
|
2
String.c
2
String.c
@ -96,7 +96,7 @@ void String_printPointer(void* p) {
|
||||
printf("%p", p);
|
||||
}
|
||||
|
||||
inline int String_eq(char* s1, char* s2) {
|
||||
inline int String_eq(const char* s1, const char* s2) {
|
||||
if (s1 == NULL || s2 == NULL) {
|
||||
if (s1 == NULL && s2 == NULL)
|
||||
return 1;
|
||||
|
2
String.h
2
String.h
@ -39,7 +39,7 @@ void String_printInt(int i);
|
||||
|
||||
void String_printPointer(void* p);
|
||||
|
||||
inline int String_eq(char* s1, char* s2);
|
||||
inline int String_eq(const char* s1, const char* s2);
|
||||
|
||||
char** String_split(char* s, char sep);
|
||||
|
||||
|
@ -165,4 +165,5 @@ void TraceScreen_run(TraceScreen* this) {
|
||||
kill(child, SIGTERM);
|
||||
waitpid(child, NULL, 0);
|
||||
fclose(strace);
|
||||
CRT_enableDelay();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void UptimeMeter_setValues(Meter* this, char* buffer, int len) {
|
||||
if (days > this->total) {
|
||||
this->total = days;
|
||||
}
|
||||
char daysbuf[10];
|
||||
char daysbuf[15];
|
||||
if (days > 100) {
|
||||
sprintf(daysbuf, "%d days(!), ", days);
|
||||
} else if (days > 1) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([htop],[0.6.3],[loderunner@users.sourceforge.net])
|
||||
AC_INIT([htop],[0.6.4],[loderunner@users.sourceforge.net])
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_SRCDIR([htop.c])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
|
2
htop.1
2
htop.1
@ -1,4 +1,4 @@
|
||||
.TH "htop" "1" "0.6.3" "Bartosz Fenski <fenio@o2.pl>" "Utils"
|
||||
.TH "htop" "1" "0.6.4" "Bartosz Fenski <fenio@o2.pl>" "Utils"
|
||||
.SH "NAME"
|
||||
htop \- interactive process viewer
|
||||
.SH "SYNTAX"
|
||||
|
34
htop.c
34
htop.c
@ -46,12 +46,13 @@ void printHelpFlag() {
|
||||
printf("Released under the GNU GPL.\n\n");
|
||||
printf("-d DELAY Delay between updates, in tenths of seconds\n\n");
|
||||
printf("-u USERNAME Show only processes of a given user\n\n");
|
||||
printf("--sort-key COLUMN Sort by this column (use --sort-key help for a column list)\n\n");
|
||||
printf("Press F1 inside htop for online help.\n");
|
||||
printf("See the man page for full information.\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void showHelp() {
|
||||
void showHelp(ProcessList* pl) {
|
||||
clear();
|
||||
attrset(CRT_colors[HELP_BOLD]);
|
||||
mvaddstr(0, 0, "htop " VERSION " - (C) 2004-2006 Hisham Muhammad.");
|
||||
@ -61,10 +62,20 @@ void showHelp() {
|
||||
mvaddstr(3, 0, "CPU usage bar: ");
|
||||
#define addattrstr(a,s) attrset(a);addstr(s)
|
||||
addattrstr(CRT_colors[BAR_BORDER], "[");
|
||||
if (pl->expandSystemTime) {
|
||||
addattrstr(CRT_colors[CPU_NICE], "low"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_KERNEL], "kernel"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_IOWAIT], "io-wait"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_IRQ], "irq"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_SOFTIRQ], "soft-irq");
|
||||
addattrstr(CRT_colors[BAR_SHADOW], " used%");
|
||||
} else {
|
||||
addattrstr(CRT_colors[CPU_NICE], "low-priority"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_KERNEL], "kernel");
|
||||
addattrstr(CRT_colors[BAR_SHADOW], " used%");
|
||||
}
|
||||
addattrstr(CRT_colors[BAR_BORDER], "]");
|
||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||
mvaddstr(4, 0, "Memory bar: ");
|
||||
@ -81,7 +92,7 @@ void showHelp() {
|
||||
addattrstr(CRT_colors[BAR_SHADOW], " used/total");
|
||||
addattrstr(CRT_colors[BAR_BORDER], "]");
|
||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||
mvaddstr(6,0, "Type and layout of header meters is configurable in the setup screen.");
|
||||
mvaddstr(6,0, "Type and layout of header meters are configurable in the setup screen.");
|
||||
|
||||
mvaddstr( 8, 0, " Arrows: scroll process list F5 t: tree view");
|
||||
mvaddstr( 9, 0, " Digits: incremental PID search u: show processes of a single user");
|
||||
@ -194,12 +205,25 @@ int main(int argc, char** argv) {
|
||||
int delay = -1;
|
||||
bool userOnly = false;
|
||||
uid_t userId = 0;
|
||||
int sortKey = 0;
|
||||
|
||||
if (argc > 0) {
|
||||
if (String_eq(argv[1], "--help")) {
|
||||
printHelpFlag();
|
||||
} else if (String_eq(argv[1], "--version")) {
|
||||
printVersionFlag();
|
||||
} else if (String_eq(argv[1], "--sort-key")) {
|
||||
if (argc < 2) printHelpFlag();
|
||||
if (String_eq(argv[2], "help")) {
|
||||
for (int j = 1; j < LAST_PROCESSFIELD; j++)
|
||||
printf ("%s\n", Process_fieldNames[j]);
|
||||
exit(0);
|
||||
}
|
||||
sortKey = ColumnsPanel_fieldNameToIndex(argv[2]);
|
||||
if (sortKey == -1) {
|
||||
fprintf(stderr, "Error: invalid column \"%s\".\n", argv[2]);
|
||||
exit(1);
|
||||
}
|
||||
} else if (String_eq(argv[1], "-d")) {
|
||||
if (argc < 2) printHelpFlag();
|
||||
sscanf(argv[2], "%d", &delay);
|
||||
@ -237,6 +261,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
Header* header = Header_new(pl);
|
||||
settings = Settings_new(pl, header);
|
||||
if (sortKey > 0) {
|
||||
pl->sortKey = sortKey;
|
||||
pl->treeView = false;
|
||||
}
|
||||
int headerHeight = Header_calculateHeight(header);
|
||||
|
||||
// FIXME: move delay code to settings
|
||||
@ -455,7 +483,7 @@ int main(int argc, char** argv) {
|
||||
case KEY_F(1):
|
||||
case 'h':
|
||||
{
|
||||
showHelp();
|
||||
showHelp(pl);
|
||||
FunctionBar_draw(defaultBar, NULL);
|
||||
refreshTimeout = 0;
|
||||
break;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Version=0.6.3
|
||||
Version=0.6.4
|
||||
Name=Htop
|
||||
Type=Application
|
||||
Comment=Show System Processes
|
||||
|
Reference in New Issue
Block a user