- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Again: a script help for cat top info and prin...
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
05-07-2002 06:25 PM
05-07-2002 06:25 PM
Yesterday I asked how to cat some lines of top info and I got many useful tips,
I did like this:
$ more top5
#!/bin/sh
> top.out
top -d 1 -f top.out
cat top.out | egrep '^Memory|^System|^avg'
$
And I added a cron job:
0,15,20,45 * * * * /tmp/top5>>/tmp/top5.log
Then review top5.log to check if cpu overloading.
The log contents are:
System: gbm2 Wed May 8 09:55:05 2002
avg 2.63 54.7% 0.0% 7.2% 38.1% 0.0% 0.0% 0.0% 0.0%
Memory: 3453692K (1200988K) real, 3217448K (1086940K) virtual, 1839072K free Page# 1/35
System: gbm2 Wed May 8 10:00:06 2002
avg 3.81 33.2% 0.0% 3.8% 63.0% 0.0% 0.0% 0.0% 0.0%
Memory: 3394480K (1175644K) real, 3186636K (1072384K) virtual, 1898448K free Page# 1/35
System: gbm2 Wed May 8 10:05:05 2002
avg 3.28 63.1% 0.0% 9.2% 27.7% 0.0% 0.0% 0.0% 0.0%
Memory: 3454928K (1239396K) real, 3224608K (1113676K) virtual, 1837860K free Page# 1/34
BUT I want to format the info in one line,
and substr some column like this:
System:gbm2 May 8 09:55:05 2002 avg 54.7% 38.1% Memory:3453692K (1200988K) real,1839072K free
System:gbm2 May 8 10:00:06 2002 avg 33.2% 63.0% Memory:3394480K (1175644K) real,1898448K free
System:gbm2 May 8 10:05:05 2002 avg 63.1% 27.7% Memory:3454928K (1239396K) real,1837860K free
I want to format in one line:
Sysem + DateTime + user% + idle% + mem real + mem free
The attachment is the top5 log and the format I want.
Thanks for help in advance.
Violin.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2002 06:41 PM
05-07-2002 06:41 PM
SolutionReplace
cat top.out | egrep '^Memory|^System|^avg'
with
cat top.out | egrep '^Memory|^System|^avg' | awk ' {printf $1 " " $2 " " $4 }'
Just add whatever fields you want using $x. I've only put down the 1st, 2nd and 4th fields, but you get the idea.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2002 06:51 PM
05-07-2002 06:51 PM
Re: Again: a script help for cat top info and print in one line.
q=`cat top.out | egrep '^Memory|^System|^avg' `
echo $q | awk '{ printf $1" "$2" " $4 " "$5" " $6" "$7" " $8 " " $10" " $13" "$18" "$19" "$20" "$21" "$25" "$26" \n"}'
By the way, you dont seem to have assigned points for your last post...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2002 07:09 PM
05-07-2002 07:09 PM
Re: Again: a script help for cat top info and print in one line.
THANK YOU SO MUCH MUCH MUCH MUCH MUCH!!
Today is my day and I'm so happpppy!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2002 07:20 PM
05-07-2002 07:20 PM
Re: Again: a script help for cat top info and print in one line.
top -d 1 -f top.out
Host_Name=`cat top.out|grep ^System |awk '{print $2}'`
Time=`cat top.out|grep ^System |awk '{print $3"-"$5"-"$4"-"$6}'`
Memory_Real=`cat top.out |grep ^Memory|awk '{print $2 $3}'`
Memory_Free=`cat top.out |grep ^Memory|awk '{print $8}'`
Load_avg_User=`cat top.out |grep ^avg|awk '{print $3}'`
Load_avg_Idle=`cat top.out |grep ^avg|awk '{print $6}'`
echo "System: $Host_Name $Time Avg: $Load_avg_User $Load_avg_Idle Memory: $Memory_Real(Real) $Memory_Free(Free)"
#EOS
-Niraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2002 07:28 PM
05-07-2002 07:28 PM
Re: Again: a script help for cat top info and print in one line.
stiill you have n't assigned points to your previous query !!
::::))))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2002 08:03 PM
05-07-2002 08:03 PM
Re: Again: a script help for cat top info and print in one line.
I don't know it's a manner to assign points for reply.
I've assigned points for all replies.
Thanks for your helps again.
Violin.