Script to parse TOP output for Excel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to parse TOP output for Excel
# 1  
Old 03-21-2011
Script to parse TOP output for Excel

I'd like to parse TOP output file containing data like the below, and then be able to import the parsed file in to Excel where I can easily generate graphs. Ideally, the output would have a single column for each value in the output.

Any thoughts on how to get started with this, or a better approach? I'm a shell scripting newbie.

top - 15:21:02 up 67 days, 1:53, 4 users, load average: 0.18, 1.33, 1.91
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.7%us, 0.2%sy, 0.0%ni, 99.1%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 24676768k total, 10236276k used, 14440492k free, 231488k buffers
Swap: 26738680k total, 12648k used, 26726032k free, 4274416k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
31403 svradmin 18 0 21.7g 4.9g 10m S 2.7 21.0 352:21.80 java
# 2  
Old 03-21-2011
Code:
column -t

# 3  
Old 03-22-2011
Run the top command in batch mode so that you can redirect the output to a file.

Code:
$top -b -n 1  > <filename>
where n is the number of iterations

Other option is to have the sysstat package installed so that you can generate the performance values of CPU,DISK,I/O and Memory for a period of time.
# 4  
Old 03-22-2011
Thanks for the replies. I am generating the data via top batch mode, but having a tough time writing the shell script to parse it in a format readable by Excel to graph the data.

I'm surprised to not find something already available, as this seems like it would be a very common issue. Any references to actual existing scripts are definitely appreciated!

I will also look in to sysstat, thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script, For loop output to excel as columns

Hi, I have a shell script which analyses the log folder for a specific string and throws me the output. I have used for loop since it does this in multiple servers. Now I want to save the output in a excel in the below format. Can someone please help? The output which I get Server1 : count... (14 Replies)
Discussion started by: srilaxman
14 Replies

2. Shell Programming and Scripting

Need a script to parse data and output to csv

I am not too savvy with arrays and am assuming that what I am looking for needs arrays. This is my requirement. So I have the raw data that gets updated to a log as shown below StudentInfo: FullInfo = { Address = Newark Age = 20 Name= John } StudentInfo:... (2 Replies)
Discussion started by: sidnow
2 Replies

3. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

4. Shell Programming and Scripting

Parse excel with indent

hello everyone how to parse excel file with indents ? i was trying perl and there is Spreadsheet::ParseExcel::Format but i have no idea how to make it work docs says $format->{Indent} but it's not working also i was trying xls2csv and xlhtml but they don't care about indents at all :( i... (1 Reply)
Discussion started by: tip78
1 Replies

5. Shell Programming and Scripting

Formatting Shell script output to Excel

I am facing a problem formatting the output of my shell script in excel. We are directing the output of the script to an excel sheet and need long integer type data printed in Excel as it is (i.e. not in the default scientific notation). Also, leading zeroes(if any) in the output are getting... (4 Replies)
Discussion started by: bornali.p
4 Replies

6. Shell Programming and Scripting

Shell Script to grep output from top command.

Hello, I want a script which would grep details from top command for specific processes. I m not sure of the PID of these processes but i know the names. $ top -c top - 16:41:55 up 160 days, 5:53, 2 users, load average: 9.36, 9.18, 8.98 Tasks: 288 total, 9 running, 279 sleeping, 0... (8 Replies)
Discussion started by: Siddheshk
8 Replies

7. Shell Programming and Scripting

Perl script to parse output and print it comma separated

I need to arrange output of SQL query into a comma separated format and I'm struggling with processing the output... The output is something like this: <Attribute1 name><x amount of white spaces><Atribute value> <Attribute2 name><x amount of white spaces><Atribute value> <Attribute3... (2 Replies)
Discussion started by: Juha
2 Replies

8. Shell Programming and Scripting

Need help with shell script - output of top command

I have written shell script to send file as an attachemt of email and output of "top -o res" command as email body. it works fine if i execute manually from prompt but it does not send "top -o res" command output in email body when it is executed via crontab. Any suggestions. My script is below:... (5 Replies)
Discussion started by: needyourhelp10
5 Replies

9. Shell Programming and Scripting

write a script to parse some tcpdump output

i am trying to write a script to parse some tcpdump output, in each line of the tcpdump output, I know for sure there are 3 keywords exist: User{different usernamehere} NAS_ipaddr{different ip here} Calling_station{ip or dns name here} But the positions for these 3 keywords in the... (4 Replies)
Discussion started by: fedora
4 Replies

10. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies
Login or Register to Ask a Question