Code

96e21af5dae018dc863372c9aa37310142e6ec33
[pkg-rrdtool.git] / doc / rrdfetch.1
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "RRDFETCH 1"
132 .TH RRDFETCH 1 "2008-09-25" "1.3.99909060808" "rrdtool"
133 .SH "NAME"
134 rrdfetch \- Fetch data from an RRD.
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 \&\fBrrdtool\fR \fBfetch\fR \fIfilename\fR \fI\s-1CF\s0\fR
138 [\fB\-\-resolution\fR|\fB\-r\fR\ \fIresolution\fR]
139 [\fB\-\-start\fR|\fB\-s\fR\ \fIstart\fR]
140 [\fB\-\-end\fR|\fB\-e\fR\ \fIend\fR]
141 [\fB\-\-daemon\fR\ \fIaddress\fR]
142 .SH "DESCRIPTION"
143 .IX Header "DESCRIPTION"
144 The \fBfetch\fR function is normally used internally by the graph
145 function to get data from \fB\s-1RRD\s0\fRs. \fBfetch\fR will analyze the \fB\s-1RRD\s0\fR
146 and try to retrieve the data in the resolution requested.
147 The data fetched is printed to stdout. \fI*UNKNOWN*\fR data is often
148 represented by the string \*(L"NaN\*(R" depending on your \s-1OS\s0's printf
149 function.
150 .IP "\fIfilename\fR" 8
151 .IX Item "filename"
152 the name of the \fB\s-1RRD\s0\fR you want to fetch the data from.
153 .IP "\fI\s-1CF\s0\fR" 8
154 .IX Item "CF"
155 the consolidation function that is applied to the data you
156 want to fetch (\s-1AVERAGE\s0,MIN,MAX,LAST)
157 .IP "\fB\-\-resolution\fR|\fB\-r\fR \fIresolution\fR (default is the highest resolution)" 8
158 .IX Item "--resolution|-r resolution (default is the highest resolution)"
159 the interval you want the values to have (seconds per
160 value). \fBrrdfetch\fR will try to match your request, but it will return
161 data even if no absolute match is possible. \fB\s-1NB\s0.\fR See note below.
162 .IP "\fB\-\-start\fR|\fB\-s\fR \fIstart\fR (default end\-1day)" 8
163 .IX Item "--start|-s start (default end-1day)"
164 start of the time series. A time in seconds since epoch (1970\-01\-01)
165 is required. Negative numbers are relative to the current time. By default,
166 one day worth of data will be fetched. See also AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0
167 section for a detailed explanation on  ways to specify the start time.
168 .IP "\fB\-\-end\fR|\fB\-e\fR \fIend\fR (default now)" 8
169 .IX Item "--end|-e end (default now)"
170 the end of the time series in seconds since epoch. See also AT-STYLE
171 \&\s-1TIME\s0 \s-1SPECIFICATION\s0 section for a detailed explanation of how to
172 specify the end time.
173 .IP "\fB\-\-daemon\fR \fIaddress\fR" 8
174 .IX Item "--daemon address"
175 Address of the rrdcached daemon. If specified, a \f(CW\*(C`flush\*(C'\fR command is sent
176 to the server before reading the \s-1RRD\s0 files. This allows \fBrrdtool\fR to return
177 fresh data even if the daemon is configured to cache values for a long time.
178 For a list of accepted formats, see the \fB\-l\fR option in the rrdcached manual.
179 .Sp
180 .Vb 1
181 \& rrdtool fetch \-\-daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE
182 .Ve
183 .Sh "\s-1RESOLUTION\s0 \s-1INTERVAL\s0"
184 .IX Subsection "RESOLUTION INTERVAL"
185 In order to get RRDtool to fetch anything other than the finest resolution \s-1RRA\s0
186 \&\fBboth\fR the start and end time must be specified on boundaries that are
187 multiples of the desired resolution. Consider the following example:
188 .PP
189 .Vb 7
190 \& rrdtool create subdata.rrd \-s 10 DS:ds0:GAUGE:300:0:U \e
191 \&  RRA:AVERAGE:0.5:30:3600 \e
192 \&  RRA:AVERAGE:0.5:90:1200 \e
193 \&  RRA:AVERAGE:0.5:360:1200 \e
194 \&  RRA:MAX:0.5:360:1200 \e
195 \&  RRA:AVERAGE:0.5:8640:600 \e
196 \&  RRA:MAX:0.5:8640:600
197 .Ve
198 .PP
199 This \s-1RRD\s0 collects data every 10 seconds and stores its averages over 5
200 minutes, 15 minutes, 1 hour, and 1 day, as well as the maxima for 1 hour
201 and 1 day.
202 .PP
203 Consider now that you want to fetch the 15 minute average data for the
204 last hour.  You might try
205 .PP
206 .Vb 1
207 \& rrdtool fetch subdata.rrd AVERAGE \-r 900 \-s \-1h
208 .Ve
209 .PP
210 However, this will almost always result in a time series that is
211 \&\fB\s-1NOT\s0\fR in the 15 minute \s-1RRA\s0. Therefore, the highest resolution \s-1RRA\s0,
212 i.e. 5 minute averages, will be chosen which in this case is not
213 what you want.
214 .PP
215 Hence, make sure that
216 .IP "1." 3
217 both start and end time are a multiple of 900
218 .IP "2." 3
219 both start and end time are within the desired \s-1RRA\s0
220 .PP
221 So, if time now is called \*(L"t\*(R", do
222 .PP
223 .Vb 3
224 \& end time == int(t/900)*900,
225 \& start time == end time \- 1hour,
226 \& resolution == 900.
227 .Ve
228 .PP
229 Using the bash shell, this could look be:
230 .PP
231 .Vb 4
232 \& TIME=$(date +%s)
233 \& RRDRES=900
234 \& rrdtool fetch subdata.rrd AVERAGE \-r $RRDRES \e
235 \&    \-e $(($TIME/$RRDRES*$RRDRES)) \-s e\-1h
236 .Ve
237 .PP
238 Or in Perl:
239 .PP
240 .Vb 3
241 \& perl \-e '$ctime = time; $rrdres = 900; \e
242 \&          system "rrdtool fetch subdata.rrd AVERAGE \e
243 \&                  \-r $rrdres \-e @{[int($ctime/$rrdres)*$rrdres]} \-s e\-1h"'
244 .Ve
245 .Sh "AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0"
246 .IX Subsection "AT-STYLE TIME SPECIFICATION"
247 Apart from the traditional \fISeconds since epoch\fR, RRDtool does also
248 understand at-style time specification. The specification is called
249 \&\*(L"at\-style\*(R" after the Unix command \fIat\fR\|(1) that has moderately complex
250 ways to specify time to run your job at a certain date and time. The
251 at-style specification consists of two parts: the \fB\s-1TIME\s0 \s-1REFERENCE\s0\fR
252 specification and the \fB\s-1TIME\s0 \s-1OFFSET\s0\fR specification.
253 .Sh "\s-1TIME\s0 \s-1REFERENCE\s0 \s-1SPECIFICATION\s0"
254 .IX Subsection "TIME REFERENCE SPECIFICATION"
255 The time reference specification is used, well, to establish a reference
256 moment in time (to which the time offset is then applied to). When present,
257 it should come first, when omitted, it defaults to \fBnow\fR. On its own part,
258 time reference consists of a \fItime-of-day\fR reference (which should come
259 first, if present) and a \fIday\fR reference.
260 .PP
261 The \fItime-of-day\fR can be specified as \fB\s-1HH:MM\s0\fR, \fB\s-1HH\s0.MM\fR,
262 or just \fB\s-1HH\s0\fR. You can suffix it with \fBam\fR or \fBpm\fR or use
263 24\-hours clock. Some special times of day are understood as well,
264 including \fBmidnight\fR (00:00), \fBnoon\fR (12:00) and British
265 \&\fBteatime\fR (16:00).
266 .PP
267 The \fIday\fR can be specified as \fImonth-name\fR \fIday-of-the-month\fR and
268 optional a 2\- or 4\-digit \fIyear\fR number (e.g. March 8 1999). Alternatively,
269 you can use \fIday-of-week-name\fR (e.g. Monday), or one of the words:
270 \&\fByesterday\fR, \fBtoday\fR, \fBtomorrow\fR. You can also specify the \fIday\fR as a
271 full date in several numerical formats, including \fBMM/DD/[\s-1YY\s0]YY\fR,
272 \&\fB\s-1DD\s0.MM.[\s-1YY\s0]YY\fR, or \fB\s-1YYYYMMDD\s0\fR.
273 .PP
274 \&\fI\s-1NOTE1\s0\fR: this is different from the original \fIat\fR\|(1) behavior, where a
275 single-number date is interpreted as MMDD[\s-1YY\s0]YY.
276 .PP
277 \&\fI\s-1NOTE2\s0\fR: if you specify the \fIday\fR in this way, the \fItime-of-day\fR is
278 \&\s-1REQUIRED\s0 as well.
279 .PP
280 Finally, you can use the words \fBnow\fR, \fBstart\fR, or \fBend\fR as your time
281 reference. \fBNow\fR refers to the current moment (and is also the default
282 time reference). \fBStart\fR (\fBend\fR) can be used to specify a time
283 relative to the start (end) time for those tools that use these
284 categories (\fBrrdfetch\fR, rrdgraph).
285 .PP
286 Month and day of the week names can be used in their naturally
287 abbreviated form (e.g., Dec for December, Sun for Sunday, etc.). The
288 words \fBnow\fR, \fBstart\fR, \fBend\fR can be abbreviated as \fBn\fR, \fBs\fR, \fBe\fR.
289 .Sh "\s-1TIME\s0 \s-1OFFSET\s0 \s-1SPECIFICATION\s0"
290 .IX Subsection "TIME OFFSET SPECIFICATION"
291 The time offset specification is used to add/subtract certain time
292 intervals to/from the time reference moment. It consists of a \fIsign\fR
293 (\fB+\fR\ or\ \fB\-\fR) and an \fIamount\fR. The following time units can be
294 used to specify the \fIamount\fR: \fByears\fR, \fBmonths\fR, \fBweeks\fR, \fBdays\fR,
295 \&\fBhours\fR, \fBminutes\fR, or \fBseconds\fR. These units can be used in
296 singular or plural form, and abbreviated naturally or to a single
297 letter (e.g. +3days, \-1wk, \-3y). Several time units can be combined
298 (e.g., \-5mon1w2d) or concatenated (e.g., \-5h45min = \-5h\-45min =
299 \&\-6h+15min = \-7h+1h30m\-15min, etc.)
300 .PP
301 \&\fI\s-1NOTE3\s0\fR: If you specify time offset in days, weeks, months, or years,
302 you will end with the time offset that may vary depending on your time
303 reference, because all those time units have no single well defined
304 time interval value (1\ year contains either 365 or 366 days, 1\ month
305 is 28 to 31 days long, and even 1\ day may be not equal to 24 hours
306 twice a year, when DST-related clock adjustments take place).
307 To cope with this, when you use days, weeks, months, or years
308 as your time offset units your time reference date is adjusted
309 accordingly without too much further effort to ensure anything
310 about it (in the hope that \fImktime\fR\|(3) will take care of this later).
311 This may lead to some surprising (or even invalid!) results,
312 e.g. 'May\ 31\ \-1month' = 'Apr\ 31' (meaningless) = 'May\ 1'
313 (after \fImktime\fR\|(3) normalization); in the \s-1EET\s0 timezone
314 \&'3:30am Mar 29 1999 \-1 day' yields '3:30am Mar 28 1999' (Sunday)
315 which is an invalid time/date combination (because of 3am \-> 4am \s-1DST\s0
316 forward clock adjustment, see the below example).
317 .PP
318 In contrast, hours, minutes, and seconds are well defined time
319 intervals, and these are guaranteed to always produce time offsets
320 exactly as specified (e.g. for \s-1EET\s0 timezone, '8:00\ Mar\ 27\ 1999\ +2\ days' = '8:00\ Mar\ 29\ 1999', but since there is 1\-hour \s-1DST\s0 forward
321 clock adjustment that occurs around 3:00\ Mar\ 28\ 1999, the actual
322 time interval between 8:00\ Mar\ 27\ 1999 and 8:00\ Mar\ 29\ 1999
323 equals 47 hours; on the other hand, '8:00\ Mar\ 27\ 1999\ +48\ hours' =
324 \&'9:00\ Mar\ 29\ 1999', as expected)
325 .PP
326 \&\fI\s-1NOTE4\s0\fR: The single-letter abbreviation for both \fBmonths\fR and \fBminutes\fR
327 is \fBm\fR. To disambiguate them, the parser tries to read your mind\ :)
328 by applying the following two heuristics:
329 .IP "1" 3
330 .IX Item "1"
331 If \fBm\fR is used in context of (i.e. right after the) years,
332 months, weeks, or days it is assumed to mean \fBmonths\fR, while
333 in the context of hours, minutes, and seconds it means minutes.
334 (e.g., in \-1y6m or +3w1m \fBm\fR is interpreted as \fBmonths\fR, while in
335 \&\-3h20m or +5s2m \fBm\fR the parser decides for \fBminutes\fR).
336 .IP "2" 3
337 .IX Item "2"
338 Out of context (i.e. right after the \fB+\fR or \fB\-\fR sign) the
339 meaning of \fBm\fR is guessed from the number it directly follows.
340 Currently, if the number's absolute value is below 25 it is assumed
341 that \fBm\fR means \fBmonths\fR, otherwise it is treated as \fBminutes\fR.
342 (e.g., \-25m == \-25 minutes, while +24m == +24 months)
343 .PP
344 \&\fIFinal \s-1NOTES\s0\fR: Time specification is case\-insensitive.
345 Whitespace can be inserted freely or omitted altogether.
346 There are, however, cases when whitespace is required
347 (e.g., 'midnight\ Thu'). In this case you should either quote the
348 whole phrase to prevent it from being taken apart by your shell or use
349 \&'_' (underscore) or ',' (comma) which also count as whitespace
350 (e.g., midnight_Thu or midnight,Thu).
351 .Sh "\s-1TIME\s0 \s-1SPECIFICATION\s0 \s-1EXAMPLES\s0"
352 .IX Subsection "TIME SPECIFICATION EXAMPLES"
353 \&\fIOct 12\fR \*(-- October 12 this year
354 .PP
355 \&\fI\-1month\fR or \fI\-1m\fR \*(-- current time of day, only a month before
356 (may yield surprises, see \s-1NOTE3\s0 above).
357 .PP
358 \&\fInoon yesterday \-3hours\fR \*(-- yesterday morning; can also be specified
359 as \fI9am\-1day\fR.
360 .PP
361 \&\fI23:59 31.12.1999\fR \*(-- 1 minute to the year 2000.
362 .PP
363 \&\fI12/31/99 11:59pm\fR \*(-- 1 minute to the year 2000 for imperialists.
364 .PP
365 \&\fI12am 01/01/01\fR \*(-- start of the new millennium
366 .PP
367 \&\fIend\-3weeks\fR or \fIe\-3w\fR \*(-- 3 weeks before end time
368 (may be used as start time specification).
369 .PP
370 \&\fIstart+6hours\fR or \fIs+6h\fR \*(-- 6 hours after start time
371 (may be used as end time specification).
372 .PP
373 \&\fI931225537\fR \*(-- 18:45  July 5th, 1999
374 (yes, seconds since 1970 are valid as well).
375 .PP
376 \&\fI19970703 12:45\fR \*(-- 12:45  July 3th, 1997
377 (my favorite, and its even got an \s-1ISO\s0 number (8601)).
378 .SH "ENVIRONMENT VARIABLES"
379 .IX Header "ENVIRONMENT VARIABLES"
380 The following environment variables may be used to change the behavior of
381 \&\f(CW\*(C`rrdtool\ fetch\*(C'\fR:
382 .IP "\fB\s-1RRDCACHED_ADDRESS\s0\fR" 4
383 .IX Item "RRDCACHED_ADDRESS"
384 If this environment variable is set it will have the same effect as specifying
385 the \f(CW\*(C`\-\-daemon\*(C'\fR option on the command line. If both are present, the command
386 line argument takes precedence.
387 .SH "AUTHOR"
388 .IX Header "AUTHOR"
389 Tobias Oetiker <tobi@oetiker.ch>