.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . 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 (.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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .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. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RRDFETCH 1" .TH RRDFETCH 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" rrdfetch \- Fetch data from an RRD. .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBrrdtool\fR \fBfetch\fR \fIfilename\fR \fI\s-1CF\s0\fR [\fB\-\-resolution\fR|\fB\-r\fR\ \fIresolution\fR] [\fB\-\-start\fR|\fB\-s\fR\ \fIstart\fR] [\fB\-\-end\fR|\fB\-e\fR\ \fIend\fR] [\fB\-\-daemon\fR\ \fIaddress\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBfetch\fR function is normally used internally by the graph function to get data from \fB\s-1RRD\s0\fRs. \fBfetch\fR will analyze the \fB\s-1RRD\s0\fR and try to retrieve the data in the resolution requested. The data fetched is printed to stdout. \fI*UNKNOWN*\fR data is often represented by the string \*(L"NaN\*(R" depending on your \s-1OS\s0's printf function. .IP "\fIfilename\fR" 8 .IX Item "filename" the name of the \fB\s-1RRD\s0\fR you want to fetch the data from. .IP "\fI\s-1CF\s0\fR" 8 .IX Item "CF" the consolidation function that is applied to the data you want to fetch (\s-1AVERAGE\s0,MIN,MAX,LAST) .IP "\fB\-\-resolution\fR|\fB\-r\fR \fIresolution\fR (default is the highest resolution)" 8 .IX Item "--resolution|-r resolution (default is the highest resolution)" the interval you want the values to have (seconds per value). \fBrrdfetch\fR will try to match your request, but it will return data even if no absolute match is possible. \fB\s-1NB\s0.\fR See note below. .IP "\fB\-\-start\fR|\fB\-s\fR \fIstart\fR (default end\-1day)" 8 .IX Item "--start|-s start (default end-1day)" start of the time series. A time in seconds since epoch (1970\-01\-01) is required. Negative numbers are relative to the current time. By default, one day worth of data will be fetched. See also AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0 section for a detailed explanation on ways to specify the start time. .IP "\fB\-\-end\fR|\fB\-e\fR \fIend\fR (default now)" 8 .IX Item "--end|-e end (default now)" the end of the time series in seconds since epoch. See also AT-STYLE \&\s-1TIME\s0 \s-1SPECIFICATION\s0 section for a detailed explanation of how to specify the end time. .IP "\fB\-\-daemon\fR \fIaddress\fR" 8 .IX Item "--daemon address" Address of the rrdcached daemon. If specified, a \f(CW\*(C`flush\*(C'\fR command is sent to the server before reading the \s-1RRD\s0 files. This allows \fBrrdtool\fR to return fresh data even if the daemon is configured to cache values for a long time. For a list of accepted formats, see the \fB\-l\fR option in the rrdcached manual. .Sp .Vb 1 \& rrdtool fetch \-\-daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE .Ve .SS "\s-1RESOLUTION\s0 \s-1INTERVAL\s0" .IX Subsection "RESOLUTION INTERVAL" In order to get RRDtool to fetch anything other than the finest resolution \s-1RRA\s0 \&\fBboth\fR the start and end time must be specified on boundaries that are multiples of the desired resolution. Consider the following example: .PP .Vb 7 \& rrdtool create subdata.rrd \-s 10 DS:ds0:GAUGE:300:0:U \e \& RRA:AVERAGE:0.5:30:3600 \e \& RRA:AVERAGE:0.5:90:1200 \e \& RRA:AVERAGE:0.5:360:1200 \e \& RRA:MAX:0.5:360:1200 \e \& RRA:AVERAGE:0.5:8640:600 \e \& RRA:MAX:0.5:8640:600 .Ve .PP This \s-1RRD\s0 collects data every 10 seconds and stores its averages over 5 minutes, 15 minutes, 1 hour, and 1 day, as well as the maxima for 1 hour and 1 day. .PP Consider now that you want to fetch the 15 minute average data for the last hour. You might try .PP .Vb 1 \& rrdtool fetch subdata.rrd AVERAGE \-r 900 \-s \-1h .Ve .PP However, this will almost always result in a time series that is \&\fB\s-1NOT\s0\fR in the 15 minute \s-1RRA\s0. Therefore, the highest resolution \s-1RRA\s0, i.e. 5 minute averages, will be chosen which in this case is not what you want. .PP Hence, make sure that .IP "1." 3 both start and end time are a multiple of 900 .IP "2." 3 both start and end time are within the desired \s-1RRA\s0 .PP So, if time now is called \*(L"t\*(R", do .PP .Vb 3 \& end time == int(t/900)*900, \& start time == end time \- 1hour, \& resolution == 900. .Ve .PP Using the bash shell, this could look be: .PP .Vb 4 \& TIME=$(date +%s) \& RRDRES=900 \& rrdtool fetch subdata.rrd AVERAGE \-r $RRDRES \e \& \-e $(($TIME/$RRDRES*$RRDRES)) \-s e\-1h .Ve .PP Or in Perl: .PP .Vb 3 \& perl \-e \*(Aq$ctime = time; $rrdres = 900; \e \& system "rrdtool fetch subdata.rrd AVERAGE \e \& \-r $rrdres \-e @{[int($ctime/$rrdres)*$rrdres]} \-s e\-1h"\*(Aq .Ve .SS "AT-STYLE \s-1TIME\s0 \s-1SPECIFICATION\s0" .IX Subsection "AT-STYLE TIME SPECIFICATION" Apart from the traditional \fISeconds since epoch\fR, RRDtool does also understand at-style time specification. The specification is called \&\*(L"at-style\*(R" after the Unix command \fIat\fR\|(1) that has moderately complex ways to specify time to run your job at a certain date and time. The at-style specification consists of two parts: the \fB\s-1TIME\s0 \s-1REFERENCE\s0\fR specification and the \fB\s-1TIME\s0 \s-1OFFSET\s0\fR specification. .SS "\s-1TIME\s0 \s-1REFERENCE\s0 \s-1SPECIFICATION\s0" .IX Subsection "TIME REFERENCE SPECIFICATION" The time reference specification is used, well, to establish a reference moment in time (to which the time offset is then applied to). When present, it should come first, when omitted, it defaults to \fBnow\fR. On its own part, time reference consists of a \fItime-of-day\fR reference (which should come first, if present) and a \fIday\fR reference. .PP The \fItime-of-day\fR can be specified as \fB\s-1HH:MM\s0\fR, \fB\s-1HH\s0.MM\fR, or just \fB\s-1HH\s0\fR. You can suffix it with \fBam\fR or \fBpm\fR or use 24\-hours clock. Some special times of day are understood as well, including \fBmidnight\fR (00:00), \fBnoon\fR (12:00) and British \&\fBteatime\fR (16:00). .PP The \fIday\fR can be specified as \fImonth-name\fR \fIday-of-the-month\fR and optional a 2\- or 4\-digit \fIyear\fR number (e.g. March 8 1999). Alternatively, you can use \fIday-of-week-name\fR (e.g. Monday), or one of the words: \&\fByesterday\fR, \fBtoday\fR, \fBtomorrow\fR. You can also specify the \fIday\fR as a full date in several numerical formats, including \fBMM/DD/[\s-1YY\s0]YY\fR, \&\fB\s-1DD\s0.MM.[\s-1YY\s0]YY\fR, or \fB\s-1YYYYMMDD\s0\fR. .PP \&\fI\s-1NOTE1\s0\fR: this is different from the original \fIat\fR\|(1) behavior, where a single-number date is interpreted as MMDD[\s-1YY\s0]YY. .PP \&\fI\s-1NOTE2\s0\fR: if you specify the \fIday\fR in this way, the \fItime-of-day\fR is \&\s-1REQUIRED\s0 as well. .PP Finally, you can use the words \fBnow\fR, \fBstart\fR, \fBend\fR or \fBepoch\fR as your time reference. \fBNow\fR refers to the current moment (and is also the default time reference). \fBStart\fR (\fBend\fR) can be used to specify a time relative to the start (end) time for those tools that use these categories (\fBrrdfetch\fR, rrdgraph) and \fBepoch\fR indicates the *IX epoch (*IX timestamp 0 = 1970\-01\-01 00:00:00 \s-1UTC\s0). \fBepoch\fR is useful to disambiguate between a timestamp value and some forms of abbreviated date/time specifications, because it allows to use time offset specifications using units, eg. \fBepoch\fR+19711205s unambiguously denotes timestamp 19711205 and not 1971\-12\-05 00:00:00 \s-1UTC\s0. .PP Month and day of the week names can be used in their naturally abbreviated form (e.g., Dec for December, Sun for Sunday, etc.). The words \fBnow\fR, \fBstart\fR, \fBend\fR can be abbreviated as \fBn\fR, \fBs\fR, \fBe\fR. .SS "\s-1TIME\s0 \s-1OFFSET\s0 \s-1SPECIFICATION\s0" .IX Subsection "TIME OFFSET SPECIFICATION" The time offset specification is used to add/subtract certain time intervals to/from the time reference moment. It consists of a \fIsign\fR (\fB+\fR\ or\ \fB\-\fR) and an \fIamount\fR. The following time units can be used to specify the \fIamount\fR: \fByears\fR, \fBmonths\fR, \fBweeks\fR, \fBdays\fR, \&\fBhours\fR, \fBminutes\fR, or \fBseconds\fR. These units can be used in singular or plural form, and abbreviated naturally or to a single letter (e.g. +3days, \-1wk, \-3y). Several time units can be combined (e.g., \-5mon1w2d) or concatenated (e.g., \-5h45min = \-5h\-45min = \&\-6h+15min = \-7h+1h30m\-15min, etc.) .PP \&\fI\s-1NOTE3\s0\fR: If you specify time offset in days, weeks, months, or years, you will end with the time offset that may vary depending on your time reference, because all those time units have no single well defined time interval value (1\ year contains either 365 or 366 days, 1\ month is 28 to 31 days long, and even 1\ day may be not equal to 24 hours twice a year, when DST-related clock adjustments take place). To cope with this, when you use days, weeks, months, or years as your time offset units your time reference date is adjusted accordingly without too much further effort to ensure anything about it (in the hope that \fImktime\fR\|(3) will take care of this later). This may lead to some surprising (or even invalid!) results, e.g. 'May\ 31\ \-1month' = 'Apr\ 31' (meaningless) = 'May\ 1' (after \fImktime\fR\|(3) normalization); in the \s-1EET\s0 timezone \&'3:30am Mar 29 1999 \-1 day' yields '3:30am Mar 28 1999' (Sunday) which is an invalid time/date combination (because of 3am \-> 4am \s-1DST\s0 forward clock adjustment, see the below example). .PP In contrast, hours, minutes, and seconds are well defined time intervals, and these are guaranteed to always produce time offsets 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 clock adjustment that occurs around 3:00\ Mar\ 28\ 1999, the actual time interval between 8:00\ Mar\ 27\ 1999 and 8:00\ Mar\ 29\ 1999 equals 47 hours; on the other hand, '8:00\ Mar\ 27\ 1999\ +48\ hours' = \&'9:00\ Mar\ 29\ 1999', as expected) .PP \&\fI\s-1NOTE4\s0\fR: The single-letter abbreviation for both \fBmonths\fR and \fBminutes\fR is \fBm\fR. To disambiguate them, the parser tries to read your mind\ :) by applying the following two heuristics: .IP "1." 3 If \fBm\fR is used in context of (i.e. right after the) years, months, weeks, or days it is assumed to mean \fBmonths\fR, while in the context of hours, minutes, and seconds it means minutes. (e.g., in \-1y6m or +3w1m \fBm\fR is interpreted as \fBmonths\fR, while in \&\-3h20m or +5s2m \fBm\fR the parser decides for \fBminutes\fR). .IP "2." 3 Out of context (i.e. right after the \fB+\fR or \fB\-\fR sign) the meaning of \fBm\fR is guessed from the number it directly follows. Currently, if the number's absolute value is below 25 it is assumed that \fBm\fR means \fBmonths\fR, otherwise it is treated as \fBminutes\fR. (e.g., \-25m == \-25 minutes, while +24m == +24 months) .PP \&\fIFinal \s-1NOTES\s0\fR: Time specification is case-insensitive. Whitespace can be inserted freely or omitted altogether. There are, however, cases when whitespace is required (e.g., 'midnight\ Thu'). In this case you should either quote the whole phrase to prevent it from being taken apart by your shell or use \&'_' (underscore) or ',' (comma) which also count as whitespace (e.g., midnight_Thu or midnight,Thu). .SS "\s-1TIME\s0 \s-1SPECIFICATION\s0 \s-1EXAMPLES\s0" .IX Subsection "TIME SPECIFICATION EXAMPLES" \&\fIOct 12\fR \*(-- October 12 this year .PP \&\fI\-1month\fR or \fI\-1m\fR \*(-- current time of day, only a month before (may yield surprises, see \s-1NOTE3\s0 above). .PP \&\fInoon yesterday \-3hours\fR \*(-- yesterday morning; can also be specified as \fI9am\-1day\fR. .PP \&\fI23:59 31.12.1999\fR \*(-- 1 minute to the year 2000. .PP \&\fI12/31/99 11:59pm\fR \*(-- 1 minute to the year 2000 for imperialists. .PP \&\fI12am 01/01/01\fR \*(-- start of the new millennium .PP \&\fIend\-3weeks\fR or \fIe\-3w\fR \*(-- 3 weeks before end time (may be used as start time specification). .PP \&\fIstart+6hours\fR or \fIs+6h\fR \*(-- 6 hours after start time (may be used as end time specification). .PP \&\fI931225537\fR \*(-- 18:45 July 5th, 1999 (yes, seconds since 1970 are valid as well). .PP \&\fI19970703 12:45\fR \*(-- 12:45 July 3th, 1997 (my favorite, and its even got an \s-1ISO\s0 number (8601)). .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" The following environment variables may be used to change the behavior of \&\f(CW\*(C`rrdtool\ fetch\*(C'\fR: .IP "\fB\s-1RRDCACHED_ADDRESS\s0\fR" 4 .IX Item "RRDCACHED_ADDRESS" If this environment variable is set it will have the same effect as specifying the \f(CW\*(C`\-\-daemon\*(C'\fR option on the command line. If both are present, the command line argument takes precedence. .SH "AUTHOR" .IX Header "AUTHOR" Tobias Oetiker