Mailing List Archive

Patch for backhand-handler display
This is a multi-part message in MIME format.
--------------050405090002070103060308
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

A Solaris server with 4GB of RAM was giving negative values in the
"Total Mem" column of the backhand-handler page because it was using %d
instead of %u. While making fixes to that I started tweaking other parts
of the layout to be a little easier to read. Here's exactly what this
patch changes:

*) Center all column headings.
*) Change justification of some columns so they line up more logically.
*) Reduce the precision of the displayed "Load" and "CPU Idle" data to
match more closely the actual precision of the numbers. It's still a
magnitude more precise than uptime(1), that doesn't necessarily mean we
can't be more accurate internally.
*) Display memory amounts as megabytes rather than bytes.
*) Change the "Total Mem" and "Avail Mem" columns to display as unsigned
integers. Because of the previous change, there was little chance they
will ever show up as negative, but since the memory amounts really ARE
unsigned, it shouldn't hurt.

If you don't want all of these formatting changes, just change the '%d's
in the memory columns to '%u's and that will at least fix the
signed/unsigned problem.

--Mike Cramer

--------------050405090002070103060308
Content-Type: text/plain;
name="backhand-handler.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="backhand-handler.patch"

Index: mod_backhand/back_util.c
===================================================================
RCS file: /storage/cvs/jesus/mod_backhand/back_util.c,v
retrieving revision 1.16
diff -u -r1.16 back_util.c
--- mod_backhand/back_util.c 2001/10/23 20:25:17 1.16
+++ mod_backhand/back_util.c 2001/10/24 18:56:43
@@ -163,13 +163,13 @@
time_t now = time(NULL);
mypid = getpid();
ap_rputs("<TABLE CELLSPACING=0 CELLPADDING=4 BORDER=0 BGCOLOR=#ffffff>\
-<TR bgcolor=#9999ee><TD><B align=center>Entry</B></TD><TD><B>Hostname</B></TD>\
-<TD align=right><B>Age</B></TD><TD align=center><B>Address</B></TD>\
-<TD align=right><B>Total Mem</B></TD><TD align=left><B>Avail Mem</B></TD>\
+<TR bgcolor=#9999ee><TD><B align=center>Entry</B></TD><TD align=center><B>Hostname</B></TD>\
+<TD align=center><B>Age</B></TD><TD align=center><B>Address</B></TD>\
+<TD align=center><B>Total Mem</B></TD><TD align=center><B>Avail Mem</B></TD>\
<TD align=center><B># ready servers/<BR># total servers</B></TD>\
<TD align=center><B>~ms/req [#req]</B></TD>\
-<TD align=right><B>Arriba</B></TD><TD align=center><B># CPUs</B></TD>\
-<TD align=right><B>Load/HWM</B></TD><TD align=right><B>CPU Idle</B></TD></TR>\n",
+<TD align=center><B>Arriba</B></TD><TD align=center><B># CPUs</B></TD>\
+<TD align=center><B>Load/HWM</B></TD><TD align=center><B>CPU Idle</B></TD></TR>\n",
r);
for(i=0;i<MAXSERVERS;i++) {
tempport = ntohs(serverstats[i].contact.sin_port);
@@ -180,18 +180,23 @@
hostaddress[21] = '\0';
if(serverstats[i].contact.sin_addr.s_addr!=0)
ap_rprintf(r, "<TR bgcolor=%s><TD align=center>%d</TD><TD>%s</TD>\
-<TD align=right>%d</TD><TD align=center>%s</TD><TD align=right>%d</TD>\
-<TD align=left>%d</TD><TD align=center>%d/%d</TD><TD align=center>%d [%d]</TD>\
+<TD align=right>%d</TD><TD align=center>%s</TD><TD align=right>%u&nbsp;MB</TD>\
+<TD align=right>%u&nbsp;MB</TD><TD align=center>%d/%d</TD><TD align=center>%d [%d]</TD>\
<TD align=right>%d</TD>\
-<TD align=center>%d</TD><TD align=right>%f/%d</TD><TD align=right>%f</TD></TR>\n",
+<TD align=center>%d</TD><TD align=right>%0.3f/%d</TD><TD align=right>%0.3f</TD></TR>\n",
(!is_alive(i,SERVER_TIMEOUT,now))?"#ff4444":
(i%2)?"#aaaaaa":"#cccccc",
i, /* Entry */
serverstats[i].hostname, /* hostname */
(int)(time(NULL) - serverstats[i].mtime), /* Age */
hostaddress, /* aaa.bbb.ccc.ddd:port */
- serverstats[i].tmem, /* Total physical memory */
- serverstats[i].amem, /* Avilable memory */
+
+ /* Total physical memory in megabytes */
+ ((unsigned int)serverstats[i].tmem)/(1024*1024),
+
+ /* Avilable memory in megabytes */
+ ((unsigned int)serverstats[i].amem)/(1024*1024),
+
serverstats[i].aservers, /* # ready Apache procs */
serverstats[i].nservers, /* # of Apache procs */
serverstats[i].tatime, /* Ave ms / request */

--------------050405090002070103060308--
Patch for backhand-handler display [ In reply to ]
I integrated all of the changes except a few of the column
realignments. I like the top of the columns aligned the same as the
data underneath. Things like hostname seem to me that they should be
left justified and things like memory seem that they should be right
justified.

The changes are in CVS.

I am not opposed to changing them if there is overwhelming support for
doing so. I am not opposed to voting Apache style-- though I don't
think to many people will participate :-)

After people vote if the sum is +2 then I'll make the change. So, vote
with a +/-1.

My vote: -1.

If someone was cool enough to have that page read in a static file with
special markup tags in it so that one could change the look'n'feel
without editing code, that would be super cool. It really begs for
something like PHP or perl, but I don't want to introduce any dependency
like that.

On Wednesday, October 24, 2001, at 02:56 PM, Michael Cramer wrote:

> A Solaris server with 4GB of RAM was giving negative values in the
> "Total Mem" column of the backhand-handler page because it was using %d
> instead of %u. While making fixes to that I started tweaking other
> parts of the layout to be a little easier to read. Here's exactly what
> this patch changes:
>
> *) Center all column headings.
> *) Change justification of some columns so they line up more logically.
> *) Reduce the precision of the displayed "Load" and "CPU Idle" data to
> match more closely the actual precision of the numbers. It's still a
> magnitude more precise than uptime(1), that doesn't necessarily mean we
> can't be more accurate internally.
> *) Display memory amounts as megabytes rather than bytes.
> *) Change the "Total Mem" and "Avail Mem" columns to display as
> unsigned integers. Because of the previous change, there was little
> chance they will ever show up as negative, but since the memory amounts
> really ARE unsigned, it shouldn't hurt.
>
> If you don't want all of these formatting changes, just change the
> '%d's in the memory columns to '%u's and that will at least fix the
> signed/unsigned problem.
>
> --Mike Cramer
> Index: mod_backhand/back_util.c
> ===================================================================
> RCS file: /storage/cvs/jesus/mod_backhand/back_util.c,v
> retrieving revision 1.16
> diff -u -r1.16 back_util.c
> --- mod_backhand/back_util.c 2001/10/23 20:25:17 1.16
> +++ mod_backhand/back_util.c 2001/10/24 18:56:43
> @@ -163,13 +163,13 @@
> time_t now = time(NULL);
> mypid = getpid();
> ap_rputs("<TABLE CELLSPACING=0 CELLPADDING=4 BORDER=0
> BGCOLOR=#ffffff>\
> -<TR bgcolor=#9999ee><TD><B
> align=center>Entry</B></TD><TD><B>Hostname</B></TD>\
> -<TD align=right><B>Age</B></TD><TD align=center><B>Address</B></TD>\
> -<TD align=right><B>Total Mem</B></TD><TD align=left><B>Avail
> Mem</B></TD>\
> +<TR bgcolor=#9999ee><TD><B align=center>Entry</B></TD><TD
> align=center><B>Hostname</B></TD>\
> +<TD align=center><B>Age</B></TD><TD align=center><B>Address</B></TD>\
> +<TD align=center><B>Total Mem</B></TD><TD align=center><B>Avail
> Mem</B></TD>\
> <TD align=center><B># ready servers/<BR># total servers</B></TD>\
> <TD align=center><B>~ms/req [#req]</B></TD>\
> -<TD align=right><B>Arriba</B></TD><TD align=center><B># CPUs</B></TD>\
> -<TD align=right><B>Load/HWM</B></TD><TD align=right><B>CPU
> Idle</B></TD></TR>\n",
> +<TD align=center><B>Arriba</B></TD><TD align=center><B># CPUs</B></TD>\
> +<TD align=center><B>Load/HWM</B></TD><TD align=center><B>CPU
> Idle</B></TD></TR>\n",
> r);
> for(i=0;i<MAXSERVERS;i++) {
> tempport = ntohs(serverstats[i].contact.sin_port);
> @@ -180,18 +180,23 @@
> hostaddress[21] = '\0';
> if(serverstats[i].contact.sin_addr.s_addr!=0)
> ap_rprintf(r, "<TR bgcolor=%s><TD align=center>%d</TD><TD>%s</TD>\
> -<TD align=right>%d</TD><TD align=center>%s</TD><TD align=right>%d</TD>\
> -<TD align=left>%d</TD><TD align=center>%d/%d</TD><TD align=center>%d
> [%d]</TD>\
> +<TD align=right>%d</TD><TD align=center>%s</TD><TD
> align=right>%u&nbsp;MB</TD>\
> +<TD align=right>%u&nbsp;MB</TD><TD align=center>%d/%d</TD><TD
> align=center>%d [%d]</TD>\
> <TD align=right>%d</TD>\
> -<TD align=center>%d</TD><TD align=right>%f/%d</TD><TD
> align=right>%f</TD></TR>\n",
> +<TD align=center>%d</TD><TD align=right>%0.3f/%d</TD><TD
> align=right>%0.3f</TD></TR>\n",
> (!is_alive(i,SERVER_TIMEOUT,now))?"#ff4444":
> (i%2)?"#aaaaaa":"#cccccc",
> i, /* Entry */
> serverstats[i].hostname, /* hostname */
> (int)(time(NULL) - serverstats[i].mtime), /* Age */
> hostaddress, /* aaa.bbb.ccc.ddd:port */
> - serverstats[i].tmem, /* Total physical memory */
> - serverstats[i].amem, /* Avilable memory */
> +
> + /* Total physical memory in megabytes */
> + ((unsigned int)serverstats[i].tmem)/(1024*1024),
> +
> + /* Avilable memory in megabytes */
> + ((unsigned int)serverstats[i].amem)/(1024*1024),
> +
> serverstats[i].aservers, /* # ready Apache procs */
> serverstats[i].nservers, /* # of Apache procs */
> serverstats[i].tatime, /* Ave ms / request */
>
--
Theo Schlossnagle
1024D/82844984/95FD 30F1 489E 4613 F22E 491A 7E88 364C 8284 4984
2047R/33131B65/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7
Patch for backhand-handler display [ In reply to ]
Theo Schlossnagle wrote:

> I integrated all of the changes except a few of the column
> realignments. I like the top of the columns aligned the same as the
> data underneath. Things like hostname seem to me that they should be
> left justified and things like memory seem that they should be right
> justified.

>
> The changes are in CVS.
>
> I am not opposed to changing them if there is overwhelming support for
> doing so. I am not opposed to voting Apache style-- though I don't
> think to many people will participate :-)
>
> After people vote if the sum is +2 then I'll make the change. So, vote
> with a +/-1.
>
> My vote: -1.


I'll vote +1, since I wrote the original patch. As long as things line
up in a way that makes scanning the list easy, I'm OK.

--Mike

>
> If someone was cool enough to have that page read in a static file with
> special markup tags in it so that one could change the look'n'feel
> without editing code, that would be super cool. It really begs for
> something like PHP or perl, but I don't want to introduce any dependency
> like that.

To dream... =)

--
Michael Cramer | Consultant, PBS Interactive
mcramer@pbs.org | AIM: PBSWebChef