Xymon Mailing List Archive search

darwin "ps" display parsing in OS-X Tiger causes all procs to vanish in display

7 messages in this thread

list Kent Brodie · Tue, 25 Jul 2006 15:52:38 -0500 ·
Hi guys.   OK, enough asking a million questions (thank you all!), now
it's time for bug reporting.

Systems:  Apple X-Servers.  I have two.    The one running OS-X 10.3 is
fine.    The one running OS-X Tiger 10.4 is being weird.   And I figured
it out.

The symptom on the newer OS is that under the "procs" column, all I see
is the process header line, followed by only a small part of the first
process listed- and NOTHING else.     It looks like this on the web
page:

  PID  PPID USER     STARTED STAT PRI %CPU      TIME %MEM    RSS
VSZ COMMAND
    1     0 root     13Jul06 S

After digging, I figured out what's happening.

OS-X 10.3: (normal)

  PID  PPID USER     STARTED STAT PRI %CPU      TIME %MEM    RSS
VSZ COMMAND
    1     0 root      3Jul06 Ss    31   0.0   0:00.21 -0.0    244
18072 /sbin/init 
    2     1 root      3Jul06 Ss    31   0.0   4:38.77 -0.0    200
18608 /sbin/mach_init 
   83     1 root      3Jul06 Ss    31   0.0   0:12.67 -0.0    200
18092 /usr/sbin/syslogd -s -m 0
   89     1 root      3Jul06 Ss    31   0.0   0:02.68 -0.0    792
29120 kextd
   91     2 root      3Jul06 Ss    31   9.0  80:57.57 -0.0   1040
31328 /usr/sbin/configd
   92     2 root      3Jul06 Ss    31   0.0   0:00.87 -0.0    892
27888 /usr/sbin/diskarbitrationd
   97     1 root      3Jul06 Ss    31   0.0   1:26.87 -0.0    212
18676 /usr/sbin/notifyd
  112     1 daemon    3Jul06 Ss    31   0.0   0:00.17 -0.0    144
18084 portmap
..............etc


OS-X 10.4 (procs display is broken)

  PID  PPID USER     STARTED STAT PRI %CPU      TIME %MEM    RSS
VSZ COMMAND
    1     0 root     13Jul06 S<s   32   0.0   0:17.23 -0.0    500
28348 /sbin/launchd
   27     1 root     13Jul06 Ss    63   0.0   0:00.00 -0.0    168
27264 /sbin/dynamic_pager -F /private/var/vm/swapfile
   31     1 root     13Jul06 Ss    31   0.0   0:06.04 -0.2   3608
30640 kextd
   62     1 root     13Jul06 Ss    31   0.0  54:48.59 -0.1   1208
31572 hwmond
   63     1 root     13Jul06 Ss    31   0.0   0:00.04 -0.0    600
27844 /usr/sbin/KernelEventAgent
   64     1 root     13Jul06 Ss    31   0.0   0:51.95 -0.1   1096
28064 /usr/sbin/mDNSResponder -launchdaemon
   65     1 root     13Jul06 Ss    31   0.0   0:11.21 -0.0    572
27592 /usr/sbin/netinfod -s local
   66     1 root     13Jul06 Ss    63   0.0  53:42.36 -0.4   7400
47040 servermgrd -x
   67     1 root     13Jul06 Ss    31   0.0   0:25.95 -0.0    512
27284 /usr/sbin/syslogd
   68     1 root     13Jul06 Ss    63   0.0   0:10.54 -0.0    732
27684 watchdogtimerd
 ...........etc


It's the first line that's causing the hobbit procs parsing to break.
Specifically, the "S<s" status.     While I don't know enough OS-X tobe
dangerous, I suspect it's a new type of process status under the latest
Darwin.   The "<" in the status is normal, and this is causing the procs
parsing in hobbit to cut off everything beyond that.

    1     0 root     13Jul06 S<s   32   0.0   0:17.23 -0.0    500
28348 /sbin/launchd


