Python learns the-python and RRDtool combination modules

Source: Internet
Author: User
Tags rrd rrdtool

RRDtoolround robin DatabaseTool is a storage format for the ring database, round robin is a technique for processing quantitative data and pointers to current elements. RRDtool is mainly used to track the change of objects, generate these changes in the trend map, such as traffic flow, system performance, disk utilization trends, many popular monitoring platforms are used to RRDtool, more famous for cacti, Ganglia, Monitorix and so on. More RRDtool introduction See official Website http://oss.oetiker.ch/rrdtool/. RRDtool is a complex tool that involves a lot of parametric concepts, and this section encapsulates several common methods of rrdtool, including Create, fetch, graph, info, and update, through Python's RRDtool module, This section does not explain the basics of RRDtool, and focuses on the use of the Python RRDtool module in the common approach.

The installation method of the RRDtool module is as follows:

Easy_install python-rrdtool #pip安装方法 pip install Python-rrdtool #easy_install安装方法 #需要rrdtool工具及其他类包支持, the CentOS Environment recommends Installation method with Yum # yum install Rrdtool-python
RRDtool Module Common method Description

The following are some common methods of the RRDtool module, including create (creating RRD), update (updated RRD), graph (Drawing), Fetch (query RRD) , and so on.

1. Create method

Create filename [--start|-b start time] [--step|-s step] [Ds:ds-name:dst:heartbeat:min:max] [RRA:CF:xff:steps:rows] method, Create a RRDtool database with the suffix RRD , with the parameters described below:

The filename of the RRDtool database created by filename, The default suffix is. rrd;--start Specifies the start time of the first record of RRDtool, which must be in timestamp format,--step specifies how often rrdtool receives a value for 5 minutes by default, which is used by the DS to define a data source, a variable that holds the result of the script; DST is used to define the data source Type, RRDtool supports counter (increment type), DERIVE (can be incrementally decremented), ABSOLUTE (assuming the value of the previous time interval is 0, then the average), guage (which is deposited directly into RRA after receiving the value), COMPUTE (Defining an expression, Refer to DS and automatically calculate a value) 5 kinds, such as network card traffic belongs to counter type, should choose Counter;rra to specify how to store the data, we can take a RRA as a table, save the statistical results of different intervals data, for CF to do data consolidation to provide the basis, the definition format is: [RRA: CF:XFF:STEPS:ROWS];CF statistics combine data, support average (average), Max (max), min (min), last (newest) 4 ways.

2. Update method

Update filename [--template|-t ds-name[:d s-name] ...] N|timestamp:value[:value ...] [Timestamp:value[:value ...] method, which stores a new value to the RRDtool database , similar to Updatev and update, the difference is that a status code is returned each time it is inserted in order to see if it succeeds (Updatev uses 0 for success, and –1 indicates failure). The parameters are described as follows:

filename Specifies the target RRD file to which the data is stored;-t ds-name[:d S-name] Specifies the name of the DS that needs to be updated; n| Timestamp represents the timestamp of the data acquisition, N represents the current timestamp; Value[:value ...] Updated data values, multiple DS multiple values.

3. Graph method

Graph filename [-s|--start seconds] [-e|--end seconds] [-x|--x-grid x-axis grid and label] [-y|--y-grid y-axis grid and LA BEL] [--alt-y-grid] [--ALT-Y-MRTG] [--alt-autoscale] [--alt-autoscale-max] [--units-exponent] value [-v|-- Vertical-label text] [-w|--width pixels] [-h|--height pixels] [-i|--interlaced] [-f|--imginfo formatstring] [-a|-- Imgformat gif| PNG|GD] [-b|--background value] [-o|--overlay value] [-u|--unit value] [-z|--lazy] [-o|--logarithmic] [-u|--upper-limit Value] [-l|--lower-limit value] [-g|--no-legend] [-r|--rigid] [--step value] [-b|--base value] [-c|--color colortag# RRGGBB] [-t|--title title] [DEF:VNAME=RRD:DS-NAME:CF] [cdef:vname=rpn-expression] [PRINT:vname:CF:format] [Gprint: Vname:CF:format] [Comment:text] [hrule:value#rrggbb[:legend] [vrule:time#rrggbb[:legend]] [line{1|2|3}:vname[# RRGGBB [: Legend]] [area:vname[#rrggbb [: Legend]] [stack:vname[#rrggbb [: Legend]]] method,drawing based on the specified RRDtool database, the key parameters are described as follows:

filename Specifies the file name of the output image, the default is the PNG format,--start Specifies the start time,--end Specifies the end time,--x-grid controls the x-axis gridline scale, the position of the label,--y-grid controls the y-axis gridline scale, the label's position ;--vertical-label specifies the caption text for the y-axis,--width pixels Specifies the width of the chart (pixels),--height pixels Specifies the height of the chart (in pixels),--imgformat the specified image format (gif| Png| GD);--background Specifies the image background color, supports #rrggbb notation,--upper-limit specifies the upper bound of the y-axis data value,--lower-limit specifies the lower limit of the y-axis data value;--no-legend Cancel the legend below the chart ;--rigid in strict accordance with Upper-limit and Lower-limit;--title the title at the top of the chart; DEF:VNAME=RRD:DS-NAME:CF the data source used to specify the drawing; cdef:vname= Rpn-expression merge multiple values, GPRINT:vname:CF:format the bottom of the chart output maximum, minimum, average, and so on; comment:text some strings that are output in the specified chart; hrule:value# The RRGGBB is used to draw a horizontal line above the chart, vrule:time#rrggbb to draw vertical lines on the chart, line{1|2|3}:vname to plot the data chart with lines, {1|2|3} to represent the thickness of the line; Area: VName the area map to plot the data graph.

4. Fetch method

Fetch filename CF [--resolution|-r resolution] [--start|-s start] [--end|-e end] method, query according to the specified RRDtool database , Key parameters are described below:

filename Specifies the RRD file name to query, CF includes average, MAX, MIN, last, required to be the type defined in RRA when the library is built, otherwise an error will be given;--start--end specifies the start and end time of the query record, the value of the option must be The timestamp format, which can be omitted by default. Gets the timestamp of the current time: Date +%s

Python learns the-python and RRDtool combination modules

Related Article

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.