Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm logging some data relative to clients NFS usage over a network. Now I want to plot it on a lines diagram, and I'm overwhelmed by the possibilities I'm finding out there. No one seems to be easy to understand for me.

Here's a simplified log:

1356112995    766
1356112995    14
1356112995   5
1356112995    38
1356114790    760
1356114790    10
1356114790    18
1356116586    758
1356116586    9
1356118387    783
1356120187    687
1356121987    699
1356123787    371
1356125587    717
1356127386    0

First column is a timestamp, it should be on the X axis. Second column is the client IP. Third column is the number of operations, it should be on the Y axis. The graph should be a line graph.

I want this to be automatic, so plotting from the command line is the way to go. No idea on how to do that, though.

It should generate a png file that will be subsequently uploaded to some webserver for visualization.

share|improve this question
do you want to see the plot in the command line or do you want to create an image and post in on the website or something? – mnmnc Dec 23 '12 at 1:09
Create an image and upload it to a webserver. I'm going to clarify this on the original post. Thanks. – Jorge Suárez de Lis Dec 23 '12 at 1:11
I like pCharts -> But this would generate a javascript chart not a picture like jpg or gif. If you want flexibility and nice look i would go with something like that. If you must have a jpg or some bitmap based picture - gnuplot will probably suit you best. – mnmnc Dec 23 '12 at 1:25
Thank you. I've tried to understand gnuplot but it won't make it easy. I'll take a look into pCharts some day, looks interesting. – Jorge Suárez de Lis Dec 23 '12 at 23:56
up vote 0 down vote accepted

There are probably some ways to do this without installing software (With NFS, I assume you're using a Linux box). But, my favorite solution involves R which is free and available for Linux/Windows/Mac, etc. and will present you with myriad opportunities to customize your plot or manipulate your data.

Step 1
Make a script with code that looks something like this:

logfile <- read.table(file="client.log") #Adjust the logfile name as needed.
#This assumes tab separated columns. 
#If needed, column delimiters can be adjusted.
names(logfile) <- c("time.stamp","client","operations") 
#Rename the columns of the input data (if they are named at all)
require(lattice) #This package is needed for the xyplot() function below.  
#The main benefit of this function for your purposes is the ability to color 
#your plot circles by client name.
png(filename="logfile.png") #Designate the plot file type and save location
#I've added jitter here which helps prevent plotted points from overlapping. #Close and save the plot

I called my script

Step 2
From a Unix or Mac command line you can call the script in this manner:

share|improve this answer
Thank you very much! I'm now looking into lattice documentation to personalize the plotting. Fortunately, I've used R some years ago, so I remember the basics. – Jorge Suárez de Lis Dec 23 '12 at 23:30
@jorge-suarez-de-lis, great! Glad you found something that meets your needs. Using lattice might have been a bit of overkill here, but it was the quickest way I could think of to plot the entire log with one simple command while at the same time assigning different colors to different "clients." – D. Woods Dec 24 '12 at 6:22

This is really late, but as I happened across this post, I'll put in my two pennies.

Without installing R, we can use call awk within gnuplot:

plot "<awk '{print $1, $3}' logfile" u 1:2

where the output of the awk command in the double quotes is used by gnuplot to plot your data. The awk command simply prints out the first and third column.

You can place the above command into a gnuplot file, such as and then call it on the command line like so

gnuplot -e "logfile='your_actual_log_file.log'"

which is a command that is easily placed into a cron job or some script you have. Note the single quotes around the text.

I just wanted to demonstrate that gnuplot is actually really flexible as it can take command line arguments and assign them as variables within a script. No heavy dependencies (looking at you, R) as awk is pretty pervasive.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .