The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
capture shell output in cron entry steve72 UNIX for Dummies Questions & Answers 5 04-17-2008 12:00 PM
Capture ufsdump/ufsrestore output Tornado Shell Programming and Scripting 2 03-31-2008 11:47 PM
Capture output to file and printer rdasari UNIX for Advanced & Expert Users 1 01-16-2008 03:57 PM
Capture scp output Tornado Shell Programming and Scripting 7 12-06-2007 10:16 PM
Capture output from interactive script MizzGail Shell Programming and Scripting 6 04-04-2002 06:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-13-2008
fara_aris fara_aris is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 27
script to capture certain output

Hi All,
I want to create a script that capture only Date & Time, Current CPU % usage, Disk % usage, Mem % usage and Top process based on this output;

Data Collected: 05/17/08 17:19:49

Refresh Interval: 600 seconds

GlancePlus Started/Reset: 05/17/08 08:19:45
B3692A GlancePlus C.03.72.00 17:29:49 UXAMSK01 9000/800 Current Avg High
-------------------------------------------------------------------------------
CPU Util SSUUUUU | 16% 9% 22%
Disk Util F | 1% 5% 12%
Mem Util SSSSSSSSSSUUUUUUUUBBBBB | 46% 45% 46%
Swap Util UUUURRRRR | 17% 16% 17%
-------------------------------------------------------------------------------
IO BY FILE SYSTEM Users= 8
Idx File System Device Type Logl IO Phys IO
--------------------------------------------------------------------------------
1 / /dev/vg00/lvol3 vxfs 24.8/ 25.1 0.5/ 0.5
2 /stand /dev/vg00/lvol1 hfs 0.0/ 0.0 0.0/ 0.0
3 /var /dev/vg00/lvol8 vxfs 0.2/ 0.3 1.9/ 2.1
4 /usr /dev/vg00/lvol7 vxfs 35.2/ 17.7 0.9/ 0.7
5 /tmp /dev/vg00/lvol4 vxfs 0.0/ 0.0 0.0/ 0.0
6 /opt /dev/vg00/lvol6 vxfs 40.2/ 40.2 0.9/ 1.0
7 /nsm /dev/vg00/lvol10 vxfs 0.5/ 0.6 0.4/ 0.3
8 /home /dev/vg00/lvol5 vxfs 0.0/ 0.0 0.0/ 0.0
9 /app/oracle9i /dev/vg00/lvol9 vxfs 0.0/ 0.0 0.0/ 0.0
10 /BTM/aramis /dev/vgaramis/lvol1 vxfs 1092/674.8 30.8/ 91.1
11 /BTB/aramis /dev/vgbtb/lvol1 vxfs 0.0/ 0.0 0.0/ 0.0
12 swap device /dev/vg00/lvol2 hfs 0.0/ 0.0 0.0/ 0.0

Top disk user: PID 11053, s_server 10.0 IOs/sec S - Select a Disk


Any advise?
  #2 (permalink)  
Old 08-13-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,631
Supposing the presented text is stored in /some/file:


Code:
sed -n '1p;8,10 {;s/^\([^ ]*\) [^0-9]*\([0-9]*%\).*$/\1 \2/p;};$p' /some/file

I hope this helps.

bakunin
  #3 (permalink)  
Old 08-13-2008
fara_aris fara_aris is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 27
Hi bakunin,
I've tested the script, and this is the output that I received;

B3692A GlancePlus C.03.72.00 08:19:46 UXAMSK01 9000/800 Current Avg High


I want the output to be like this;

Data Collected: 05/17/08 17:19:49
UXAMSK01 Current
-------------------------------------------------------------------------------
CPU 16%
Disk 1%
Mem 46%

Top disk user: PID 11053, s_server 10.0 IOs/sec S - Select a Disk

Is it possible?
  #4 (permalink)  
Old 08-14-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,631
Hm, i have tried the script with the following file, on which it does (almost - the "...Current..."-line is missing) exactly that:


Code:
Data Collected: 05/17/08 17:19:49

Refresh Interval: 600 seconds

