Date: Thu, 30 Oct 2008 18:03:49 -0200 From: "Eduardo Meyer" <dudu.meyer@gmail.com> To: freebsd-stable@freebsd.org, dudu.meyer@gmail.com Subject: Re: Script-friendly (parseble) ps(1) output? Message-ID: <d3ea75b30810301303y8657f65vd6165f0650ea2bb5@mail.gmail.com> In-Reply-To: <200810301418.m9UEIvSj086321@lurza.secnetix.de> References: <d3ea75b30810291502h716ae979r9906a7a053ec5f56@mail.gmail.com> <200810301418.m9UEIvSj086321@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Oct 30, 2008 at 12:18 PM, Oliver Fromme <olli@lurza.secnetix.de> wrote: > Eduardo Meyer wrote: > > I need to write a cgi script which will print the output from ps(1) in > > a table (html), so the average-operator can click on a KILL link and Thank you all. I didnt mention the language, yes, I wanted it with shell script. Sadly, no idea was completly enough, for the default ps output it simple has no pattern. No multiple-pattern would do the job safely. With kernel stuff like idle, output happens to be completly nonsense. Counting positions in a array is the way to go, but not with the default output. Things just happen to get completly trashed with long values, like idle CPU time. What I did was formating every output header like that ps -o start="<<<..............................................>>>" -o lstart="<<<..............................................>>>" -o args="<<<..............................................>>>" etc So I could find the begining and the ending column. "-o command" or "-o args" have always to be the last option, if I dont want 'em to get truncated. So sad. Now my next problem, do the sabe with sockstat.... %sockstat | head -4 USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS freebsdsupportsshd 57255 3 tcp4 172.16.0.225:22 172.16.0.69:63583 freebsdsupportsshd 57255 4 stream -> ?? root sshd 57253 3 tcp4 172.16.0.225:22 172.16.0.69:63583 So I have the USER and COMMAND column "merged" in a single string, because username is large. Again, space can not be used as a separator, but hopefully only the patterns with "->" will have space if not a column separator, easier to parse. But sockstat have no formatting option to be issued like -o from ps(1). Measing in the very first sockstat output, I dont know what to do... :( -- =========== Eduardo Meyer pessoal: dudu.meyer@gmail.com profissional: ddm.farmaciap@saude.gov.br
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d3ea75b30810301303y8657f65vd6165f0650ea2bb5>