[rrd-users] rrd_update_r() error : expected timestamp not found in data source from update

Athanasios Silis athanasios.silis at gmail.com
Mon Dec 21 14:48:04 CET 2015


thank you very much!
indeed rrd_update_r() takes its arguments in a fairly different way
compared to rrd_update().
In fact calling the 3rd and 4th arguments of rrd_update_r() is misleading.

One more question that is unclear to be. Is rrd_update_r() actually an
async call to rrd_update? or is it simple a thread-safe call to rrd_update
and I am the one who should spawn a thread and execute rrd_update_r() in it?

thank you

On Mon, Dec 21, 2015 at 3:22 PM, Tony Mountifield <tony at mountifield.org>
wrote:

> Hi there,
>
>
>
> You might find this page useful:
> http://stackoverflow.com/questions/6681090/how-to-call-threadsafe-rrd-update-r-round-robin-database-function-with-c-api
>
>
>
> In particular, I think you need to give the template separately as the
> second arg to rrd_update_r().
>
>
>
> Try something that ends up like this:
>
>
>
> char *argv[] = { "1450694776:1015:1000:123:20.63:38.48:987" };
>
>
>
> int ret = rrd_update_r("sensors.rrd",
> "CO2unf:CO2fil:O2pp:O2pct:O2temp:O2pres", 1, argv);
>
>
>
> Regards
>
> Tony
>
>
>
> *From:* Athanasios Silis [mailto:athanasios.silis at gmail.com]
> *Sent:* 21 December 2015 12:12
> *To:* Tony Mountifield
> *Subject:* Re: [rrd-users] rrd_update_r() error : expected timestamp not
> found in data source from update
>
>
>
> mind you the examples are not very helpful, because the only relevant
> section is in rrd_daemon.c , where
>
> a "cache_item_t" structure is "fed" into rrd_update_r().
>
> The "cache_item_t" structure is a typedef of "cache_item_s"  and no parent
> declaration is visible anywhere in the rrdtool1.x/* folder!
>
>
>
> On Mon, Dec 21, 2015 at 12:47 PM, Athanasios Silis <
> athanasios.silis at gmail.com> wrote:
>
> Hi there,
>
> thank you for taking the time. This is only a proof of concept to verify
> how it works. so it all in main.cpp
>
> #include <iostream>
> #include <errno.h>   // Error number definitions
> #include <rrd.h>
> #include <wordexp.h>
> #include <time.h>
>
> using namespace std;
>
> void splitToArgs(string& str);
>
> int main(int argc, char* argv[])
> {
>         time_t tm = time(NULL);
>         stringstream ss;
>         ss << tm;
>         cout << "ss=" << ss.str() << endl;
>
>         string updstr = string("update sensors.rrd --template
> CO2unf:CO2fil:O2pp:O2pct:O2temp:O2pres ")\
>                 + ss.str() + string(":1015:1000:123:20.63:38.48:987");
>         cout << "updstr=" << updstr << endl;
>
>         splitToArgs(updstr);
>         return 0;
> }
>
> void splitToArgs(string& str)
> {
>         wordexp_t we;
>         int er = 0;
>
>         if ( (er=wordexp(str.c_str() , &we, 0)) != 0)
>         {
>                 cout << "error in word expansion " <<  er << endl;
>         }
>         else
>         {
>                 if (we.we_wordc>0)
>                 {
>                         char * filename = we.we_wordv[1];
>                         rrd_clear_error();
>                         //int ret = rrd_update( we.we_wordc, we.we_wordv );
>                         const char **w = const_cast<const
> char**>(we.we_wordv); //hell yeah!
>                         int ret = rrd_update_r( filename , NULL ,
> we.we_wordc, w );
>                         if ( ret != 0 )
>                         {
>                                 cout << "rrd_update error # = " << ret <<
> " error get= "
>                                          << rrd_get_error() << "
> rrd_strerror(errno) = " << endl;
>                         }
>                 }
>         }
>         wordfree(&we);
> }
>
>
>
> The about produces the following output:
>
> ss=1450694776
>
> updstr=update sensors.rrd --template
> CO2unf:CO2fil:O2pp:O2pct:O2temp:O2pres
> 1450694776:1015:1000:123:20.63:38.48:987
>
> rrd_update error # = -1 error get= sensors.rrd: expected timestamp not
> found in data source from update
>
>
>
>
>
> On Mon, Dec 21, 2015 at 12:22 PM, Tony Mountifield <tony at mountifield.org>
> wrote:
>
> In article <CADgchnuMGkA=tQdMtACMWPYX2TgDUwKfbf3g=
> d+Fa3V5BP+WDA at mail.gmail.com>,
> Athanasios Silis <athanasios.silis at gmail.com> wrote:
> > Hello there,
> > I am trying to use rrd_update_r() to update a rrdb through a c++ program.
> > So I am generating the argc/argv on the fly to pass into the function.
> >
> > The originating string is the following:
> >
> >         time_t tm = time(NULL);
> >         stringstream ss;
> >         ss << tm;
> >         string updstr = string("update sensors.rrd \
> >                 --template CO2unf:CO2fil:O2pp:O2pct:O2temp:O2pres ")\
> >                 + ss.str() + string(":1015:1000:123:20.63:38.48:987");
> >
> > I get this error  from rrd_get_error():
> > sensors.rrd: expected timestamp not found in data source from update
> >
> > Is timestamp not accepted in seconds from EPOCH?
>
> Can you show your code all the way from the above until the call to
> rrd_update_r()?
>
> Also, show the value of updstr, to make sure it is what you think it is?
>
> Cheers
> Tony
> --
> Tony Mountifield
> Work: tony at softins.co.uk - http://www.softins.co.uk
> Play: tony at mountifield.org - http://tony.mountifield.org
>
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/rrd-users/attachments/20151221/57b2a4b4/attachment.html>


More information about the rrd-users mailing list