Initial revision
[rrdtool.git] / doc / rrdfetch.pod
1 =head1 NAME
2
3 rrdtool fetch - fetch data from an rrd.
4
5 =for html <div align="right"><a href="rrdfetch.pdf">PDF</a> version.</div>
6
7 =head1 SYNOPSIS
8
9 B<rrdtool> B<fetch> I<filename> I<CF> 
10 S<[B<--resolution>|B<-r> I<resolution>]> 
11 S<[B<--start>|B<-s> I<start>]> 
12 S<[B<--end>|B<-e> I<end>]> 
13
14 =head1 DESCRIPTION
15
16 The B<fetch> function is normally used internally by the graph function,
17 to get data from B<RRD>s. B<fetch> will analyze the B<RRD> and
18 will try to retrieve the data in the resolution requested.
19 The data fetched is printed to stdout. I<*UNKNOWN*> data is often
20 represented by the string "NaN" depending on your OSs printf
21 function.
22
23 =over 8
24
25 =item I<filename> 
26
27 the name of the B<RRD> you want to fetch the data from.
28
29 =item I<CF> 
30
31 which consolidation function should have been applied to the data you
32 want to fetch? (AVERAGE,MIN,MAX,LAST)
33
34 =item B<--resolution>|B<-r> I<resolution> (default is the highest resolution)
35
36 what interval should the values have (seconds per value). B<rrdfetch> will try
37 to match your request, but it will return data even if no absolute
38 match is possible.
39
40 =item B<--start>|B<-s> I<start> (default end-1day)
41
42 when should the data begin. A time in seconds since epoch (1970-01-01)
43 is required. Negative numbers are relative to the current time. By default
44 one day worth of data will be fetched. See also AT-STYLE TIME SPECIFICATION
45 section for a detailed explanation on  ways to specify start time.
46
47 =item B<--end>|B<-e> I<end> (default now)
48
49 when should the data end. Time in seconds since epoch. See also
50 AT-STYLE TIME SPECIFICATION section for a detailed explanation of how to specify
51 end time.
52
53 =back
54
55 =head2 AT-STYLE TIME SPECIFICATION
56
57 Apart from the traditional I<Seconds since epoch>, rrdtool does also
58 understand at-style time specification.  The specification is called
59 "at-style" after Unix command at(1) that has moderately complex ways
60 to specify time to run your job at.  The at-style specification
61 consists of two parts: B<TIME REFERENCE> specification and B<TIME
62 OFFSET> specification.
63
64 =head2 TIME REFERENCE SPECIFICATION
65
66 Time reference specification is used, well,... to establish a reference
67 moment in time (for time offset to be applied to). When present,
68 it should come first, when omitted, it defaults to B<now>. On its own part,
69 time reference consists of I<time-of-day> reference (which should come
70 first, if present) and I<day> reference.
71
72 I<Time-of-day> can be specified as B<HH:MM>, B<HH.MM>,
73 or just B<HH>, you can suffix it with B<am> or B<pm> or use
74 24-hours clock. The few special times of day are understood as well,
75 these include B<midnight> (00:00), B<noon> (12:00) and British
76 B<teatime> (16:00).
77
78 The I<day> can be specified as I<month-name> I<day-of-the-month>
79 and optional 2- or 4-digit I<year> number (e.g. March 8 1999).
80 Alternatively, you can use I<day-of-week-name> (e.g. Monday),
81 or one of the words: B<yesterday>, B<today>, B<tomorrow>.
82 You can also specify I<day> as a full date in several numerical formats;
83 these include: B<MM/DD/[YY]YY>, B<DD.MM.[YY]YY>, B<YYYYMMDD>.
84
85 I<NOTE1>: this is different from the original at(1) behavior,
86 which interprets a single-number date as MMDD[YY]YY.
87
88 I<NOTE2>: if you specify I<day> this way, the I<time-of-day> is REQUIRED
89 to be present.
90
91 Finally, you can use words B<now>, B<start>, or B<end> as your time
92 reference. B<Now> refers to the current moment (and is also a default
93 time reference). B<Start> (B<end>) can be used to specify time
94 relative to the start (end) time for those tools that use these
95 categories (rrdfetch, rrdgraph).
96
97 Month and weekday names can be used in their naturally abbreviated form
98 (e.g., Dec for December, Sun for Sunday, etc.). The words B<now>,
99 B<start>, B<end> can be abbreviated to B<n>, B<s>, B<e>.
100
101 =head2 TIME OFFSET SPECIFICATION
102
103 Time offset specification is used to add (or subtract) certain time
104 interval to (from) the time reference moment. It consists of I<sign>
105 (S<B<+> or B<->>) and I<amount>. The following time units can be used
106 to specify the I<amount>: B<years>, B<months>, B<weeks>, B<days>,
107 B<hours>, B<minutes>, B<seconds>, these can be used in singular
108 or plural form, and abbreviated naturally or to a single letter
109 (e.g. +3days, -1wk, -3y). Several time units can be combined
110 together (e.g., -5mon1w2d), as well as several time offsets can be
111 concatenated (e.g., -5h45min = -5h-45min = -6h+15min = -7h+1h30m-15min, etc.)
112
113 I<NOTE3>: If you specify time offset in days, weeks, months, or years,
114 you will end with the time offset that may vary depending on you time
115 reference, because all those time units have no single well defined
116 time interval value (S<1 year> contains either 365 or 366 days, S<1 month>
117 is 28 to 31 days long, and even S<1 day> may be not equal to 24 hours
118 twice a year, when DST-related clock adjustments take place).
119 To cope with this, when you use days, weeks, months, or years
120 as your time offset units your time reference date is adjusted
121 accordingly without taking too much further effort to ensure anything
122 about it (in the hope that mktime(3) will take care of this later).
123 This may lead to some surprising (or even invalid!) results,
124 e.g. S<'May 31 -1month'> = S<'Apr 31'> (meaningless) = S<'May 1'>
125 (after mktime(3) normalization); in the EET timezone
126 '3:30am Mar 29 1999 -1 day' yields '3:30am Mar 28 1999' (Sunday)
127 which is invalid time/date combination (because of 3am -> 4am DST
128 forward clock adjustment, see the below example).
129 On the other hand, hours, minutes, and seconds are well defined time
130 intervals, and these are guaranteed to always produce time offsets
131 exactly as specified (e.g. for EET timezone, S<'8:00 Mar 27 1999 +2 days'> =
132 S<'8:00 Mar 29 1999'>, but since there is 1-hour DST forward clock adjustment
133 takes place around S<3:00 Mar 28 1999>, the actual time interval between
134 S<8:00 Mar 27 1999> and S<8:00 Mar 29 1999> equals 47 hours; on the other hand,
135 S<'8:00 Mar 27 1999 +48 hours'> = S<'9:00 Mar 29 1999'>, as expected)
136
137 I<NOTE4>: The single-letter abbreviation for both B<months> and B<minutes>
138 is B<m>. To disambiguate, the parser tries to read your S<mind :)>
139 by applying the following two heuristics:
140
141 =over 3
142
143 =item 1
144
145 If B<m> is used in context of (i.e. right after the) years,
146 months, weeks, or days it is assumed to mean B<months>, while
147 in the context of hours, minutes, and seconds it means minutes.
148 (e.g., in -1y6m or +3w1m B<m> means B<months>, while in
149 -3h20m or +5s2m B<m> means B<minutes>)
150
151 =item 2
152
153 Out of context (i.e. right after the B<+> or B<-> sign) the
154 meaning of B<m> is guessed from the number it directly follows.
155 Currently, if the number absolute value is below 25 it is assumed
156 that B<m> means B<months>, otherwise it is treated as B<minutes>.
157 (e.g., -25m == -25 minutes, while +24m == +24 months)
158
159 =back
160
161 I<Final NOTES>: Time specification is case-insensitive.
162 Whitespace can be inserted freely or omitted altogether,
163 there are, however, cases when whitespace is required
164 (e.g., S<'midnight Thu'>). In this case you should either quote the
165 whole phrase to prevent it from being taken apart by your shell or use
166 '_' (underscore) or ',' (comma) which also count as whitespace
167 (e.g., midnight_Thu or midnight,Thu)
168
169
170 =head2 TIME SPECIFICATION EXAMPLES
171
172 I<Oct 12> -- October 12 this year
173
174 I<-1month> or I<-1m> -- current time of day, only a month before
175 (may yield surprises, see the NOTE3 above)
176
177 I<noon yesterday -3hours> -- yesterday morning; can be put also as I<9am-1day>
178
179 I<23:59 31.12.1999> -- 1 minute to the year 2000
180
181 I<12/31/99 11:59pm> -- 1 minute to the year 2000 for imperialists
182
183 I<12am 01/01/01> -- start of the new millennium
184
185 I<end-3weeks> or I<e-3w> -- 3 weeks before end time
186 (may be used as start time specification)
187
188 I<start+6hours> or I<s+6h> -- 6 hours after start time
189 (may be used as end time specification)
190
191 I<931225537> -- 18:45  July 5th, 1999
192 (yes, seconds since 1970 are valid as well)
193
194 I<19970703 12:45> -- 12:45  July 3th, 1997
195 (not quote standard, but I love this ...)
196
197
198 =head1 AUTHOR
199
200 Tobias Oetiker <oetiker@ee.ethz.ch>
201