From owner-freebsd-stable@FreeBSD.ORG Thu Oct 30 20:03:52 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05C8E106564A for ; Thu, 30 Oct 2008 20:03:52 +0000 (UTC) (envelope-from dudu.meyer@gmail.com) Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.28]) by mx1.freebsd.org (Postfix) with ESMTP id AC4AF8FC1F for ; Thu, 30 Oct 2008 20:03:51 +0000 (UTC) (envelope-from dudu.meyer@gmail.com) Received: by yw-out-2324.google.com with SMTP id 9so329090ywe.13 for ; Thu, 30 Oct 2008 13:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=ehcXYkrLpUajGr2BlkFWc7OFDOVetWl+Lx1ssZpx8hI=; b=B4+5bS7n2RlhEmh8qJx+zKmxgdnRbMgrN5pBShoJDHXv+eL8p5N2DMXrnrqL2m2yG6 qqOiKA9dGk4Grx+tC0JK3VdANZ0aXsVnPuZHTMPq8IMA7+7LvT5Jp9fZE3MMhJVXt5L4 QTCurJOlF5MvTZb6f8q/+VD/n9C8Rm2Zhk2qI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=R8aw85X3Zvw6qodCMQo9/9Ag35DhKbaN++czd16KlTjRgbaY0zsFBwqL5uWX58NDrM TMHz46Lh5cAHKe7hIaZvuGu3dzYSv3s3Hp0peR4pOBLJY5ziU3UcqsNdrjI3O+wk2VYP kG/0QuhTcu64PVhfe4GtpzhQW6xaoU5O2TLFE= Received: by 10.64.183.6 with SMTP id g6mr11670558qbf.37.1225397029752; Thu, 30 Oct 2008 13:03:49 -0700 (PDT) Received: by 10.64.201.9 with HTTP; Thu, 30 Oct 2008 13:03:49 -0700 (PDT) Message-ID: Date: Thu, 30 Oct 2008 18:03:49 -0200 From: "Eduardo Meyer" To: freebsd-stable@freebsd.org, dudu.meyer@gmail.com In-Reply-To: <200810301418.m9UEIvSj086321@lurza.secnetix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200810301418.m9UEIvSj086321@lurza.secnetix.de> Cc: Subject: Re: Script-friendly (parseble) ps(1) output? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2008 20:03:52 -0000 On Thu, Oct 30, 2008 at 12:18 PM, Oliver Fromme 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