13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 11 ■ TRACKING DOWN BUGSThis outputs data (to the file specified in line 10 of the script) in the following form:Mar-19-00:30:02 0.40Mar-19-00:31:01 3.54Mar-19-00:32:01 2.68The best way to get an idea of what’s going on here is to plot it, which is where gnuplot comes in.gnuplot expects two space-delimited columns of input, which is why line 18 uses the format it does.Check man strftime for more details or for other format options to use (the script imports this POSIXmodule in Line 08). Here the usage is %b (short form of month), %d (date of month in digits), and %H:%M:%S(time in hours/minutes/seconds), separated by hyphens.Check whether you have gnuplot installed on your system, and install the gnuplot package if not.Now, here’s the gnuplot config file for this data, nfs-ping.conf:01 set terminal png size 1200,80002 set xdata time03 set timefmt "%b-%d-%H:%M:%S"04 set output "nfs-ping.png"05 set xrange ["Mar-25-00:00:00":"Mar-26-00:00:00"]06 set yrange [0:50]07 set grid08 set xlabel "Date\\nTime"09 set ylabel "Ping Response"10 set title "NFS server ping times"11 set key left box12 plot "nfs-ping-1.dat" using 1:2 index 0 title "ahost" with points■ Note In line 05, change the range to match whatever the dates of your own data are. This gives the start andend points of the x range.Line 01 sets the output as a PNG file and the size of the plot in pixels, and line 04 sets the name ofthe output file. Line 02 identifies this as a time plot, and line 03 gives the time format as it has beenrecorded in your data file; you can use man date to get more information about how to specify time data.In line 05, the specified time range must be in this format as well. Lines 08–10 set the labels for the axesand the main graph.Line 12 is the one that does most of the work. The input data file is specified first. using 1:2 meansthat columns 1 and 2 of the input data are used to create the plot. index 0 means that you use the firstdata set in the file. You can have multiple data sets in a single file, delimited by two blank lines betweeneach. Here’s an example:# data for NFS host 1col1 col2col1 col2228Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!