Rrdtool data-php Tutorial

Source: Internet
Author: User
Tags rrd rrdtool
For rrdtool data, write a data every 10 seconds, but the read is different from the written data.

The created database is as follows:

./Bin/rrdtool create data/test. rrd -- start 1365756520 -- step 10 DS: myds: GAUGE: 100: 0: u rra: LAST: 0.5: 1: 100000


Write Data
./Bin/rrdtool updatev data/test. rrd-t myds N: 1028


Read Data
./Bin/rrdtool fetch data/test. rrd LAST-s 1365756520

// Return [1365766390] RRA [AVERAGE] [1] DS [myds] = 1.0256558852e + 03

What is the situation, as if the average value has been obtained ??




Reply to discussion (solution)

Who will answer this question?

[1, 1365766390] RRA [AVERAGE] [1] DS [myds] = 1.0256558852e + 03
AVERAGE

Isn't that what you want?

However, my/bin/rrdtool fetch data/test. rrd LAST-s 1365756520

Fetch is LAST

[root@localhost shm]# /usr/local/rrdtool/bin/rrdtool create test.rrd --step 10 DS:myds:GAUGE:100:0:U RRA:LAST:0.5:1:100000[root@localhost shm]# /usr/local/rrdtool/bin/rrdtool updatev test.rrd -t myds N:1028return_value = 0[1365991710]RRA[LAST][1]DS[myds] = 1.0280000000e+03[root@localhost shm]# /usr/local/rrdtool/bin/rrdtool fetch test.rrd LAST | grep -v nan                           myds1365991710: 1.0280000000e+03[root@localhost shm]# /usr/local/rrdtool/bin/rrdtool -VRRDtool 1.4.7  Copyright 1997-2012 by Tobias Oetiker 
 
                 Compiled Jul  5 2012 15:34:45
 


Here I will test ...... No such problem ......

It is strange that according to your create statement, the average cf should not exist. do you have other operations on this test. rrd?


[root@localhost shm]# /usr/local/rrdtool/bin/rrdtool create test.rrd --step 10 DS:myds:GAUGE:100:0:U RRA:LAST:0.5:1:100000[root@localhost shm]# /usr/local/rrdtool/bin/rrdtool info test.rrd filename = "test.rrd"rrd_version = "0003"step = 10last_update = 1365991934header_size = 584ds[myds].index = 0ds[myds].type = "GAUGE"ds[myds].minimal_heartbeat = 100ds[myds].min = 0.0000000000e+00ds[myds].max = NaNds[myds].last_ds = "U"ds[myds].value = 0.0000000000e+00ds[myds].unknown_sec = 4rra[0].cf = "LAST"rra[0].rows = 100000rra[0].cur_row = 82401rra[0].pdp_per_row = 1rra[0].xff = 5.0000000000e-01rra[0].cdp_prep[0].value = NaNrra[0].cdp_prep[0].unknown_datapoints = 0

In addition, there is a situation where you want to test how historical data will be processed ...... However, I don't think there should be a merge average for your create statement.

In this case, the previous data update is normal, but the subsequent data changes to a mess,

It is strange that according to your create statement, the average cf should not exist. do you have other operations on this test. rrd?


PHP code? 12345678910111213141516171819202122 [root @ localhost shm] #/usr/local/rrdtool/bin/rrdtool create test. rrd -- st ......

In fact, I want to use it as a database, store what data, and retrieve what data.

[Root @ localhost rrdtool] #./bin/rrdtool updatev data/test. rrd-t myds N: 1028
Return_value = 0
[1366011870] RRA [LAST] [1] DS [myds] = 1.0011771028e + 03
[1366011890] RRA [LAST] [1] DS [myds] = 1.0011771028e + 03
[Root @ localhost rrdtool] #

Even more depressing, why are two rows returned and two time stamps?

Try again.
./Bin/rrdtool create data/test. rrd -- start 1365768603 -- step 10 DS: myds: GAUGE: 100: 0: u rra: LAST: 0.5: 1: 100000


./Bin/rrdtool updatev data/test. rrd-t myds N: 1028


./Bin/rrdtool updatev data/test. rrd-t myds N: 102


[Root @ localhost rrdtool] #./bin/rrdtool updatev data/test. rrd-t myds N: 76
Return_value = 0
[1, 1366095920] RRA [LAST] [1] DS [myds] = 7.3762737333e + 01
[1, 1366095940] RRA [LAST] [1] DS [myds] = 7.3762737333e + 01


------ The following content is info ----
[Root @ localhost rrdtool] #./bin/rrdtool info data/test. rrd
Filename = "data/test. rrd"
Rrrd_version = "0003"
Step = 10
Last_update = 1366095930
Header_size = 584
Ds [myds]. index = 0
Ds [myds]. type = "GAUGE"
Ds [myds]. minimal_heartbeat = 100
Ds [myds]. min = 0.20.000000e + 00
Ds [myds]. max = NaN
Ds [myds]. last_ds = "76"
Ds [myds]. value = 5.9394532000e + 01
Ds [myds]. unknown_sec = 0
Rra [0]. cf = "LAST"
Rra [0]. rows = 100000
Rra [0]. cur_row = 79575
Rra [0]. pdp_per_row = 1
Rra [0]. xff = 5.20.000000e-01
Rra [0]. cdp_prep [0]. value = NaN
Rra [0]. cdp_prep [0]. unknown_datapoints = 0

No answers...

Solving ........

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.