GlancePlus Started/Reset: 05/17/08 08:19:45
B3692A GlancePlus C.03.72.00 17:29:49 UXAMSK01 9000/800 Current Avg High
-------------------------------------------------------------------------------
CPU Util SSUUUUU | 16% 9% 22%
Disk Util F | 1% 5% 12%
Mem Util SSSSSSSSSSUUUUUUUUBBBBB | 46% 45% 46%
Swap Util UUUURRRRR | 17% 16% 17%
-------------------------------------------------------------------------------
IO BY FILE SYSTEM Users= 8
Idx File System Device Type Logl IO Phys IO
--------------------------------------------------------------------------------
1 / /dev/vg00/lvol3 vxfs 24.8/ 25.1 0.5/ 0.5
2 /stand /dev/vg00/lvol1 hfs 0.0/ 0.0 0.0/ 0.0
3 /var /dev/vg00/lvol8 vxfs 0.2/ 0.3 1.9/ 2.1
4 /usr /dev/vg00/lvol7 vxfs 35.2/ 17.7 0.9/ 0.7
5 /tmp /dev/vg00/lvol4 vxfs 0.0/ 0.0 0.0/ 0.0
6 /opt /dev/vg00/lvol6 vxfs 40.2/ 40.2 0.9/ 1.0
7 /nsm /dev/vg00/lvol10 vxfs 0.5/ 0.6 0.4/ 0.3
8 /home /dev/vg00/lvol5 vxfs 0.0/ 0.0 0.0/ 0.0
9 /app/oracle9i /dev/vg00/lvol9 vxfs 0.0/ 0.0 0.0/ 0.0
10 /BTM/aramis /dev/vgaramis/lvol1 vxfs 1092/674.8 30.8/ 91.1
11 /BTB/aramis /dev/vgbtb/lvol1 vxfs 0.0/ 0.0 0.0/ 0.0
12 swap device /dev/vg00/lvol2 hfs 0.0/ 0.0 0.0/ 0.0

Top disk user: PID 11053, s_server 10.0 IOs/sec S - Select a Disk <end-of-file>

bakunin
  #5 (permalink)  
Old 08-14-2008
broli's Avatar
broli broli is offline
Registered User
  
 

Join Date: Dec 2007
Location: Argentina
Posts: 215
with awk it would be easier

awk 'NR==8 { print $5 } \
NR==9 { print $5 }\
NR==10 { print $5 }' datafile

acomplish the first part ....
  #6 (permalink)  
Old 08-14-2008
fara_aris fara_aris is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 27
bakunin,
i've managed to get the output that i desired using the script that you've given, but now i'm facing another problem. the output file (/some/file) is not static, it has more output, because it has 600 seconds interval. so in one output file, i can have more entries like the one i've shown below.

so how to make the script to capture (time, cpu/disk/mem-current and top process) and direct it into one file (e.g output.out)?

which means, when i run the script, e.g:
sed -n '1p;8,10 {;s/^\([^ ]*\) [^0-9]*\([0-9]*%\).*$/\1 \2/p;};$p' /home/fara/AMSK01_glance.out_20080517
i want to get output.out that looks like this;

Data Collected: 05/17/08 17:19:49
UXAMSK01 Current
-------------------------------------------------------------------------------
CPU 16%
Disk 1%
Mem 46%

Top disk user: PID 11053, s_server 10.0 IOs/sec S - Select a Disk

Data Collected: 05/17/08 17:29:49
UXAMSK01 Current
-------------------------------------------------------------------------------
CPU 16%
Disk 1%
Mem 46%

Top disk user: PID 11053, s_server 10.0 IOs/sec S - Select a Disk

Data Collected: 05/17/08 17:39:49
UXAMSK01 Current
-------------------------------------------------------------------------------
CPU 16%
Disk 1%
Mem 46%

Top disk user: PID 11053, s_server 10.0 IOs/sec S - Select a Disk


(etc)

Sorry if it's troublesome..

  #7 (permalink)  
Old 08-14-2008
fara_aris fara_aris is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 27
broli,
i don't understand what you mean.. kindly explain..

thanks
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0