ziutek / rrd

Bindings to rrdtool
Other
147 stars 44 forks source link

date in rrd file #32

Open vlpoliakov28 opened 3 years ago

vlpoliakov28 commented 3 years ago

hi! By a call of the function Update value date in field _lastupdate in rrd file the current datetime value setting. why?

ziutek commented 3 years ago

I'm sorry, I don't understand your question.

vlpoliakov28 commented 3 years ago

Hi! When used function Update, what date wrote in rrd file? In field last_update. How write in field last_update my own date?

ziutek commented 3 years ago

The Update method takes a time as its first parameter. See the code bellow:

u := NewUpdater(dbfile)
for i := 0; i < 10; i++ {
    time.Sleep(step * time.Second)
    err := u.Update(time.Now(), i, 1.5*float64(i))
    if err != nil {
        t.Fatal(err)
    }
}

You can replace time.Now() with arbitrary date but be careful because RRD library checks it against the previous data/timestamp written and can drop data with inconsistent timestamp.

vlpoliakov28 commented 3 years ago

Big thanks! I will try it!