3

I have some data from a log file. I would like to graph how many times an error happened during a time period.

For exmample:

09:00:01, error_1, blah blah blah
09:00:10, error_1, blah blah blah
09:00:23, error_1, blah blah blah
09:01:10, error_2, blah blah blah
09:07:01, error_1, blah blah blah
09:07:43, error_1, blah blah blah
09:11:03, error_1, blah blah blah 
09:18:10, error_1, blah blah blah
09:40:57, error_2, blah blah blah 
09:41:23, error_1, blah blah blah
...
23:32:20 error_1

So with the above, I would like to plot the values so that I can show a week with individual points being in hour intervals and showing the sum of "error_1" for that hour... Hope that makes sense.

If anyone could help me out it would be greatly appreciated! If there is a way to do this entirely with gnuplot that would be even better.

Thanks!

matak
  • 173
  • 1
  • 8

1 Answers1

0

You're looking to make gnuplot do the binning to make a histogram. The only trick is that you need to filter out rows based on their error codes. You could probably do the filtering in gnuplot, but it's MUCH easier to use something like grep.

set xdata time
set timefmt '%H:%M:%S'
set datafile sep ','
binwidth = 3600  #3600 seconds in an hour.
bin(x,width) = width*floor(x/width)
plot for [ERR in "error_1 error_2"] sprintf('<grep %s test.dat',ERR) u (bin($1,binwidth)):(1.0) smooth freq w boxes ti ERR
Community
  • 1
  • 1
mgilson
  • 300,191
  • 65
  • 633
  • 696
  • Thanks! I think I got the majority of what you are doing here... What is :(1.0) doing? Also, I am getting a error "all points y undefined!" with an error pointing all the way at the end of the line. – matak Nov 09 '12 at 22:20
  • `(1.0)` is the literal constant 1. It adds one to the value for each data that falls into the particular bin. – mgilson Nov 10 '12 at 01:22
  • Hey thanks for helping! I am getting some errors and cannot figure out what I am doing wrong. Here is the gnuplot commands that I am using. `set timefmt "%m/%d/%Y %H:%M" set xdata time set terminal png size 1024,768 set output "xxx.png"\n set format x "%m/%d\n%H:%M" set xrange ["11/6/2012 20:19":"11/7/2012 10:00"] binwidth = 3600 #3600 seconds in an hour. bin(x,width) = width*floor(x/width) plot for [ERR in "HBER RX_FAILURE"] sprintf(' – matak Nov 12 '12 at 16:15
  • Here is a sample of the log that I am trying to plot. `xxxx/radio-1.4.123123132.1,RX_FAILURE,MAJOR,,11/7/2012 16:52,11/7/2012 16:52
    xxxx/radio-1.4.123123123.1,HBER,MAJOR,,11/7/2012 16:52,11/7/2012 16:52`
    – matak Nov 12 '12 at 16:15