RRDtool combine Python to count network card traffic

Source: Internet
Author: User
Tags rrd rrdtool
Import RRDtool
Import time

CUR_TIME=STR (int (time.time ()))
Rrd=rrdtool.create (' flow.rrd ', '--step ', ' a ', '--start ', Cur_time, #Flow. RRD filename,--step indicates how often the data is written, Start indicates the start time of the first record
' Ds:eth0_in:counter:600:0:u ', #DS定义数据源, the network card eth0 into the traffic, COUNTER represents the increment (DST definition data type), followed by 600 seconds for the heartbeat value, 600 seconds without receiving data, will be replaced with unknown, 0 is the minimum value and U is the maximum value
' Ds:eth0_out:counter:600:0:u ', #DST有的类型: DERIVE (can be increased and reduced), ABSOLUTE (assuming the previous time interval is 0, then the average), guage (the value is received directly into RRA), COMPUTE (defining expressions, referencing DS and automatically calculating a value)
' rra:average:0.5:1:600 ', #RRA定义数据存储格式
' rra:average:0.5:6:700 ', #CF统计合并数据, with AVERAGE, Max, min,last up-to-date values
' rra:average:0.5:24:775 ', #数字0.5 indicates that PDP values in one CDP are marked as unknown if more than half are unknown.
' rra:average:0.5:288:797 ', #存储时间计算为0. The value after 5 is multiplied by 300 seconds, and the last value represents the number of times the value is stored
' rra:max:0.5:1:600 ',
' rra:max:0.5:6:700 ',
' rra:max:0.5:24:775 ',
' rra:max:0.5:444:797 ',
' rra:min:0.5:1:600 ',
' rra:min:0.5:6:700 ',
' rra:min:0.5:24:775 ',
' rra:min:0.5:444:797 ')
If RRD:
Print (Rrdtool.error ())

RRDtool combine Python to count network card traffic

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.