I've written a quick patch that adds an option to enumerate CPUs in
the display starting from zero.
I'd be happy to make any changes required to have this accepted, as
this is a huge point against htop in my experience.
Sean
=== cut ===
diff -Nur ./htop-orig/htop-0.9/CPUMeter.c ./htop/htop-0.9/CPUMeter.c
--- ./htop-orig/htop-0.9/CPUMeter.c 2011-03-15 17:46:35.988635271 +0000
+++ ./htop/htop-0.9/CPUMeter.c 2011-03-15 17:30:48.455103368 +0000
@@ -33,7 +33,10 @@
int cpu = this->param;
if (this->pl->cpuCount > 1) {
char caption[10];
- sprintf(caption, "%-3d", cpu);
+ if (this->pl->countCPUsFromZero)
+ sprintf(caption, "%-3d", cpu-1);
+ else
+ sprintf(caption, "%-3d", cpu);
Meter_setCaption(this, caption);
}
if (this->param == 0)
diff -Nur ./htop-orig/htop-0.9/DisplayOptionsPanel.c
./htop/htop-0.9/DisplayOptionsPanel.c
--- ./htop-orig/htop-0.9/DisplayOptionsPanel.c 2011-03-15
17:46:35.978634178 +0000
+++ ./htop/htop-0.9/DisplayOptionsPanel.c 2011-03-15 17:28:06.697429512
+0000
@@ -74,5 +74,6 @@
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight
large numbers in memory counters"),
&(settings->pl->highlightMegabytes), false));
Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a
margin around header"), &(settings->header->margin), false));
Panel_add(super, (Object*) CheckItem_new(String_copy("Detailed CPU
time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)"),
&(settings->pl->detailedCPUTime), false));
+ Panel_add(super, (Object*) CheckItem_new(String_copy("Count CPUs
from 0 instead of 1"), &(settings->pl->countCPUsFromZero), false));
return this;
}
diff -Nur ./htop-orig/htop-0.9/Process.c ./htop/htop-0.9/Process.c
--- ./htop-orig/htop-0.9/Process.c 2011-03-15 17:46:35.988635271 +0000
+++ ./htop/htop-0.9/Process.c 2011-03-15 17:32:42.457559490 +0000
@@ -332,7 +332,14 @@
case TTY_NR: snprintf(buffer, n, "%5u ", this->tty_nr); break;
case TGID: snprintf(buffer, n, "%5u ", this->tgid); break;
case TPGID: snprintf(buffer, n, "%5d ", this->tpgid); break;
- case PROCESSOR: snprintf(buffer, n, "%3d ", this->processor+1); break;
+ case PROCESSOR: {
+ if (this->pl->countCPUsFromZero)
+ snprintf(buffer, n, "%3d ", this->processor);
+ else
+ snprintf(buffer, n, "%3d ", this->processor+1);
+ break;
+ }
+
case NLWP: snprintf(buffer, n, "%4ld ", this->nlwp); break;
case COMM: {
if (this->pl->highlightThreads && Process_isThread(this)) {
diff -Nur ./htop-orig/htop-0.9/ProcessList.c ./htop/htop-0.9/ProcessList.c
--- ./htop-orig/htop-0.9/ProcessList.c 2011-03-15 17:46:35.998636364 +0000
+++ ./htop/htop-0.9/ProcessList.c 2011-03-15 17:39:04.819337420 +0000
@@ -177,6 +177,7 @@
this->highlightBaseName = false;
this->highlightMegabytes = false;
this->detailedCPUTime = false;
+ this->countCPUsFromZero = false;
return this;
}
diff -Nur ./htop-orig/htop-0.9/ProcessList.h ./htop/htop-0.9/ProcessList.h
--- ./htop-orig/htop-0.9/ProcessList.h 2011-03-15 17:46:35.978634178 +0000
+++ ./htop/htop-0.9/ProcessList.h 2011-03-15 17:40:00.365406584 +0000
@@ -124,6 +124,7 @@
bool highlightMegabytes;
bool highlightThreads;
bool detailedCPUTime;
+ bool countCPUsFromZero;
} ProcessList;
diff -Nur ./htop-orig/htop-0.9/Settings.c ./htop/htop-0.9/Settings.c
--- ./htop-orig/htop-0.9/Settings.c 2011-03-15 17:46:35.988635271 +0000
+++ ./htop/htop-0.9/Settings.c 2011-03-15 17:41:40.956397549 +0000
@@ -113,6 +113,8 @@
this->pl->detailedCPUTime = atoi(option[1]);
} else if (String_eq(option[0], "detailed_cpu_time")) {
this->pl->detailedCPUTime = atoi(option[1]);
+ } else if (String_eq(option[0], "cpu_count_from_zero")) {
+ this->pl->countCPUsFromZero = atoi(option[1]);
} else if (String_eq(option[0], "delay")) {
this->delay = atoi(option[1]);
} else if (String_eq(option[0], "color_scheme")) {
@@ -172,6 +174,7 @@
fprintf(fd, "tree_view=%d\n", (int) this->pl->treeView);
fprintf(fd, "header_margin=%d\n", (int) this->header->margin);
fprintf(fd, "detailed_cpu_time=%d\n", (int) this->pl->detailedCPUTime);
+ fprintf(fd, "cpu_count_from_zero=%d\n", (int) this->pl->countCPUsFromZero);
fprintf(fd, "color_scheme=%d\n", (int) this->colorScheme);
fprintf(fd, "delay=%d\n", (int) this->delay);
fprintf(fd, "left_meters=");
=== cut ===
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
htop-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htop-general