This of course makes any procs check useless (in my case,I was checking
for simple things, like "cron", etc - and the test fails of course,
since there's no such (or any other!) process listed..................


Kent C. Brodie - user-da7f7d5174c0@xymon.invalid
Department of Physiology
Medical College of Wisconsin
(XXX) XXX-XXXX
list Henrik Størner · Tue, 25 Jul 2006 23:02:53 +0200 ·
quoted from Kent Brodie
On Tue, Jul 25, 2006 at 03:52:38PM -0500, Brodie, Kent wrote:
OS-X 10.4 (procs display is broken)

  PID  PPID USER     STARTED STAT PRI %CPU      TIME %MEM    RSS
VSZ COMMAND
    1     0 root     13Jul06 S<s   32   0.0   0:17.23 -0.0    500 28348 /sbin/launchd

It's the first line that's causing the hobbit procs parsing to break.
Specifically, the "S<s" status.     While I don't know enough OS-X tobe
dangerous, I suspect it's a new type of process status under the latest
Darwin.   The "<" in the status is normal, and this is causing the procs
parsing in hobbit to cut off everything beyond that.
This of course makes any procs check useless (in my case,I was checking
for simple things, like "cron", etc - and the test fails of course,
since there's no such (or any other!) process listed..................
I can see why it would stop it from appearing on the web page (since
your browser then interprets everything after the '<' as an unknown
- very large - HTML tag. But the client parsing code works regardless of
this, and should handle the process listing just fine.

Could you verify if the following URL
 http://www.hswn.dk/hobbit-cgi/bb-hostsvc.sh?CLIENT=voodoo.hswn.dk&section=ps
(adapted to match you Hobbit server hostname and the OSX client name, of
course) returns the full "ps" listing, or only a part of it?


Regards,
Henrik
list Kent Brodie · Tue, 25 Jul 2006 16:23:34 -0500 ·
When I click on that url, I am asked to *download* a file called
bb-hostsvc.sh...     my browser (IE) won't display anything...   
quoted from Kent Brodie

Kent C. Brodie - user-da7f7d5174c0@xymon.invalid
Department of Physiology
Medical College of Wisconsin
(XXX) XXX-XXXX
-----Original Message-----
From: Henrik Stoerner [mailto:user-ce4a2c883f75@xymon.invalid] 
Sent: Tuesday, July 25, 2006 4:03 PM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] darwin "ps" display parsing in OS-X Tiger causes

all procs to vanish in display
quoted from Henrik Størner

On Tue, Jul 25, 2006 at 03:52:38PM -0500, Brodie, Kent wrote:
OS-X 10.4 (procs display is broken)

  PID  PPID USER     STARTED STAT PRI %CPU      TIME %MEM    RSS
VSZ COMMAND
    1     0 root     13Jul06 S<s   32   0.0   0:17.23 -0.0    500
28348 /sbin/launchd
It's the first line that's causing the hobbit procs parsing to break.
Specifically, the "S<s" status.     While I don't know enough OS-X
tobe
dangerous, I suspect it's a new type of process status under the
latest
Darwin.   The "<" in the status is normal, and this is causing the
procs
parsing in hobbit to cut off everything beyond that.
This of course makes any procs check useless (in my case,I was
checking
for simple things, like "cron", etc - and the test fails of course,
since there's no such (or any other!) process listed..................
I can see why it would stop it from appearing on the web page (since
your browser then interprets everything after the '<' as an unknown
- very large - HTML tag. But the client parsing code works regardless of
this, and should handle the process listing just fine.

Could you verify if the following URL
 

http://www.hswn.dk/hobbit-cgi/bb-hostsvc.sh?CLIENT=voodoo.hswn.dk&sectio
n=ps
quoted from Henrik Størner
(adapted to match you Hobbit server hostname and the OSX client name, of
course) returns the full "ps" listing, or only a part of it?


Regards,
Henrik
list Kent Brodie · Tue, 25 Jul 2006 16:24:36 -0500 ·
Um, ok, so the parsing works, but that breaks a browser by attempting to
do the <....       I was able to fix it simply by removing the STATE
column from the process display for that one server....      
signature

Kent C. Brodie - user-da7f7d5174c0@xymon.invalid
Department of Physiology
Medical College of Wisconsin
(XXX) XXX-XXXX

-----Original Message-----

quoted from Kent Brodie
From: Henrik Stoerner [mailto:user-ce4a2c883f75@xymon.invalid] 
Sent: Tuesday, July 25, 2006 4:03 PM
To: user-ae9b8668bcde@xymon.invalid
Subject: Re: [hobbit] darwin "ps" display parsing in OS-X Tiger causes
all procs to vanish in display

On Tue, Jul 25, 2006 at 03:52:38PM -0500, Brodie, Kent wrote:
OS-X 10.4 (procs display is broken)

  PID  PPID USER     STARTED STAT PRI %CPU      TIME %MEM    RSS
VSZ COMMAND
    1     0 root     13Jul06 S<s   32   0.0   0:17.23 -0.0    500
28348 /sbin/launchd
It's the first line that's causing the hobbit procs parsing to break.
Specifically, the "S<s" status.     While I don't know enough OS-X
tobe
dangerous, I suspect it's a new type of process status under the
latest
Darwin.   The "<" in the status is normal, and this is causing the
procs
parsing in hobbit to cut off everything beyond that.
This of course makes any procs check useless (in my case,I was
checking
for simple things, like "cron", etc - and the test fails of course,
since there's no such (or any other!) process listed..................
I can see why it would stop it from appearing on the web page (since
your browser then interprets everything after the '<' as an unknown
- very large - HTML tag. But the client parsing code works regardless of
this, and should handle the process listing just fine.

Could you verify if the following URL
 
http://www.hswn.dk/hobbit-cgi/bb-hostsvc.sh?CLIENT=voodoo.hswn.dk&sectio
n=ps
(adapted to match you Hobbit server hostname and the OSX client name, of
course) returns the full "ps" listing, or only a part of it?


Regards,
Henrik
list Henrik Størner · Tue, 25 Jul 2006 23:29:03 +0200 ·
quoted from Kent Brodie
On Tue, Jul 25, 2006 at 04:23:34PM -0500, Brodie, Kent wrote:
When I click on that url, I am asked to *download* a file called
bb-hostsvc.sh...     my browser (IE) won't display anything...   
IE is bizarre if it cannot render a simple text/plain content-type.
You're not alone; I have heard this from others - but it works fine
on my IE 6 (+ patches).


Regards,
Henrik
list Henrik Størner · Tue, 25 Jul 2006 23:29:28 +0200 ·
quoted from Kent Brodie
On Tue, Jul 25, 2006 at 04:24:36PM -0500, Brodie, Kent wrote:
Um, ok, so the parsing works, but that breaks a browser by attempting to
do the <....       I was able to fix it simply by removing the STATE
column from the process display for that one server....      
Right, I'll see if I can get that fixed.


Regards,
Henrik
list Henrik Størner · Tue, 25 Jul 2006 23:57:00 +0200 ·
quoted from Henrik Størner
On Tue, Jul 25, 2006 at 04:24:36PM -0500, Brodie, Kent wrote:
Um, ok, so the parsing works, but that breaks a browser by attempting to
do the <....
This patch should make it show up correctly.


Regards,
Henrik

-------------- next part --------------
--- hobbitd/hobbitd_client.c	2006/07/20 16:06:41	1.94
+++ hobbitd/hobbitd_client.c	2006/07/25 21:42:46
@@ -720,7 +720,41 @@
 	}
 
 	/* And the full ps output for those who want it */
-	if (pslistinprocs) addtostatus(psstr);
+	if (pslistinprocs) {
+		/*
+		 * NB: Process listings may contain HTML special characters.
+		 *     We must encode these for HTML, cf.
+		 *     http://www.w3.org/TR/html4/charset.html#h-5.3.2
+		 */
+		char *inp, *tagpos;
• +		inp = psstr;
+		do {
+			tagpos = inp + strcspn(inp, "<>&\"");
+			switch (*tagpos) {
+			  case '<':
+				*tagpos = '\0'; addtostatus(inp); addtostatus("&lt;"); *tagpos = '<';
+				inp = tagpos + 1;
+				break;
+			  case '>':
+				*tagpos = '\0'; addtostatus(inp); addtostatus("&gt;"); *tagpos = '>';
+				inp = tagpos + 1;
+				break;
+			  case '&':
+				*tagpos = '\0'; addtostatus(inp); addtostatus("&amp;"); *tagpos = '&';
+				inp = tagpos + 1;
+				break;
+			  case '\"':
+				*tagpos = '\0'; addtostatus(inp); addtostatus("&quot;"); *tagpos = '\"';
+				inp = tagpos + 1;
+				break;
+			  default:
+				/* We're done */
+				addtostatus(inp); inp = NULL;
+				break;
+			}
+		} while (inp && *inp);
+	}
 
 	if (fromline && !localmode) addtostatus(fromline);
 	finish_status();