X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=doc%2Frrdtutorial.txt;h=f5237ace0b8a430c545ccb314ab6df85ae80e0bf;hb=645054bac6187b0e83fd4125fd59e4feda216b64;hp=29d5de337215e76e84d58c8e97042112d6a2f415;hpb=ffa00ac697dccce18dca8880ca7a14066521ac5c;p=pkg-rrdtool.git diff --git a/doc/rrdtutorial.txt b/doc/rrdtutorial.txt index 29d5de3..f5237ac 100644 --- a/doc/rrdtutorial.txt +++ b/doc/rrdtutorial.txt @@ -6,23 +6,22 @@ NNAAMMEE rrdtutorial - Alex van den Bogaerdt's RRDtool tutorial DDEESSCCRRIIPPTTIIOONN - RRDtool is written by Tobias Oetiker with contribu- - tions from many people all around the world. This document is written - by Alex van den Bogaerdt to help you under- - stand what RRDtool is and what it can do for you. + 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 + understand what RRDtool is and what it can do for you. The documentation provided with RRDtool can be too technical for some - people. This tutorial is here to help you understand the basics of RRD- - tool. It should prepare you to read the documentation yourself. It - also explains the general things about statistics with a focus on net- - working. + people. This tutorial is here to help you understand the basics of + RRDtool. It should prepare you to read the documentation yourself. It + also explains the general things about statistics with a focus on + networking. TTUUTTOORRIIAALL - IImmppoorrttaanntt - - Please don't skip ahead in this document! The first part of this docu- - ment explains the basics and may be boring. But if you don't under- - stand the basics, the examples will not be as meaningful to you. + IImmppoorrttaanntt + 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. Sometimes things change. This example used to provide numbers like "0.04" in stead of "4.00000e-02". Those are really the same numbers, @@ -43,68 +42,64 @@ TTUUTTOORRIIAALL result as a fix to the source of this document. Discuss it on the user's list, or write to me. - WWhhaatt iiss RRRRDDttooooll?? - - RRDtool refers to Round Robin Database tool. Round robin is a tech- - nique that works with a fixed amount of data, and a pointer to the cur- - rent element. Think of a circle with some dots plotted on the edge. + WWhhaatt iiss RRRRDDttooooll?? + 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. When - the current data is read or written, the pointer moves to the next ele- - ment. As we are on a circle there is neither a beginning nor an end, + 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 main- - tenance. RRDtool works with with Round Robin Databases (RRDs). It + 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 data from them. - WWhhaatt ddaattaa ccaann bbee ppuutt iinnttoo aann RRRRDD?? - + WWhhaatt ddaattaa ccaann bbee ppuutt iinnttoo aann RRRRDD?? 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 MRTG (the - next section will give more details on this more specialized applica- - tion). - - Many examples below talk about SNMP which is an acronym for Simple Net- - work Management Protocol. "Simple" 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 under- - stand what people are talking about. For now, just realize that SNMP - 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 RRD. - - WWhhaatt ccaann II ddoo wwiitthh tthhiiss ttooooll?? - + next section will give more details on this more specialized + application). + + Many examples below talk about SNMP which is an acronym for Simple + Network Management Protocol. "Simple" 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 + SNMP 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 RRD. + + WWhhaatt ccaann II ddoo wwiitthh tthhiiss ttooooll?? RRDtool originated from MRTG (Multi Router Traffic Grapher). MRTG started as a tiny little script for graphing the use of a university's connection to the Internet. MRTG was later (ab-)used as a tool for - graphing other data sources including temperature, speed, voltage, num- - ber of printouts and the like. + graphing other data sources including temperature, speed, voltage, + number of printouts and the like. Most likely you will start to use RRDtool to store and process data - collected via SNMP. The data will most likely be bytes (or bits) trans- - fered from and to a network or a computer. But it can also be used to - display tidal waves, solar radiation, power consumption, number of vis- - itors 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. - - You only need a sensor to measure the data and be able to feed the num- - bers into RRDtool. RRDtool then lets you create a database, store data - in it, retrieve that data and create graphs in PNG format for display - on a web browser. Those PNG images are dependent on the data you col- - lected and could be, for instance, an overview of the average network - usage, or the peaks that occurred. - - WWhhaatt iiff II ssttiillll hhaavvee pprroobblleemmss aafftteerr rreeaaddiinngg tthhiiss ddooccuummeenntt?? - + collected via SNMP. The data will most likely be bytes (or bits) + transfered 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. + + 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 + data in it, retrieve that data and create graphs in PNG format for + display on a web browser. Those PNG 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. + + WWhhaatt iiff II ssttiillll hhaavvee pprroobblleemmss aafftteerr rreeaaddiinngg tthhiiss ddooccuummeenntt?? 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 OS, it will - probably not be the fault of RRDtool. There may be pre-compiled ver- - sions around on the Internet. If they come from trusted sources, get + probably not be the fault of RRDtool. There may be pre-compiled + versions around on the Internet. If they come from trusted sources, get one of those. If on the other hand the program works but does not give you the @@ -112,19 +107,19 @@ TTUUTTOORRIIAALL configuration and compare it with the examples that follow. There is a mailing list and an archive of it. Read the list for a few - weeks and search the archive. It is considered rude to just ask a ques- - tion without searching the archives: your problem may already have been - solved for somebody else! This is true for most, if not all, mailing - lists and not only for this particular one. Look in the documentation - that came with RRDtool for the location and usage of the list. + weeks and search the archive. It is considered rude to just ask a + question without searching the archives: your problem may already have + been solved for somebody else! This is true for most, if not all, + mailing lists and not only for this particular one. Look in the + documentation that came with RRDtool for the location and usage of the + list. I suggest you take a moment to subscribe to the mailing list right now - by sending an email to with a sub- - ject of "subscribe". If you ever want to leave this list, just write an - email to the same address but now with a subject of "unsubscribe". - - HHooww wwiillll yyoouu hheellpp mmee?? + by sending an email to with a + subject of "subscribe". If you ever want to leave this list, just write + an email to the same address but now with a subject of "unsubscribe". + HHooww wwiillll yyoouu hheellpp mmee?? By giving you some detailed descriptions with detailed examples. I assume that following the instructions in the order presented will give you enough knowledge of RRDtool to experiment for yourself. If it @@ -137,8 +132,7 @@ TTUUTTOORRIIAALL You will need to know something about hexadecimal numbers. If you don't then start with reading bin_dec_hex before you continue here. - YYoouurr ffiirrsstt RRoouunndd RRoobbiinn DDaattaabbaassee - + YYoouurr ffiirrsstt RRoouunndd RRoobbiinn DDaattaabbaassee 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 in it and extract this data again. Your output should be the same as the @@ -150,26 +144,26 @@ TTUUTTOORRIIAALL 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 proba- - bly 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. + increasing with every byte that is transfered. 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. 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 SNMP world most of the counters are 32 bits. That means they are - counting from 0 to 4294967295. We will use these values in the exam- - ples. The device, when asked, returns the current value of the + 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 not very hard to calculate. First in words, then in calcula- - tions: + This is not very hard to calculate. First in words, then in + calculations: 1. Take the current counter, subtract the previous value from it. - 2. Do the same with the current time and the previous time (in sec- - onds). + 2. Do the same with the current time and the previous time (in + seconds). 3. Divide the outcome of (1) by the outcome of (2), the result is the amount of bytes per second. Multiply by eight to get the number of @@ -203,8 +197,8 @@ TTUUTTOORRIIAALL 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 exam- - ple at home or where I live :) + native English speaking friends: that's 90 mph so don't try this + example at home or where I live :) 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 @@ -219,8 +213,8 @@ TTUUTTOORRIIAALL OS to OS, but I assume you can figure it out if it works different on your's. Make sure you do not overwrite any file on your system when executing the following command and type the whole line as one long - line (I had to split it for readability) and skip all of the '\' char- - acters. + line (I had to split it for readability) and skip all of the '\' + characters. rrdtool create test.rrd \ --start 920804400 \ @@ -230,8 +224,7 @@ TTUUTTOORRIIAALL (So enter: "rrdtool create test.rrd --start 920804400 DS ...") - WWhhaatt hhaass bbeeeenn ccrreeaatteedd?? - + WWhhaatt hhaass bbeeeenn ccrreeaatteedd?? 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 920804400 seconds as explained below). Our @@ -326,8 +319,7 @@ TTUUTTOORRIIAALL The meaning of the above output will become clear below. - TTiimmee ttoo ccrreeaattee ssoommee ggrraapphhiiccss - + TTiimmee ttoo ccrreeaattee ssoommee ggrraapphhiiccss Try the following command: rrdtool graph speed.png \ @@ -348,11 +340,11 @@ TTUUTTOORRIIAALL If this has worked: congratulations! If not, check what went wrong. - The colors are built up from red, green and blue. For each of the com- - ponents, you specify how much to use in hexadecimal where 00 means not - included and FF means fully included. The "color" white is a mixture - of red, green and blue: FFFFFF The "color" black is all colors off: - 000000 + The colors are built up from red, green and blue. For each of the + components, you specify how much to use in hexadecimal where 00 means + not included and FF means fully included. The "color" white is a + mixture of red, green and blue: FFFFFF The "color" black is all colors + off: 000000 red #FF0000 green #00FF00 @@ -367,8 +359,7 @@ TTUUTTOORRIIAALL viewer. Web browsers will display the PNG via the URL "file:///the/path/to/speed.png" - GGrraapphhiiccss wwiitthh ssoommee mmaatthh - + GGrraapphhiiccss wwiitthh ssoommee mmaatthh 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 likely candidates) so they are skipped. @@ -384,10 +375,10 @@ TTUUTTOORRIIAALL If we had measured our distances in meters, this would have been (12357000-12345000)/300 = 12000/300 = 40. - As most people have a better feel for numbers in this range, we'll cor- - rect that. We could recreate our database and store the correct data, - but there is a better way: we do some calculations while creating the - png file! + 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 + data, but there is a better way: we do some calculations while creating + the png file! rrdtool graph speed2.png \ --start 920804400 --end 920808000 \ @@ -420,8 +411,8 @@ TTUUTTOORRIIAALL detail. Also, you may want to read my tutorial on CDEFs and Steve Rader's tutorial on RPN. But first finish this tutorial. - Hang on! If we can multiply values with 1000, it should also be possi- - ble to display kilometers per hour from the same data! + Hang on! If we can multiply values with 1000, it should also be + possible to display kilometers per hour from the same data! To change a value that is measured in meters per second: @@ -466,8 +457,7 @@ TTUUTTOORRIIAALL Check if kmh is greater than 100 ( kmh,100 ) GT If so, return kmh, else return 0 ((( kmh,100) GT ), kmh, 0) IF - GGrraapphhiiccss MMaaggiicc - + GGrraapphhiiccss MMaaggiicc 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 PNG: @@ -509,13 +499,12 @@ TTUUTTOORRIIAALL not be enough, especially when proxies are involved. Try shift-reload or ctrl-F5). - UUppddaatteess iinn RReeaalliittyy - + UUppddaatteess iinn RReeaalliittyy We've already used the "update" command: it took one or more parameters in the form of "