1 \mode<presentation>
2 {
3 \usetheme{default} % no fancy navigation or anything ...
4 \usecolortheme{tobi}
5 \usefonttheme{serif}
6 \usepackage{lmodern}
7 \newcommand{\addgraph}[1]{\includegraphics[width=\textwidth]{ex/#1}}
8 }
9 \mode<article>
10 {
11 %\usepackage[colorlinks,hyperindex,plainpages=false]{hyperref}
12 \usepackage{url}
13 \usepackage{graphicx}
14 \setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
15 \setlength{\parindent}{0pt}
16 \usepackage{times}
17 \newcommand{\addgraph}[1]{\begin{center}\framebox{\includegraphics[width=0.7\textwidth]{ex/#1}}\end{center}}
18 }
19 \usepackage{alltt}
20 \usepackage{listings}
21 \usepackage{svgcolor}
22 \usepackage[english]{babel}
23 % or whatever
24 \mode<article>{
25 }
27 \usepackage[latin1]{inputenc}
28 % or whatever
30 \usepackage[T1]{fontenc}
31 % Or whatever. Note that the encoding and the font should match. If T1
32 % does not look nice, try deleting the line with the fontenc.
34 \title
35 {RRDtool by Example}
37 \author
38 {Tobias Oetiker}
40 \institute
41 {OETIKER+PARTNER AG}
43 \date[LISA 2008] % (optional, should be abbreviation of conference name)
44 {21. Large Installation System Administration Conference}
46 \mode<presentation>{\subject{RRDtool tutorial based on example use}}
48 \mode<presentation>{
49 \lstset{%
50 language=Perl,%
51 numbers=left,%
52 basicstyle=\ttfamily\footnotesize\color{black},%
53 keywordstyle=\color{darkgreen},%
54 % identifyerstyle=\color{brown},%
55 commentstyle=\color{mediumpurple},%
56 stringstyle=\color{dimgray},
57 numberstyle=\ttfamily\scriptsize\color{darkgray},
58 showstringspaces=false
59 }
60 }
61 \mode<article>{
62 \lstset{%
63 language=Perl,%
64 numbers=left,%
65 basicstyle=\ttfamily\footnotesize,%
66 keywordstyle=\bfseries,%
67 numberstyle=\ttfamily\scriptsize,
68 % identifyerstyle=\color{brown},%
69 commentstyle=\itshape,%
70 stringstyle=\color{black},
71 showstringspaces=false
72 }
73 }
75 \begin{document}
77 \mode<article>{\maketitle}
79 \begin{frame}<presentation>
80 \titlepage
81 \end{frame}
83 \mode<articel>{\tableofcontents}
85 \section{A different kind of Database}
87 \begin{frame}{creating a simple rrd}
88 \lstinputlisting[language=bash,firstline=0,lastline=11]{ex/create-first.sh}
89 One Datasource, 4 Round Robin Archives
90 \end{frame}
92 \begin{frame}{feeding data}
93 \lstinputlisting[language=bash,firstline=13,lastline=21]{ex/create-first.sh}
94 Feed in some data. One or several updates at once.
95 \end{frame}
97 \begin{frame}[allowframebreaks]{inside the database}
98 \lstinputlisting[language=xml,basicstyle=\ttfamily\scriptsize]{ex/create-first.xml}
99 \end{frame}
101 \mode<article>{
102 The xml dump of the rrd file shows an approximation of the on-disk
103 structure of the database. The rra database sections are re-ordered, so that
104 they are in chronological order with the oldest at the top. Also the
105 cdp sections are stored right after the header. Idea behind this
106 design is, that things that get written on every update are as close
107 together as possible.}
109 \begin{frame}{rrd features}
110 \begin{itemize}
111 \item optimized for time-series data
112 \item fixed size rotating data store
113 \item constant on-disk size
114 \item no maintenance
115 \item on the fly consolidation
116 \end{itemize}
117 \end{frame}
119 \begin{frame}[fragile]{on-disk structure}
120 \begin{alltt}
121 +-------------------------------+
122 | Static Header | \textrm{RRD Cookie, DB Cfg}
123 |-------------------------------|
124 : Data Source (DS) Definitions :
125 |-------------------------------|
126 : RR Archive (RRA) Definitions :
127 |===============================|
128 | Live Head | \textrm{Last Update Time}
129 |-------------------------------|
130 : PDP Prep per DS : \textrm{Last Value for Diff}
131 |-------------------------------|
132 : CDP Prep per RRA and DS : \textrm{Intermediate Storage}
133 |-------------------------------|
134 : RRA Pointers :
135 |===============================|
136 : Round Robin Archives (RRA) :
137 +-------------------------------+
138 \end{alltt}
139 \end{frame}
141 \begin{frame}{irregular data arrival intervals}
142 \lstinputlisting[language=bash,lastline=19]{ex/update-real.sh}
143 \end{frame}
145 \mode<article>{To try things out, lets assume that data arrives at
146 irregular intervals. This is counter data, by synchronizing the
147 data values with the arrival time we should get a constant rate
148 stored in the database.}
150 \begin{frame}{database after the irregular updates}
151 \lstinputlisting[language=bash,firstline=20]{ex/update-real.sh}
152 \lstinputlisting[language=bash]{ex/update-real.txt}
154 \begin{itemize}
155 \item rrdtool re-binning at work
156 \item major difference to a normal db
157 \item all bins contain 1.0
158 \item the time is the 'end-time' of the bin.
159 \end{itemize}
160 \end{frame}
162 \begin{frame}{optimizing your rrds}
163 \begin{itemize}
164 \item update of multi DS RRD is cheep
165 \item single update interval per RRD
166 \item RRD modification is expensive
167 \item RRD size and update performance are independent
168 \item RRA complexity affects update performance
169 \end{itemize}
170 \end{frame}
172 \mode<article>{As long as your system is small (a few hundred rrds)
173 you should optimize for convenience. Only keep these DSes together
174 in one RRD that are tightly bound together. For everything else
175 create separate rrds.}
177 \begin{frame}{fetching data}
178 fetch is for reading data from an rrd
179 \lstinputlisting[language=bash,firstline=8,lastline=9]{ex/catch-fetch.sh}
180 \begin{itemize}
181 \item one RRA with two 300s entries
182 \item one RRA with three 600s entries
183 \end{itemize}
184 \end{frame}
186 \begin{frame}[fragile]{playing catch with fetch}
187 first pull 300 seconds
188 \begin{verbatim}
189 > rrdtool fetch x.rrd -r 300 \
190 -s 1200000600 -e 1200000900 AVERAGE
192 1200000900: 4.0000000000e+01
193 1200001200: 5.0000000000e+01
194 \end{verbatim}
196 then pull 900 seconds
197 \begin{verbatim}
198 > rrdtool fetch x.rrd -r300 \
199 -s 1200000000 -e 1200000900 AVERAGE
201 1200000600: 2.5000000000e+01
202 1200001200: 4.5000000000e+01
203 \end{verbatim}
204 \end{frame}
206 \begin{frame}{fetch recap}
207 \begin{itemize}
208 \item looking for complete coverage
209 \item resolution is only a suggestion
210 \item time stamp in output marks the END of the period
211 \item end-time differences cause problem
212 \item since 1.3 only the start-time is relevant for coverage
213 \item outside the rra everything is nan
214 \end{itemize}
215 \end{frame}
217 \begin{frame}{the size of an rrd - code}
218 \lstinputlisting{ex/rrd-size.pl}
219 \end{frame}
221 \begin{frame}{the size of an rrd - result}
222 \lstinputlisting{ex/rrd-size.txt}
223 \begin{itemize}
224 \item overhead is minimal
225 \item 8 byte per double
226 \item \ldots per Datasource
227 \item \ldots per RRA
228 \item \ldots per RRA Row
229 \end{itemize}
230 \end{frame}
232 \mode<article>{The rrd format is highly efficient at storing non
233 sparse data. The overhead for an extra RRA or DS is normally a few
234 bytes on top of the 8 Byte per double.}
236 \section{Graphing}
237 \begin{frame}[fragile]{rrdgraph syntax 101}
238 for graph command syntax, there are two basic rules:\pause
239 \begin{enumerate}
240 \item \texttt{-{}-options} start with a double dash\pause
241 \item graphing instructions start with a letter
242 \end{enumerate}
244 \pause
245 \begin{center}
246 \renewcommand{\tabcolsep}{0.4cm}
247 \renewcommand{\arraystretch}{2}
249 \begin{tabular}{|l|}\hline
250 \begin{minipage}[t]{0.7\textwidth}
251 \begin{alltt}
252 rrdtool graph \textit{output}
253 DEF:var=\textit{rrd}:\textit{DS}:\textit{AVARAGE}
254 LINE:var#\textit{hex-rgb-color}:Comment
256 \end{alltt}
257 \end{minipage}\\\hline
258 \end{tabular}
259 \end{center}
261 \texttt{DEF} and \texttt{LINE} are \emph{graphing instructions}.
262 \end{frame}
264 \mode<article>{The rrd graph command is the most versatile of all rrdtool
265 commands. It comes with its own little language, optimized for
266 drawing graphs. There are two kinds of arguments. The options,
267 which start with a double-dash and the graphing instruction that
268 start with an uppercase letter.}
270 \begin{frame}{normal line}
271 \addgraph{LINE}
272 \end{frame}
274 \begin{frame}{lower limit}
275 \addgraph{LINE-lower}
276 \end{frame}
278 \mode<article>{Unless you are a baker and are drawing stock diagrams,
279 make sure your graph displays the zero-y-value. Otherwise it is
280 pretty difficult to judge the meaning of the graph since perspective
281 is limited to the numbers on the y-axis.}
283 \begin{frame}{slope mode}
284 \addgraph{LINE-slope}
285 \end{frame}
287 \mode<article>{RRD graphs are pretty blocky. This is on purpose, since
288 the data is blocky too. The slope mode is a little concession by
289 tilting the vertical connections between the 'block' by one pixel.}
291 \begin{frame}{anti-anti-aliasing: graph}
292 \addgraph{LINE-graph-mono}
293 \end{frame}
295 \begin{frame}{anti-anti-aliasing: font}
296 \addgraph{LINE-font-mono}
297 \end{frame}
299 \begin{frame}{line width}
300 \addgraph{LINE-width}
301 \end{frame}
303 \begin{frame}{dashed line}
304 \addgraph{LINE-dash}
305 \end{frame}
307 \mode<article>{The numbers are in ON-OFF-ON-OFF-\ldots pattern. The
308 \texttt{dash-offset} property lets you shift the dashing of the line
309 to the right.}
311 \begin{frame}{DEF with :step}
312 \addgraph{DEF-step}
313 \end{frame}
316 \begin{frame}{DEF with :start}
317 \addgraph{DEF-start}
318 \end{frame}
320 \begin{frame}{DEF with :reduce}
321 \addgraph{DEF-reduce}
322 \end{frame}
324 \begin{frame}{AREA simple}
325 \addgraph{AREA-simple}
326 \end{frame}
328 \begin{frame}{two AREAs}
329 \addgraph{AREA-two}
330 \end{frame}
332 \begin{frame}{transparent AREA}
333 \addgraph{AREA-trans}
334 \end{frame}
336 \mode<article>{RRDtool creates real alpha transparency, you can set
337 the whole graph to be transparent by setting the
338 graph CANVAS and BACKGROUND colors to transparent.}
340 \begin{frame}{stacked AREA}
341 \addgraph{AREA-stack}
342 \end{frame}
344 \begin{frame}{time shift}
345 \addgraph{SHIFT-simple}
346 \end{frame}
348 \begin{frame}{shifting with extra data}
349 \addgraph{SHIFT-startdef}
350 \end{frame}
352 \mode<article>{A normal \texttt{DEF} line requests exactly as much data as it
353 requires for drawing the graph. When you \texttt{SHIFT} the data, you
354 may want to adjust the data fetched accordingly.}
356 \section{Revers Polish Notation (RPN) Math}
358 \mode<article>{RRDtool lets you apply math operations to the data
359 prior to showing it to the user. It uses RPN math for this. If you
360 ever owned a classic HP calculator, you may still remember how RPN
361 math works. For all the others, there is a little example below,
362 that shows how todo a little addition in RPN.}
364 \begin{frame}[fragile]{RPN basics: Step 0}
365 $15+23=38$
366 \begin{alltt}
367 1: NAN
368 2: NAN
369 3: NAN
370 \end{alltt}
371 \end{frame}
372 \begin{frame}[fragile]{RPN basics: Step 1}
373 $\mathbf{15}+23=38$
374 \begin{alltt}
375 [15] 1: \textbf{15}
376 2: NAN
377 3: NAN
378 \end{alltt}
379 \end{frame}
380 \begin{frame}[fragile]{RPN basics: Step 2}
381 $15+\mathbf{23}=38$
382 \begin{alltt}
383 [23] 1: \textbf{23}
384 2: 15
385 3: NAN
386 \end{alltt}
387 \end{frame}
388 \begin{frame}[fragile]{RPN basics: Step 3}
389 $15\mathbf{+}23=38$
390 \begin{alltt}
391 [+] 1: \textbf{38}
392 2: NAN
393 3: NAN
394 \end{alltt}
395 \end{frame}
398 \begin{frame}{math in the graph (+)}
399 \addgraph{RPN-simple}
400 \end{frame}
402 \mode<article>{A simple addition. We add a fixed value to one a data
403 source. Note that at least one data source must appear inside a CDEF
404 expression. The input to a CDEF expression can come from another
405 CDEF expression.}
407 \begin{frame}{the MAX function}
408 \addgraph{RPN-max}
409 \end{frame}
411 \mode<article>{The MAX function operates on two value. In this example
412 the input comes from two different data sources.}
414 \begin{frame}{the LIMIT function}
415 \addgraph{RPN-limit}
416 \end{frame}
418 \mode<article>{The \texttt{LIMIT} function will return UNKNOWN as soon
419 as the input value is outside the given range. UNKNOWN data does not
420 get drawn.}
422 \begin{frame}{the TREND function}
423 \addgraph{RPN-trend}
424 \end{frame}
426 \mode<article>{If a data source varies massively, the TREND function
427 lets you smooth away by building a moving average. By calculating
428 the average the output gets shifted by the length of the TREND
429 calculation.}
431 \begin{frame}{the TREND with early start}
432 \addgraph{RPN-trend-start}
433 \end{frame}
435 \mode<article>{In the previous graph there was a bit of data missing
436 at the left border of the graph. This was because rrdgraph loads
437 exactly the amount of data that is required in the graph (yes same
438 story as before). By loading more data, we can provide the TREND
439 function with enough input, so that it can calculate the first few
440 pixel as well.}
442 \begin{frame}{the TREND and SHIFT}
443 \addgraph{RPN-trend-shift}
444 \end{frame}
446 \mode<article>{Another interesting option, is to SHIFT the result of
447 the TREND calculation back in time, so that it matches with the
448 source data, since this may allow us to see when there are
449 'outliners'}
451 \begin{frame}{the IF function}
452 \addgraph{RPN-if}
453 \end{frame}
455 \mode<article>{The IF function requires three items on the stack. It
456 turns \texttt{a,b,c,IF} into \texttt{if a then b else c}. There is a
457 bunch of operators that go along with the \texttt{IF}: \texttt{LT}
458 less, \texttt{LE} - less or equal, \texttt{EQ} - equal, \texttt{NE}
459 not equal, \texttt{GE} - greater or equal, \texttt{GT} - greater.}
461 \begin{frame}{about invisibility}
462 \addgraph{RPN-UNKN}
463 \end{frame}
465 \mode<article>{Unknown values can not be drawn. Here we use this to
466 just show a value if it is the largest one.}
468 \begin{frame}{positional drawing count}
469 \addgraph{RPN-count}
470 \end{frame}
472 \mode<article>{If you were into bar charts, you might fake them with
473 this trick. COUNT, counts the values of the data set. We use this,
474 together with the modulo operator to suppress drawing the every
475 third entry.}
477 \begin{frame}{access the previous value}
478 \addgraph{RPN-prev}
479 \end{frame}
481 \begin{frame}{positional drawing time}
482 \addgraph{RPN-time}
483 \end{frame}
485 \begin{frame}{positional drawing time-shifting}
486 \addgraph{RPN-time-minus}
487 \end{frame}
489 \mode<article>{There is also a function for accessing the Unix time
490 (seconds since 1970). With it you can make your stripes a fixed
491 number of seconds wide.}
493 \section{Consolidation functions}
495 \begin{frame}{calculating in the graph}
496 \addgraph{VDEF-average}
497 \end{frame}
499 \section{Holt-Winters Aberrant Behaviour Detection}
501 %\includegraphics[width=0.6\textwidth]{js/scoping-correct}
503 \mode<presentation>{
504 \begin{frame}
505 \begin{center}
506 % Code walk through of the SmokeTrace application.
507 \end{center}
508 \end{frame}
510 \begin{frame}
511 \begin{center}
512 \Huge ?
513 \end{center}
514 \end{frame}
515 \begin{frame}
516 \begin{center}
517 Tobi Oetiker <tobi@oetiker.ch>
518 \end{center}
519 \end{frame}
520 }
522 \mode<article>{
523 \vspace{3cm}
524 Tobias Oetiker <tobi@oetiker.ch>
525 }
526 \end{document}
527 %%% Local Variables:
528 %%% TeX-master: "presentation.tex"
529 %%% mode: flyspell
530 %%% TeX-PDF-mode: t
531 %%% End: