RRDTool use of three commands

Source: Internet
Author: User
Tags deprecated rrd rrdtool

To understand how rrdtool is to be used first from the RRD data storage, RRDtool is to operate the tool of the database, copy the following text to explain.

0x01 What is the RRD database

The so-called "Round Robin" is actually a way of storing data, using a fixed-size space to store the data, and a pointer to the location of the most recent data. We can think of the space of the database used to store the data as a circle with many ticks on it. Where these ticks are located represents where the data is stored. The so-called pointers can be thought of as a straight line pointing at these scales from the center point. The pointer moves automatically as the data reads and writes. Note that the circle has no start and end points, so the pointer can be moved all the time without worrying about the inability to move forward after reaching the end. After a period of time, when all the space is filled with data, it is stored again from the beginning. The size of the entire storage space is a fixed value. So RRDtool is a tool that uses a similar approach to storing data, and the suffix name of the database file used by RRDtool is '. Rrd. Such as

0x02 Creating RRDtool Create

Simply from the theoretical understanding of RRDtool is really difficult, DS, DST, RRA, PDP, CF, CDP and other key words directly into a piece, in fact, these keywords are from the RRD database creation statement. Since it was created, it was related to the structure of the RRD database.

* Create-create a new RRD

RRDtool Create filename [--start|-b start time]
[--step|-s Step]
[--no-overwrite|-o]
[DS:DS-NAME:DST:DST arguments]
[RRA:CF:CF arguments]

The explanation of each noun can be referred to http://freeloda.blog.51cto.com/2033581/1307492, which is very easy to read.

Personally, although the DS specifies how much each interval is, it does not indicate how large the whole DS is and how much data can be stored, so the DS is a temporary storage location

The final RRA is the so-called RRD database, CD arguments has SETPS specified how many PDP poly synthesis a cdp,rows indicates how many CDP, here has been fixed RRA contains several CDP, created after the size is unchanged, resulting in the RRD file size does not change

[email protected] ~]# rrdtool Create--start 1459017812--step 3 test.rrd ds:ds1:gauge:6:u:u rra:average:0.5:2: 600

Viewing the current time is Date +%s, which creates a time slot (--step 3) with a time interval of 3s, and then aggregates avergae per 2 PDP in RRA (each CDP span is 6s), creating 600, which records one hours of data.

View current RRD file, use Fetch to specify aggregation method and start time

[[email protected] ~]# rrdtool fetch TEST.RRD average-r 2-s 1459018002
Ds1

1459018008:-nan
1459018014:-nan
1459018020:-nan
1459018026:-nan
1459018032:-nan
1459018038:-nan

You can see the time interval of 6s, without any data, and then insert the data

0x03 Inserting Data rrdtool update

The command to insert data into the RRD file is RRDtool update

* Update-update an RRD

RRDtool update filename
[--template|-t ds-name:ds-name: ...]
[--daemon <address>]
time| N:value[:value ...]

[Email protected] [: Value ...]

[Time:value[:value ...]

Two main options one is the order of the data source, which corresponds to the order in which the values need to be inserted, the other is "Time: Value", the current time can be replaced by n

[[email protected] ~]# rrdtool update test.rrd N: ' Echo $RANDOM '

Just update the data once, write a loop to keep it updated

[email protected] ~]# cat test.sh
while (true)
Do
Sleep 3//insert data every 3s
RRDtool update test.rrd N: ' Echo $RANDOM '
Done

Then execute the script, after a period of time, to view the Rrd file,-R 2 is the resolution (representing two PDP aggregations, if the specified other resolution is created RRA, take similar)

[[email protected] ~]# rrdtool fetch TEST.RRD average-r 2-s 1459019604
Ds1

1459019610:2.4833740297e+04
1459019616:1.0401318901e+04
1459019622:2.2809431869e+04
1459019628:1.4484339557e+04
1459019634:1.3323151010e+04
1459019640:1.7158955025e+04
1459019646:1.1848137257e+04
1459019652:2.7713005683e+04
1459019658:2.2571123781e+04
1459019664:1.8554102312e+04

0x04 Drawing RRDtool Graph

RRD data file with data can be drawn, look at the parameters of RRDtool graph, too much! %>_<%

* Graph-generate a graph from one or several RRD

RRDtool graph filename [-s|--start seconds] [-e|--end seconds]

[-x|--x-grid x-axis grid and label]
[-y|--alt-y-grid] [--full-size-mode]
[-y|--y-grid Y-axis grid and label]
[-v|--vertical-label string] [-w|--width pixels]
[--right-axis Scale:shift] [--right-axis-label label]
[--right-axis-format format]
[-h|--height pixels] [-o|--logarithmic]
[-u|--upper-limit value] [-z|--lazy]
[-l|--lower-limit value] [-r|--rigid]
[-g|--no-legend] [--daemon <address>]
[-f|--force-rules-legend]
[-j|--only-graph]

[-n|--font FONTTAG:size:font]
[-m|--zoom factor]
[-a|- -alt-autoscale]
[-m|--alt-autoscale-max]
[-g|--graph-render-mode {Normal,mono}]
[-r|--font-render-mode {normal,light,mono}]
[-b|--font-smoothing-threshold size]
[-t|--tabwidth Width]
[-e|--slope-mode]
[-p|--pango-markup]
[-n|--no-gridfit]
[-x|-- Units-exponent value]
[-l|--units-length value]
[-s|--step seconds]
[-f|-- Imginfo Printfstr]
[-a|--imgformat PNG]
[-c|--color Colortag#rrggbb[aa]]
[-- Border width
[-t|--title string]
[-w|--watermark string]
[DEF:VNAME=RRD: DS-NAME:CF]

[Cdef:vname=rpn-expression]
[Vdef:vdefname=rpn-expression]
[PRINT:vdefname:format]
[GPRINT:vdefname:format]
[Comment:text]
[SHIFT:vname:offset]
[Textalign:{left|right|justified|center}]
[Tick:vname#rrggbb[aa][:[fraction][:legend]]
[Hrule:value#rrggbb[aa][:legend]]
[Vrule:value#rrggbb[aa][:legend]]
[line[width]:vname[#rrggbb [Aa][:[legend][:stack]]
[area:vname[#rrggbb [Aa][:[legend][:stack]]
[PRINT:vname:CF:format] (deprecated)
[GPRINT:vname:CF:format] (deprecated)
[stack:vname[#rrggbb [Aa][:legend]] (deprecated)

[-s|--start time] Start date
[-e|--end time] End
[-s|--step seconds] Resolution
[-t|--title string] The title of the picture &NBSP;
[-v|--vertical-label string] Y-axis label
[-w|-- Width pixels] display extents (pixels)
[-h|--height pixels] the height of the display area   (pixels)
[-j|--only-graph] Draw only images
[-u|--upper-limit value] Y-axis maximum
[-l|-- Lower-limit value] Y-axis min
[-r|--rigid] fixed y-axis values without scaling
[-a|--alt-autoscale" auto-scale
[-j|--alt-autoscale-min] Auto scale only minimum
[-m|--alt-autoscale-max] only Autoscale Max
[-n|--no-gridfit] do not display gridlines

< Span data-wiz-span= "Data-wiz-span" >< Span data-wiz-span= "Data-wiz-span" >< Span class= "Apple-converted-space" >< Span data-wiz-span= "Data-wiz-span" >< Span data-wiz-span= "Data-wiz-span" >[-x| --x-grid X-axis grid and label]  specify horizontal axis characteristics, datum gridline units (time): value: Main gridline Unit: value: X-axis label display interval (units): value: The latter two are time formats
[-y|--y-grid Y-axis Grid and label]

[-c|-- Color COLORTAG#RRGGBB[AA]] Specifies the associated color, Colortag (back/canvas/shadea/shadeb/grid/font/axis/frame/arrow)
[-n|-- Font FONTTAG:size:font] Custom font library, specifying path
[-a|-- Imgformat PNG] Output format
[-w|--watermark string] watermark

[data definition ...] The data and variables get the paint, in the following format:
def:vname=rrdfile:ds-name:cf[:step=step][ :start=time][:end=time]    varname A custom variable saves data obtained from an RRD data source, CF specifies which aggregate result of the data source (which RRA)

line[width]:value[#color][:[legend]] line weight: The variable vname# color defined by the previous def: color squares text information below the figure

[GPRINT:vname:CF:format] Figure below the value information

[email protected] ~]# rrdtool graph test.png--step 3--start=1459019604 def:vtest=test.rrd:ds1:average Line: vtest#ff0000: ' Date '

RRDTool use of three commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.