X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=doc%2Frrdtutorial.1;h=db57748d29e9993fddafab501cdcb6a73f7d5c90;hb=d9822df7ed5e8122cf3a62e4e99678e94007f504;hp=5a22139f28450629d3fe32313306ae87bd5d6dda;hpb=034c985d61f53f91dac1c2f5facffa51b145a536;p=pkg-rrdtool.git diff --git a/doc/rrdtutorial.1 b/doc/rrdtutorial.1 index 5a22139..db57748 100644 --- a/doc/rrdtutorial.1 +++ b/doc/rrdtutorial.1 @@ -1,15 +1,7 @@ -.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 +.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== -.de Sh \" Subsection heading -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp @@ -48,22 +40,25 @@ . ds R" '' 'br\} .\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" .\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. -.if \nF \{\ +.ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} -.\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 -.if n .na +.el \{\ +. de IX +.. +.\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,14 +124,18 @@ .\" ======================================================================== .\" .IX Title "RRDTUTORIAL 1" -.TH RRDTUTORIAL 1 "2008-03-15" "1.3rc4" "rrdtool" +.TH RRDTUTORIAL 1 "2013-05-23" "1.4.8" "rrdtool" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh .SH "NAME" rrdtutorial \- Alex van den Bogaerdt's RRDtool tutorial .SH "DESCRIPTION" .IX Header "DESCRIPTION" RRDtool is written by Tobias Oetiker with contributions from many people all around the world. This document is -written by Alex van den Bogaerdt to help you +written by Alex van den Bogaerdt to help you understand what RRDtool is and what it can do for you. .PP The documentation provided with RRDtool can be too technical for some @@ -146,42 +145,61 @@ It also explains the general things about statistics with a focus on networking. .SH "TUTORIAL" .IX Header "TUTORIAL" -.Sh "Important" +.SS "Important" .IX Subsection "Important" Please don't skip ahead in this document! The first part of this document explains the basics and may be boring. But if you don't understand the basics, the examples will not be as meaningful to you. -.Sh "What is RRDtool?" +.PP +Sometimes things change. This example used to provide numbers like +\&\*(L"0.04\*(R" in stead of \*(L"4.00000e\-02\*(R". Those are really the same numbers, +just written down differently. Don't be alarmed if a future version +of rrdtool displays a slightly different form of output. The examples +in this document are correct for version 1.2.0 of RRDtool. +.PP +Also, sometimes bugs do occur. They may also influence the outcome of +the examples. Example speed4.png was suffering from this (the handling +of unknown data in an if-statement was wrong). Normal data will be +just fine (a bug in rrdtool wouldn't last long) but special cases like +NaN, \s-1INF\s0 and so on may last a bit longer. Try another version if you +can, or just live with it. +.PP +I fixed the speed4.png example (and added a note). There may be other +examples which suffer from the same or a similar bug. Try to fix it +yourself, which is a great excercise. But please do not submit your +result as a fix to the source of this document. Discuss it on the +user's list, or write to me. +.SS "What is RRDtool?" .IX Subsection "What is RRDtool?" RRDtool refers to Round Robin Database tool. Round robin is a technique that works with a fixed amount of data, and a pointer to the current element. Think of a circle with some dots plotted -on the edge \*(-- these dots are the places where data can be stored. Draw an -arrow from the center of the circle to one of the dots \*(-- this is the pointer. +on the edge. These dots are the places where data can be stored. Draw an +arrow from the center of the circle to one of the dots; this is the pointer. When the current data is read or written, the pointer moves to the next element. As we are on a circle there is neither a beginning nor an end, you can go on and on and on. After a while, all the available places will be used and the process automatically reuses old locations. This way, the dataset will not grow in size and therefore requires no maintenance. -RRDtool works with with Round Robin Databases (RRDs). It stores and retrieves +RRDtool works with Round Robin Databases (RRDs). It stores and retrieves data from them. -.Sh "What data can be put into an \s-1RRD\s0?" +.SS "What data can be put into an \s-1RRD\s0?" .IX Subsection "What data can be put into an RRD?" -You name it, it will probably fit as long as it is some sort of time-series -data. This means you have to be able to measure some value at several points in time and -provide this information to RRDtool. If you can do this, RRDtool will be -able to store it. The values must be numerical but don't have to be -integers, as is the case with \s-1MRTG\s0 (the next section will give more details -on this more specialized application). +You name it, it will probably fit as long as it is some sort of +time-series data. This means you have to be able to measure some value +at several points in time and provide this information to RRDtool. If +you can do this, RRDtool will be able to store it. The values must be +numerical but don't have to be integers, as is the case with \s-1MRTG\s0 (the +next section will give more details on this more specialized application). .PP Many examples below talk about \s-1SNMP\s0 which is an acronym for Simple Network -Management Protocol. \*(L"Simple\*(R" refers to the protocol \*(-- it does not +Management Protocol. \*(L"Simple\*(R" refers to the protocol. It does not mean it is simple to manage or monitor a network. After working your way through this document, you should know enough to be able to understand what people are talking about. For now, just realize that \&\s-1SNMP\s0 can be used to query devices for the values of counters they keep. It is the value from those counters that we want to store in the \s-1RRD\s0. -.Sh "What can I do with this tool?" +.SS "What can I do with this tool?" .IX Subsection "What can I do with this tool?" RRDtool originated from \s-1MRTG\s0 (Multi Router Traffic Grapher). \s-1MRTG\s0 started as a tiny little script for graphing the use of a university's @@ -191,11 +209,11 @@ number of printouts and the like. .PP Most likely you will start to use RRDtool to store and process data collected via \s-1SNMP\s0. The data will most likely be bytes (or bits) -transfered from and to a network or a computer. But it can also be +transferred from and to a network or a computer. But it can also be used to display tidal waves, solar radiation, power consumption, number of visitors at an exhibition, noise levels near an airport, temperature on your favorite holiday location, temperature in the -fridge and whatever you imagination can come up with. +fridge and whatever your imagination can come up with. .PP You only need a sensor to measure the data and be able to feed the numbers into RRDtool. RRDtool then lets you create a database, store @@ -203,7 +221,7 @@ data in it, retrieve that data and create graphs in \s-1PNG\s0 format for display on a web browser. Those \s-1PNG\s0 images are dependent on the data you collected and could be, for instance, an overview of the average network usage, or the peaks that occurred. -.Sh "What if I still have problems after reading this document?" +.SS "What if I still have problems after reading this document?" .IX Subsection "What if I still have problems after reading this document?" First of all: read it again! You may have missed something. If you are unable to compile the sources and you have a fairly common @@ -226,7 +244,7 @@ I suggest you take a moment to subscribe to the mailing list right now by sending an email to with a subject of \*(L"subscribe\*(R". If you ever want to leave this list, just write an email to the same address but now with a subject of \*(L"unsubscribe\*(R". -.Sh "How will you help me?" +.SS "How will you help me?" .IX Subsection "How will you help me?" By giving you some detailed descriptions with detailed examples. I assume that following the instructions in the order presented @@ -239,7 +257,7 @@ more important, some background information of how it works. .PP You will need to know something about hexadecimal numbers. If you don't then start with reading bin_dec_hex before you continue here. -.Sh "Your first Round Robin Database" +.SS "Your first Round Robin Database" .IX Subsection "Your first Round Robin Database" In my opinion the best way to learn something is to actually do it. Why not start right now? We will create a database, put some values @@ -252,7 +270,7 @@ all the same: some number over some time. .PP Assume we have a device that transfers bytes to and from the Internet. This device keeps a counter that starts at zero when it is turned on, -increasing with every byte that is transfered. This counter will probably have +increasing with every byte that is transferred. This counter will probably have a maximum value. If this value is reached and an extra byte is counted, the counter starts over at zero. This is the same as many counters in the world such as the mileage counter in a car. @@ -261,10 +279,10 @@ Most discussions about networking talk about bits per second so lets get used to that right away. Assume a byte is eight bits and start to think in bits not bytes. The counter, however, still counts bytes! In the \s-1SNMP\s0 world most of the counters are 32 bits. That means they are -counting from 0 to 4'294'967'295. We will use these values in the examples. +counting from 0 to 4294967295. We will use these values in the examples. The device, when asked, returns the current value of the counter. We know the time that has passes since we last asked so we now know how -many bytes have been transfered ***on average*** per second. This is +many bytes have been transferred ***on average*** per second. This is not very hard to calculate. First in words, then in calculations: .IP "1." 3 Take the current counter, subtract the previous value from it. @@ -287,36 +305,36 @@ most into miles per hour by dividing km by 1.6 (close enough). I will use the following abbreviations: .PP .Vb 6 -\& M: meter -\& KM: kilometer (= 1'000 meters). -\& H: hour -\& S: second -\& KM/H: kilometers per hour -\& M/S: meters per second +\& m: meter +\& km: kilometer (= 1000 meters). +\& h: hour +\& s: second +\& km/h: kilometers per hour +\& m/s: meters per second .Ve .PP You are driving a car. At 12:05 you read the counter in the dashboard -and it tells you that the car has moved 12'345 \s-1KM\s0 until that moment. -At 12:10 you look again, it reads 12'357 \s-1KM\s0. This means you have -traveled 12 \s-1KM\s0 in five minutes. A scientist would translate that +and it tells you that the car has moved 12345 km until that moment. +At 12:10 you look again, it reads 12357 km. This means you have +traveled 12 km in five minutes. A scientist would translate that into meters per second and this makes a nice comparison toward the problem of (bytes per five minutes) versus (bits per second). .PP -We traveled 12 kilometers which is 12'000 meters. We did that in five -minutes or 300 seconds. Our speed is 12'000M / 300S or 40 M/S. +We traveled 12 kilometers which is 12000 meters. We did that in five +minutes or 300 seconds. Our speed is 12000m / 300s or 40 m/s. .PP -We could also calculate the speed in \s-1KM/H:\s0 12 times 5 minutes -is an hour, so we have to multiply 12 \s-1KM\s0 by 12 to get 144 \s-1KM/H\s0. -For our native English speaking friends: that's 90 \s-1MPH\s0 so don't +We could also calculate the speed in km/h: 12 times 5 minutes +is an hour, so we have to multiply 12 km by 12 to get 144 km/h. +For our native English speaking friends: that's 90 mph so don't try this example at home or where I live :) .PP Remember: these numbers are averages only. There is no way to figure out from the numbers, if you drove at a constant speed. There is an example later on in this tutorial that explains this. .PP -I hope you understand that there is no difference in calculating M/S or -bps; only the way we collect the data is different. Even the K from kilo -is the same as in networking terms k also means 1'000. +I hope you understand that there is no difference in calculating m/s or +bps; only the way we collect the data is different. Even the k from kilo +is the same as in networking terms k also means 1000. .PP We will now create a database where we can keep all these interesting numbers. The method used to start the program may differ slightly from @@ -335,11 +353,11 @@ and skip all of the '\e' characters. .Ve .PP (So enter: \f(CW\*(C`rrdtool create test.rrd \-\-start 920804400 DS ...\*(C'\fR) -.Sh "What has been created?" +.SS "What has been created?" .IX Subsection "What has been created?" We created the round robin database called test (test.rrd) which starts at noon the day I started writing this document, 7th of March, 1999 (this date -translates to 920'804'400 seconds as explained below). Our database holds +translates to 920804400 seconds as explained below). Our database holds one data source (\s-1DS\s0) named \*(L"speed\*(R" that represents a counter. This counter is read every five minutes (this is the default therefore you don't have to put \f(CW\*(C`\-\-step=300\*(C'\fR). In the same database two round robin archives (RRAs) @@ -361,22 +379,22 @@ As an example: where I will see \*(L"12:05\*(R" the \s-1UK\s0 folks will see \*( We now have to fill our database with some numbers. We'll pretend to have read the following numbers: .PP -.Vb 15 -\& 12:05 12345 KM -\& 12:10 12357 KM -\& 12:15 12363 KM -\& 12:20 12363 KM -\& 12:25 12363 KM -\& 12:30 12373 KM -\& 12:35 12383 KM -\& 12:40 12393 KM -\& 12:45 12399 KM -\& 12:50 12405 KM -\& 12:55 12411 KM -\& 13:00 12415 KM -\& 13:05 12420 KM -\& 13:10 12422 KM -\& 13:15 12423 KM +.Vb 10 +\& 12:05 12345 km +\& 12:10 12357 km +\& 12:15 12363 km +\& 12:20 12363 km +\& 12:25 12363 km +\& 12:30 12373 km +\& 12:35 12383 km +\& 12:40 12393 km +\& 12:45 12399 km +\& 12:50 12405 km +\& 12:55 12411 km +\& 13:00 12415 km +\& 13:05 12420 km +\& 13:10 12422 km +\& 13:15 12423 km .Ve .PP We fill the database as follows: @@ -412,9 +430,7 @@ It should return the following output: .PP .Vb 1 \& speed -.Ve -.PP -.Vb 16 +\& \& 920804700: nan \& 920805000: 4.0000000000e\-02 \& 920805300: 2.0000000000e\-02 @@ -431,22 +447,22 @@ It should return the following output: \& 920808600: 6.6666666667e\-03 \& 920808900: 3.3333333333e\-03 \& 920809200: nan +\& 920809500: nan .Ve .PP -If it doesn't, something may be wrong. Perhaps your \s-1OS\s0 will print -\&\*(L"NaN\*(R" in a different form. \*(L"NaN\*(R" stands for \*(L"Not A Number\*(R". If your \s-1OS\s0 -writes \*(L"U\*(R" or \*(L"\s-1UNKN\s0\*(R" or something similar that's okay. If something -else is wrong, it will probably be due to an error you made (assuming -that my tutorial is correct of course :\-). In that case: delete the -database and try again. Sometimes things change. This example used -to provide numbers like \*(L"0.04\*(R" in stead of \*(L"4.00000e\-02\*(R". Those are -really the same numbers, just written down differently. Don't be -alarmed if a future version of rrdtool displays a slightly different -form of output. The examples in this document are correct for version -1.2.0 of RRDtool. +Note that you might get more rows than you expect. The reason for this is +that you ask for a time range that ends on 920809200. The number that is +written behind 920809200: in the list above covers the time range from +920808900 to 920809200, \s-1EXCLUDING\s0 920809200. Hence to be on the sure side, +you receive the entry from 920809200 to 920809500 as well since it \s-1INCLUDES\s0 +920809200. You may also see \*(L"NaN\*(R" instead of \*(L"nan\*(R" this is \s-1OS\s0 dependent. +\&\*(L"NaN\*(R" stands for \*(L"Not A Number\*(R". If your \s-1OS\s0 writes \*(L"U\*(R" or \*(L"\s-1UNKN\s0\*(R" or +something similar that's okay. If something else is wrong, it will probably +be due to an error you made (assuming that my tutorial is correct of course +:\-). In that case: delete the database and try again. .PP The meaning of the above output will become clear below. -.Sh "Time to create some graphics" +.SS "Time to create some graphics" .IX Subsection "Time to create some graphics" Try the following command: .PP @@ -461,7 +477,7 @@ This will create speed.png which starts at 12:00 and ends at 13:00. There is a definition of a variable called myspeed, using the data from \s-1RRA\s0 \&\*(L"speed\*(R" out of database \*(L"test.rrd\*(R". The line drawn is 2 pixels high and represents the variable myspeed. The color is red (specified by -its rgb\-representation, see below). +its rgb-representation, see below). .PP You'll notice that the start of the graph is not at 12:00 but at 12:05. This is because we have insufficient data to tell the average before @@ -484,28 +500,28 @@ The \*(L"color\*(R" black is all colors off: 000000 \& gray #555555 (one third of all components) .Ve .PP -Additionally you can add an alpha channel (transparency). The default -will be \*(L"\s-1FF\s0\*(R" which means non\-transparent. +Additionally you can (with a recent RRDtool) add an alpha channel +(transparency). The default will be \*(L"\s-1FF\s0\*(R" which means non-transparent. .PP The \s-1PNG\s0 you just created can be displayed using your favorite image viewer. Web browsers will display the \s-1PNG\s0 via the \s-1URL\s0 \&\*(L"file:///the/path/to/speed.png\*(R" -.Sh "Graphics with some math" +.SS "Graphics with some math" .IX Subsection "Graphics with some math" When looking at the image, you notice that the horizontal axis is labeled 12:10, 12:20, 12:30, 12:40 and 12:50. Sometimes a label doesn't fit (12:00 -and 13:00 would be candidates) so they are skipped. +and 13:00 would be likely candidates) so they are skipped. .PP The vertical axis displays the range we entered. We provided kilometers and when divided by 300 seconds, we get very small -numbers. To be exact, the first value was 12 (12'357\-12'345) and divided +numbers. To be exact, the first value was 12 (12357\-12345) and divided by 300 this makes 0.04, which is displayed by RRDtool as \*(L"40 m\*(R" -meaning \*(L"40/1'000\*(R". The \*(L"m\*(R" (milli) has nothing to do with meters, +meaning \*(L"40/1000\*(R". The \*(L"m\*(R" (milli) has nothing to do with meters (also m), kilometers or millimeters! RRDtool doesn't know about the physical units of our data, it just works with dimensionless numbers. .PP If we had measured our distances in meters, this would have been -(12'357'000\-12'345'000)/300 = 12'000/300 = 40. +(12357000\-12345000)/300 = 12000/300 = 40. .PP As most people have a better feel for numbers in this range, we'll correct that. We could recreate our database and store the correct @@ -521,10 +537,19 @@ the png file! \& LINE2:realspeed#FF0000 .Ve .PP -Note: Make sure not to forget the backslash \e in front of the -multiplication operator * above. The backslash is needed to \*(L"escape\*(R" -the * as some operating systems might interpret and expand * instead -of passing it to the rrdtool command. +Note: I need to escape the multiplication operator * with a backslash. +If I don't, the operating system may interpret it and use it for file +name expansion. You could also place the line within quotation marks +like so: +.PP +.Vb 1 +\& "CDEF:realspeed=myspeed,1000,*" \e +.Ve +.PP +It boils down to: it is RRDtool which should see *, not your shell. +And it is your shell interpreting \e, not RRDtool. You may need to +adjust examples accordingly if you happen to use an operating +system or shell which behaves differently. .PP After viewing this \s-1PNG\s0, you notice the \*(L"m\*(R" (milli) has disappeared. This it what the correct result would be. Also, a label @@ -538,22 +563,22 @@ those\*(R". Don't bother with \s-1RPN\s0 yet, it will be explained later on in more detail. Also, you may want to read my tutorial on CDEFs and Steve Rader's tutorial on \s-1RPN\s0. But first finish this tutorial. .PP -Hang on! If we can multiply values with 1'000, it should also be possible +Hang on! If we can multiply values with 1000, it should also be possible to display kilometers per hour from the same data! .PP To change a value that is measured in meters per second: .PP .Vb 3 -\& Calculate meters per hour: value * 3'600 -\& Calculate kilometers per hour: value / 1'000 -\& Together this makes: value * (3'600/1'000) or value * 3.6 +\& Calculate meters per hour: value * 3600 +\& Calculate kilometers per hour: value / 1000 +\& Together this makes: value * (3600/1000) or value * 3.6 .Ve .PP In our example database we made a mistake and we need to compensate for -this by multiplying with 1'000. Applying that correction: +this by multiplying with 1000. Applying that correction: .PP .Vb 1 -\& value * 3.6 * 1'000 == value * 3'600 +\& value * 3.6 * 1000 == value * 3600 .Ve .PP Now let's create this \s-1PNG\s0, and add some more magic ... @@ -574,7 +599,7 @@ Now let's create this \s-1PNG\s0, and add some more magic ... Note: here we use another means to escape the * operator by enclosing the whole string in double quotes. .PP -This graph looks much better. Speed is shown in \s-1KM/H\s0 and there is even +This graph looks much better. Speed is shown in km/h and there is even an extra line with the maximum allowed speed (on the road I travel on). I also changed the colors used to display speed and changed it from a line into an area. @@ -593,18 +618,19 @@ For values above the speed limit: \& Check if kmh is greater than 100 ( kmh,100 ) GT \& If so, return kmh, else return 0 ((( kmh,100) GT ), kmh, 0) IF .Ve -.Sh "Graphics Magic" +.SS "Graphics Magic" .IX Subsection "Graphics Magic" I like to believe there are virtually no limits to how RRDtool graph can manipulate data. I will not explain how it works, but look at the following \s-1PNG:\s0 .PP -.Vb 12 +.Vb 10 \& rrdtool graph speed4.png \e \& \-\-start 920804400 \-\-end 920808000 \e \& \-\-vertical\-label km/h \e \& DEF:myspeed=test.rrd:speed:AVERAGE \e -\& "CDEF:kmh=myspeed,3600,*" \e +\& CDEF:nonans=myspeed,UN,0,myspeed,IF \e +\& CDEF:kmh=nonans,3600,* \e \& CDEF:fast=kmh,100,GT,100,0,IF \e \& CDEF:over=kmh,100,GT,kmh,100,\-,0,IF \e \& CDEF:good=kmh,100,GT,0,kmh,IF \e @@ -614,6 +640,10 @@ following \s-1PNG:\s0 \& STACK:over#FF0000:"Over speed" .Ve .PP +Remember the note in the beginning? I had to remove unknown data from +this example. The 'nonans' \s-1CDEF\s0 is new, and the 6th line (which used to +be the 5th line) used to read 'CDEF:kmh=myspeed,3600,*' +.PP Let's create a quick and dirty \s-1HTML\s0 page to view the three PNGs: .PP .Vb 7 @@ -633,7 +663,7 @@ database. When you want to view the data, recreate the PNGs and make sure to refresh them in your browser. (Note: just clicking reload may not be enough, especially when proxies are involved. Try shift-reload or ctrl\-F5). -.Sh "Updates in Reality" +.SS "Updates in Reality" .IX Subsection "Updates in Reality" We've already used the \f(CW\*(C`update\*(C'\fR command: it took one or more parameters in the form of \*(L"