script to capture certain output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to capture certain output
# 1  
Old 08-13-2008
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  
Old 08-13-2008
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  
Old 08-13-2008
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  
Old 08-14-2008
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  
Old 08-14-2008
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  
Old 08-14-2008
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  
Old 08-14-2008
broli,
i don't understand what you mean.. kindly explain..

thanks Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep -P does not capture the desired output

Hi, I'm trying to filter the following output to only display information about an alarm where the Status: corresponds to Set. -------------------------------------------------------- Description: hw_optics: RX POWER LANE-0 LOW ALARM Location: Optics0/0/0/21... (6 Replies)
Discussion started by: sand1234
6 Replies

2. Shell Programming and Scripting

Capture output from expect script

Hi I am new to Expect scripting. I have to connect to a remote server and capture the output. Here I need output of " send "list registered\r"" to be stored in a file. but after execution, /tmp/capture.txt is of 0 byte #!/usr/bin/expect spawn ssh abc@10.10.10.10 -p 5022 expect... (2 Replies)
Discussion started by: bns928
2 Replies

3. Shell Programming and Scripting

Want ro capture the debug in output file

I want to capture the debug for the below command in output file . i tried like this but its not working: sh -xv <scriptname> >> output.log i want the output in a log file. Anyone plz help in this (2 Replies)
Discussion started by: chakkaravarthy
2 Replies

4. Shell Programming and Scripting

How to capture output to log file

Hi I have a script that will run multiple unix & sql commands. I want to see the output as well as capture it to a log file for further analysis. Is there an easy way to do that instead of adding "tee -a logfile" on everyline or even on the execute line (i.e. script | tee -s logfile). Thanks (1 Reply)
Discussion started by: nimo
1 Replies

5. Shell Programming and Scripting

Script to capture snoop output

Hi Everyone :), Need your advice as I'm new to UNIX scripting.. I'm trying to write a script to capture snoop output for 5 minutes for every hour for 24 hours. To stop snoop, I need to press Control-C to break it. This is what I got so far, but now I'm stuck! :confused: The script: # cat... (2 Replies)
Discussion started by: faraaris
2 Replies

6. Shell Programming and Scripting

Enter the command to capture output--help

&& echo "PLEASE enter the command to capture output" || echo "Processing your command manual" x=$# echo $x while do while man $@ | read -r line do >$@.txt ... (1 Reply)
Discussion started by: rrd1986
1 Replies

7. Shell Programming and Scripting

Capture Shell Script Output To A File

Hi, I am running a shell script called dbProcess.sh which performs shutdown and startup of various Oracle instances we have.At the time of execution the script produces the following output to the command line window $./dbProcess.sh stop #### Run Details ###### Hostname : server-hop-1... (4 Replies)
Discussion started by: rajan_san
4 Replies

8. UNIX for Advanced & Expert Users

Capture output to file and printer

Hi All : I wanted a unix command by which I could be able to print the output to a file and at the same time to a printer. Any help will be greatly appreciated. Regards, Ramamurthy Dasari (1 Reply)
Discussion started by: rdasari
1 Replies

9. Shell Programming and Scripting

Capture scp output

I have a simple script that uses scp to copy some files from one server to another. I want to capture the files that are copied but simple redirection to a file does not work. So I want to capture this output from the scp command in a log file. -bash-3.00$ scp -pr /export/jumpstart/Files... (7 Replies)
Discussion started by: Tornado
7 Replies

10. Shell Programming and Scripting

Capture output from interactive script

I have written a menu driven script to walk users through bringing up and down an application process. Sometimes the user tells me the script does not work taking the application down, but he can't recall seeing an error message. Is there a way to capture std out and stderr out from an... (6 Replies)
Discussion started by: MizzGail
6 Replies
Login or Register to Ask a Question