RRDtool usage (combined with instances)

Source: Internet
Author: User
Tags rrd rrdtool

I. Introduction
RRDtool refers to the Round Robin Database tool, that is, the ring Database. In terms of functionality, RRDtool can be used for data storage + data display. The well-known network traffic plotting software MRTG and Cluster Monitoring System Ganglia both use the RRDtool.

In terms of data storage, RRDtool uses the "Round Robin" mode to store data. The so-called "Round Robin" is a way to store data, using a fixed size of space to store data, and a pointer pointing to the latest data location. We can regard the database space used to store data as a circle with many scales on it. The positions of these scales represent the places where data is stored. A pointer can be considered as a line pointing from the center to these scales. The pointer is automatically moved as data is read and written. Note that this circle does not have a starting point or an ending point, so the pointer can be moved all the time without worrying about writing after it reaches the ending point. After a period of time, when all the space is full of data, it will be stored from the beginning. In this way, the size of the entire bucket is a fixed value. The suffix of the database file used by RRDtool is ". rrd ".
In terms of data presentation, RRDtool can be seen as a powerful drawing engine. This is one of them on the official website. We have a general understanding of the drawing capabilities of RRDtool.

RRDtool official website link: http://oss.oetiker.ch/rrdtool/

Ii. Basic syntax
RRDtool is used in three parts: creating a database, updating data, and drawing (using shell commands ). Therefore, we also introduce the basic syntax in the above three parts.
1. database creation
To be clear, the database creation command is written as a segment here, and the actual application should be written as a string.
Rrdtool create cpu. rrd # Database Name
-- Start $ (date-d '1 days ago '+ % s) # start Time
-- Step 15 # Data Update Interval
DS: cpu_user: GAUGE: 120: 0: NaN # DS: cpu_user, equivalent to the variable name; followed by DST: GAUGE, equivalent to the data type; followed by heartbeat, is the maximum no data interval; the last two NaN are the minimum and maximum limits.
DS: cpu_system: GAUGE: 120: 0: NaN
DS: cpu_wio: GAUGE: 120: 0: NaN
DS: cpu_idle: GAUGE: 120: 0: NaN
RRA: AVERAGE: 0.5: 1: 244 # RRA is the form of data storage, Data Tables
RRA: AVERAGE: 0.5: 24: 244 # CF merge statistics include average, max, min, and last
RRA: AVERAGE: 0.5: 168: 244 #0.5 is xff, indicating that when the proportion of the missing data volume exceeds 0.5, the data is displayed as null.
RRA: AVERAGE: 0.5: 672: 244 # PDP, a data point calculated, such as the AVERAGE value.
RRA: AVERAGE: 0.5: 5760: 374 # CDP, which combines multiple PDP into one CDP. CDP is the value actually stored in RRA and used in plotting, 1. 24, 168, and 672 indicate how many PDP are merged into one CDP.

For specific parameter meanings, see the notes. The purpose of this Code Section is to create an rrd database cpu. rrd, save cpu-related information, and update data every 15 seconds.

Ii. Update

Update is relatively simple, that is, writing data to the database (that is, the. rrd file) on a regular basis. Write commands every time, similar to the following commands.

Rrdtool updatev/var/lib/monitor/rrds/server/cpu. rrd 1382646278: 0.733211: 0.433261: 1.516414: 97.317114
#/Var/lib/monitor/rrds/server/cpu. rrd is a database file
#1382646278 is the timestamp
#0.733211: 0.433261: 1.516414: 97.317114 is the specific write value, which respectively refer to cpu_user, cpu_system, cpu_wio, and cpu_idle.

In actual use, you should write a program to regularly obtain the cpu usage, and execute the above command to write data to the database.

3. Drawing
Similar to when creating a database, for clear expressions, the drawing command is written as a segment, which should be written as a string in actual application.
/Usr/bin/rrdtool graph/home/xx/cpu.png
-- Start '-100' -- end N // time of the past hour
-- Width 385 -- height 190 // image size
-- Title 'cpu usage in the past hour '-- upper-limit 100 -- lower-limit 0 // question and upper and lower limits
-- Vertical-label percentage -- rigid
DEF: 'cpu _ user' = '/var/lib/monitor/rrds/server/cpu. rrd': 'cpu _ user': AVERAGE # obtain the variable cpu_user
AREA: 'cpu _ user' # FF0000: 'user' // graphic format, including AREA, STACK, LINE, etc.
VDEF: cpu_user_last = cpu_user, LAST // variable definition, take the specific value
VDEF: cpu_user_avg = cpu_user, AVERAGE
Gprs int: 'cpu _ user_last ': 'Now \: % 5.1lf % s' // print the value in the image
Gprs int: 'cpu _ user_avg ': 'avg \: % 5.1lf % s \ J' DEF: 'cpu _ system' = '/var/lib/monitor/rrds/server/cpu. rrd ': 'cpu _ system': average stack: 'cpu _ system' #33cc33: 'system' VDEF: cpu_system_last = cpu_system, last vdef: cpu_system_avg = cpu_system, AVERAGE uplint: 'cpu _ system_last ': 'Now \: % 5.1lf % s 'uplint: 'cpu _ system_avg': 'avg \: % 5.1lf % s \ J' DEF: 'cpu _ wio' = '/var/lib/monitor/rrds/server/cpu. rrd ': 'cpu _ wio': average stack: 'cpu _ wio '# 1C86EE: 'wait' VDEF: cpu_wio_last = cpu_wio, last vdef: cpu_wio_avg = cpu_wio, AVERAGE uplint: 'cpu _ wio_last ': 'Now \: % 5.1lf % s 'uplint: 'cpu _ wio_avg': 'avg \: % 5.1lf % s \ J' DEF: 'cpu _ idle' = '/var/lib/monitor/rrds/server/cpu. rrd ': 'cpu _ idle': average stack: 'cpu _ idle' # e2e2f2: 'id' VDEF: cpu_idle_last = cpu_idle, last vdef: cpu_idle_avg = cpu_idle, AVERAGE uplint: 'cpu _ idle_last ': 'Now \: % 5.1lf % s 'uplint: 'cpu _ idle_avg': 'avg \: % 5.1lf % s \ J'

The image is as follows. I deliberately stopped updating the data for a period of time, and the image obtained by drawing showed no data during the corresponding period of time.

Use RRDtool to customize plotting to monitor Oracle databases

Simple Image Rendering using RRDtool

When installing RRDtool, the following error occurs: configure: error: Please fix the library issues listed above and try again.

RHEL5.5 installing RRDtool solves many Dependencies

Use yum to install RRDtool in CentOS

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.