<div dir="ltr"><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">Hi!<br><br>I have written a C program which use RRD C API functions rrd_create(), rrd_update() and rrd_dump() to create, update and show the contents of the RRD database</span>. <span style="font-family:arial,helvetica,sans-serif">I want to fill the RRD database with the integers returned by C rand( ) function i.e. the random value generated by the rand( ) function is stored </span></span><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">against each timestamp.</span></span><br>
<br></span></span></div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">Below is my code snippet:<br></span></span><div><span style="font-family:courier new,monospace"><br>
char *updateparams[] = {<br> "rrdupdate",<br> "Flow1bytes.rrd",<br> "???:Bytecounter[i]",<br> NULL<br> };<br><br><br>for (i=0; i < 50; i++)<br>{ <br>flow1.bytes= rand();<br>
Bytecounter[i]=flow1.bytes;<br>rrd_update(3,updateparams);<br>}<br><br></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">Please guide me how can I access the timestamp variable and write it in the update parameter at the place marked by ???.</span><br>
<span style="font-family:arial,helvetica,sans-serif"><br></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">The code for creating the Flow1bytes.rrd database is this:</span><br>
<br><span style="font-family:comic sans ms,sans-serif">char *createparams[] = {<br> "rrdcreate",<br> "Flow1bytes.rrd",<br> "--step=1",<br> "DS:Bytecounter:COUNTER:1000:0:800",<br>
"RRA:AVERAGE:0.5:1:50",<br> NULL<br> };<br></span><br></span></div><div><span style="font-family:courier new,monospace">rrd_create(5, createparams);<br><br><span style="font-family:arial,helvetica,sans-serif"><br>
</span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">Thank you.</span><br></span></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Nov 28, 2013 at 11:01 AM, Fizza Hussain <span dir="ltr"><<a href="mailto:12mseefhussain@seecs.edu.pk" target="_blank">12mseefhussain@seecs.edu.pk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Thank you so much Petteri for your help..<br><br></div><div>I am definitely going to try this out..<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Nov 28, 2013 at 12:43 AM, Petteri Matilainen <span dir="ltr"><<a href="mailto:pmatil@gmail.com" target="_blank">pmatil@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On 27.11.2013 13:12, Fizza Hussain wrote:<br>
> Hi,<br>
><br>
> I want to create and update the RRD database from a C code. For that<br>
> purpose, I have included rrd.h file in my source code and have linked<br>
> the C code against librrd library. These two steps are done perfectly.<br>
> However, I am facing some difficulties in figuring out what arguments<br>
> should I provide to the functions provided by C API? For example,<br>
> rrd_create( ) function takes an int and a char string as its arguments.<br>
> i.e. {int rrd_create(int , char **)}.<br>
><br>
><br>
> I have previously used rrdtool via CLI and am comfortable with its CLI<br>
> commands rrdtool create test.rrd --start 90234 (and so on). Please guide<br>
> me what should be the arguments to the rrd_create( ) function provided<br>
> by C API.<br>
><br>
><br>
><br>
> Thanks,<br>
><br>
> Fizza Hussain<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> rrd-users mailing list<br>
> <a href="mailto:rrd-users@lists.oetiker.ch" target="_blank">rrd-users@lists.oetiker.ch</a><br>
> <a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users</a><br>
><br>
<br>
Hi Fizza,<br>
<br>
The create function takes only 2 arguments: the count and the array of<br>
pointers to the arguments. Among the first links in google I found this<br>
example: <a href="http://permalink.gmane.org/gmane.comp.db.rrdtool.devel/894" target="_blank">http://permalink.gmane.org/gmane.comp.db.rrdtool.devel/894</a><br>
There's an example on how to use the create function and many others.<br>
Note that the examples are for an older version of rrdtool so you may<br>
have to modify the code.<br>
<br>
regards,<br>
<br>
Pete<br>
<br>
<br>
_______________________________________________<br>
rrd-users mailing list<br>
<a href="mailto:rrd-users@lists.oetiker.ch" target="_blank">rrd-users@lists.oetiker.ch</a><br>
<a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>