From owner-freebsd-stable@FreeBSD.ORG Thu Oct 30 20:02:09 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 E957E106564A for ; Thu, 30 Oct 2008 20:02:09 +0000 (UTC) (envelope-from dudu.meyer@gmail.com) Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.29]) by mx1.freebsd.org (Postfix) with ESMTP id 9C26B8FC1B for ; Thu, 30 Oct 2008 20:02:09 +0000 (UTC) (envelope-from dudu.meyer@gmail.com) Received: by yw-out-2324.google.com with SMTP id 9so328484ywe.13 for ; Thu, 30 Oct 2008 13:02:08 -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=gOBnyikmPOP/2zHzy+0ck8VIIccgOKMi0RxaxcS63/ndHklopRZ3oiCQ2F3JHSDIVG TNGuwMvUElYd3Y2/O3gjugHMwZRlqDk2rUWwWVrhXf07I7JL8XzpuhP1qE/KKKE+MXox sJ2f77fV/gKX5aLz7rgWBDPys8BcLd4iQ1Ffo= 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=LZHjSbP9hbBTnI+KYiEV2B3plJKoxUkfN9Lb/pstdNrr+lngNiwLVavr6pw9Bt3ETf gB8Z0oQgnt9fhITA00r8w3DpSlHBeNvhtNiqNMxnptjfcUBj8pDkSzaD7Z0Zpq3r+P98 sq25Bf2O3U+auiu9YZnt+KeXLdOizZND6kta0= Received: by 10.142.139.14 with SMTP id m14mr4894745wfd.291.1225396928311; Thu, 30 Oct 2008 13:02:08 -0700 (PDT) Received: by 10.142.158.11 with HTTP; Thu, 30 Oct 2008 13:02:08 -0700 (PDT) Message-ID: Date: Thu, 30 Oct 2008 18:02:08 -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:02:10 -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