Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to create a line chart to display the cpu usage of each process over time. How do I create the chart with time as the X axis, %CPU as the Y axis, then use the command name to indicate which line on the chart the data belongs to?

My data was created using the unix command:

pidstat -hdul 1 > file.txt

I then reformatted the data into csv using this command:

sed '1d;/^[#]/d;/^$/d;s/^[ ]*//;s/[ ]+/,/g' raw_data_file_input > nice_data_file.csv

My data is organized into the following columns:

Time, PID, %usr, %system, %guest, %CPU, CPU, KB_rd/s, KB_wr/s, KB_ccwr/s, Command

In other words, I want every command "kjournald" to be one line on the graph at various times, and "gnome-panel" to be another separate line.

Here is a sample of the data in csv format:

1320713878,680,0.00,0.00,0.00,0.00,0,0.00,35.64,0.00,kjournald
1320713878,2831,1.98,1.98,0.00,3.96,0,0.00,0.00,0.00,/usr/bin/X,:0,-br,-verbose,-auth,/var/run/gdm/auth-for-gdm-LiEP18/database,-nolisten,tcp,vt7,
1320713878,4360,0.00,1.98,0.00,1.98,0,0.00,0.00,0.00,gnome-terminal,
1320713878,7897,1.98,0.00,0.00,1.98,0,0.00,0.00,0.00,gnome-panel,
1320713878,24834,0.00,0.99,0.00,0.99,0,0.00,0.00,0.00,networking,networking,file:///usr/local/src/opensplice/install/HDE/x86.linux2.6/etc/config/ospl.xml,
1320713878,24986,0.00,1.98,0.00,1.98,1,0.00,0.00,0.00,pidstat,-hdul,1,
1320713879,2426,1.00,1.00,0.00,2.00,3,0.00,0.00,0.00,/usr/bin/prltoolsd,-p,/var/run/prltoolsd.pid,
1320713879,2831,2.00,1.00,0.00,3.00,2,0.00,4.00,0.00,/usr/bin/X,:0,-br,-verbose,-auth,/var/run/gdm/auth-for-gdm-LiEP18/database,-nolisten,tcp,vt7,
1320713879,7904,14.00,0.00,0.00,14.00,1,0.00,0.00,0.00,nautilus,--no-desktop,--browser,
1320713879,24834,0.00,1.00,0.00,1.00,0,0.00,0.00,0.00,networking,networking,file:///usr/local/src/opensplice/install/HDE/x86.linux2.6/etc/config/ospl.xml,
1320713879,24992,0.00,2.00,0.00,2.00,0,0.00,0.00,0.00,/bin/sh,./killAll.sh,
1320713880,2831,0.00,1.00,0.00,1.00,1,0.00,0.00,0.00,/usr/bin/X,:0,-br,-verbose,-auth,/var/run/gdm/auth-for-gdm-LiEP18/database,-nolisten,tcp,vt7,
1320713880,3466,0.00,1.00,0.00,1.00,2,0.00,0.00,0.00,/usr/sbin/nscd,
1320713880,4129,0.00,2.00,0.00,2.00,0,0.00,0.00,0.00,/usr/bin/prl_wmouse_d,-d,
1320713880,24986,0.00,2.00,0.00,2.00,2,0.00,0.00,0.00,pidstat,-hdul,1,
1320713880,24992,0.00,2.00,0.00,2.00,3,0.00,0.00,0.00,/bin/sh,./killAll.sh,
share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I don't know how familiar you are with the "Text-to-columns" tool on Excel's "Data" tab, but you can use that to quickly split apart your comma-delimited file.

I may be missing something, but, it appears to me that your sample data has only one instance of each "Command". I couldn't construct a time-dependent line chart with a single data point, so I made up some additional "dummy" data, with dummy values for each "time".

A pivot table will easily handle this. The pivot table will sort the data and you can filter it to only show certain categories ("Commands", in this case).

Once you've built your pivot table you can then click anywhere in the pivot table and "Insert" a chart. See below.

enter image description here

share|improve this answer
    
There are definitely multiple instances of command. Is it possible for you to post a link to that sample file you created so I can figure out how to correctly create the pivot tables? Oh I see, you simply filter each column based on each "Command" in the pivot table, then graph that. –  Andrew Hundt Nov 9 '11 at 20:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.