From owner-freebsd-questions@FreeBSD.ORG Sun Jun 8 23:21:05 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2542837B401 for ; Sun, 8 Jun 2003 23:21:05 -0700 (PDT) Received: from smtp-out.comcast.net (smtp-out.comcast.net [24.153.64.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7CD1043FB1 for ; Sun, 8 Jun 2003 23:21:04 -0700 (PDT) (envelope-from steves06@comcast.net) Received: from murphy.sapovits.org (pcp02671656pcs.norstn01.pa.comcast.net [68.85.23.211]) by mtaout02.icomcast.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HG7001NTAZ3SR@mtaout02.icomcast.net> for freebsd-questions@freebsd.org; Mon, 09 Jun 2003 02:21:03 -0400 (EDT) Date: Mon, 09 Jun 2003 02:24:03 -0400 From: Steve Sapovits In-reply-to: <001e01c32e4c$c0c19490$0200a8c0@bartxp> To: Derrick Ryalls Message-id: <20030609022403.1884cb6a.steves06@comcast.net> MIME-version: 1.0 X-Mailer: Sylpheed version 0.8.6claws (GTK+ 1.2.10; i386-portbld-freebsd5.0) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT References: <001e01c32e4c$c0c19490$0200a8c0@bartxp> cc: freebsd-questions@freebsd.org Subject: Re: Shell line parse needed X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2003 06:21:05 -0000 On Sun, 08 Jun 2003 23:02:42 -0700 Derrick Ryalls wrote: > Thanks to help from here I have MRTG setup on a 4.7 server, but now I > need help with parsing console info. I want a script to report CPU > utilization by a specific process. When I type this: > > top | grep hlds > > it gives me: > > 60905 root 10 0 54960K 49736K nanslp 1:26 0.00% 0.00% hlds > > What I need is to get the last whole number before hlds, which should be > cpu utilization. For instance, if the line was: > > 60905 root 10 0 54960K 49736K nanslp 1:26 4.61% 5.23% hlds > > I would need the script to report: > > 5 This gets you the 5 if the process is running: top | grep hlds | awk '{printf "%d\n", $10}' -- Steve Sapovits steves06@comcast.net