- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to collect data from command output
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:29 AM
06-06-2007 02:29 AM
I wanna collect some data from "top" output for writing a Unix system capacity report script. As we know, #top -d 1 will list many contents and datas, but I just wanna collect the datas from line 1 to line 11, I don't wanna get detail process CPU TTY PID .. informations, How do i do?
I know, cut -c1-11 just for columns 1 to 11 not row
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:44 AM
06-06-2007 02:44 AM
Re: How to collect data from command output
Thank you very much for your fast reply. It works according as your "head" command. I have no idea why I forgot head and tail command.
one more question:
Is there any command could collect specified row, such as 2-11 or 2-5,11-15,22 etc.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:47 AM
06-06-2007 02:47 AM
Re: How to collect data from command output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:48 AM
06-06-2007 02:48 AM
Re: How to collect data from command output
It's likely that 'sar' can give you the metrics you're interested in directly.
For example,
$ sar -u 5 12
will report CPU utilization every 5 seconds for 1 minute
$ sar -b 5 12
will report buffer activity
$ sar -d 5 12
will report disk activity
...and so on.
Note that the "system activity report package" can be used to automatically capture system data in the background. It will also generate detailed reports.
See sar(1M) and sa1(1M) for more information.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:52 AM
06-06-2007 02:52 AM
Re: How to collect data from command output
to print lines 11-15:
# sed -n '11,15p' /var/tmp/top-file
If you want to redirect that output to another file:
# sed -n '11,15p' /var/tmp/top-file > /var/tmp/top-file-11-15
If you want a single line:
# sed -n '11p' /var/tmp/top-file
These sed examples came from:
HANDY ONE-LINERS FOR SED
http://sed.sourceforge.net/sed1line.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:54 AM
06-06-2007 02:54 AM
Re: How to collect data from command output
# top -d 1 -f /var/tmp/top-file
# head -11 /var/tmp/top-file > /var/tmp/top-file-11
#!/usr/bin/sh
typeset TDIR=${TMPDIR:-/var/tmp}
typeset T1=${TDIR}/X${$}_1.out
trap 'eval rm -f ${T1}' 0 1 2 3 15
top -d 1 -f ${T1}
awk '/^CPU TTY/ {exit}; {print $0}' ${T1}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 02:55 AM
06-06-2007 02:55 AM
Re: How to collect data from command output
Print rows 2-5, 11-15, and 22:
$ sed -n '2,5p;11,15p;22p' < infile
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 03:04 AM
06-06-2007 03:04 AM
Re: How to collect data from command output
thanks for your reply.
Yes, "sar" is a very useful command. it could list many kinds of data, like cpu, disk, buffer etc. even I could use -A option like all. But except -u cpu output info is very simple and clear other info hard to read. As you may know, this system report just for a biz manager, all contents should simple and easy to read. So through compare I found "top" output is better, have cpu and mem.
sa1 and sa2 is a simple and good scripts.
thank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 03:13 AM
06-06-2007 03:13 AM
Re: How to collect data from command output
Thank you very much for your kindly helps,
"sed" command is very useful, Clay's awk CPU TTY script is very useful too. those two ways give me more idea and suggestions.
thanks again.
Have a great day and take care, buddies.