<div dir="ltr"><div><br></div><div>Hi,<br><br>The C API functions rrd_fetch ( ) and rrd_graph( ) both take 8 arguments, as per their declaration in the rrd.h file. This is how they are declared in rrd.h file:<br><br><span style="font-family:courier new,monospace">int rrd_fetch( int, char **,time_t *,time_t *,unsigned long *,unsigned long *,char ***, rrd_value_t **);<br>
<br>int rrd_graph(int,char **,char ***,int *,int *,FILE *,double *,double *);<br><br></span></div><div><span style="font-family:courier new,monospace"><font face="arial,helvetica,sans-serif">From what I know is that the first two arguments are the number of arguments and the array of char* arguments respectively.<br>
</font></span></div><div><span style="font-family:courier new,monospace"><font face="arial,helvetica,sans-serif">What are the rest of the arguments for? I mean what should I pass in those arguments in order to use the function from a C code?<br>
<br><br><br></font></span></div><div><span style="font-family:courier new,monospace"><font face="arial,helvetica,sans-serif">Thank you.<br></font></span></div><div><span style="font-family:courier new,monospace"><br>
<br></span></div><div><span style="font-family:courier new,monospace"> </span></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 29, 2013 at 12:28 PM, 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, Sir..<br></div>I has really helped me out.<br></div><div class="gmail_extra"><br>
<br><div class="gmail_quote"><div>On Fri, Nov 29, 2013 at 1:08 AM, Tony Mountifield <span dir="ltr"><<a href="mailto:tony@mountifield.org" target="_blank">tony@mountifield.org</a>></span> wrote:<br>
</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In article <CAOcjRXnATr1Qpu8rbjBT7_fsA4XaHANaCigTLe8qk6=<a href="mailto:Cr1NeYQ@mail.gmail.com" target="_blank">Cr1NeYQ@mail.gmail.com</a>>,<br>
<div>Fizza Hussain <<a href="mailto:12mseefhussain@seecs.edu.pk" target="_blank">12mseefhussain@seecs.edu.pk</a>> wrote:<br>
> Hi!<br>
><br>
> I have written a C program which use RRD C API functions rrd_create(),<br>
> rrd_update() and rrd_dump() to create, update and show the contents of the<br>
> RRD database. I want to fill the RRD database with the integers returned by<br>
> C rand( ) function i.e. the random value generated by the rand( ) function<br>
> is stored against each timestamp.<br>
><br>
> Below is my code snippet:<br>
><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>
> Please guide me how can I access the timestamp variable and write it in the<br>
> update parameter at the place marked by ???.<br>
<br>
</div>You need to have a buffer that you update. In your example above,<br>
"???:Bytecounter[i]" is just a string, not a reference to the Bytecounter<br>
array. Try this:<br>
<br>
char buffer[32];<br>
<div><br>
char *updateparams[] = {<br>
"rrdupdate",<br>
"Flow1bytes.rrd",<br>
</div> buffer,<br>
<div> NULL<br>
};<br>
<br>
for (i=0; i<50; i++)<br>
{<br>
</div> timestamp = ...; /* get a timestamp from somewhere */<br>
flow1.bytes = rand();<br>
Bytecounter[i] = flow1.bytes; /* why two steps, and the storage in the array? */<br>
snprintf(buffer, sizeof(buffer), "%d:%d", timestamp, Bytecounter[i]);<br>
rrd_update(3,updateparams);<br>
}<br>
<br>
I realize that this is just a test example, but you should be aware that RRD<br>
will not allow you to write multiple values to the same timestamp (even if that<br>
timestamp is N). For testing, you could initialise timestamp outside the loop<br>
and increment it within the loop.<br>
<br>
Hope this is enough to get you started. It's really basic C programming, not RRD-specific.<br>
<br>
Cheers<br>
<span><font color="#888888">Tony<br>
--<br>
Tony Mountifield<br>
Work: <a href="mailto:tony@softins.co.uk" target="_blank">tony@softins.co.uk</a> - <a href="http://www.softins.co.uk" target="_blank">http://www.softins.co.uk</a><br>
Play: <a href="mailto:tony@mountifield.org" target="_blank">tony@mountifield.org</a> - <a href="http://tony.mountifield.org" target="_blank">http://tony.mountifield.org</a><br>
</font></span><div><div><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>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div></div>