Date: Sun, 8 Jun 2003 23:02:42 -0700 From: "Derrick Ryalls" <ryallsd@datasphereweb.com> To: "'freebsd-questions'" <freebsd-questions@freebsd.org> Subject: Shell line parse needed Message-ID: <001e01c32e4c$c0c19490$0200a8c0@bartxp>
next in thread | raw e-mail | index | archive | help
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 If no matching process is found, it should report 0. I was thinking of writing a C prog for this since that is the language I can use, but I am certain this could be a very small shell script. Thanks in advance. -Derrick
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001e01c32e4c$c0c19490$0200a8c0>