[rrd-users] C API for rrdtool
Fizza Hussain
12mseefhussain at seecs.edu.pk
Thu Nov 28 14:55:03 CET 2013
I have found this information in a
tutorial<http://www.vandenbogaerdt.nl/rrdtool/tutorial/rrdupdate.php>that
'N' is Now i.e. the current time. I think It can be used as the
current timestamp variable (denoted by ??? in the code snippet).
I have now used that N in my code:
char *updateparams[] = {
"rrdupdate",
"Flow1bytes.rrd",
"N:Bytecounter[i]",
NULL
};
However, the RRD database Flow1bytes.rrd is still not updated. All the
values against each timestamp are are Unknown i.e. -nan.
1385646821: -nan
1385646822: -nan
1385646823: -nan
1385646824: -nan
1385646825: -nan
1385646826: -nan
1385646827: -nan
1385646828: -nan
1385646829: -nan
and so on...
Please suggest what is going wrong?
On Thu, Nov 28, 2013 at 2:57 PM, Fizza Hussain
<12mseefhussain at seecs.edu.pk>wrote:
> Hi!
>
> 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. 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 against each timestamp.
>
> Below is my code snippet:
>
> char *updateparams[] = {
> "rrdupdate",
> "Flow1bytes.rrd",
> "???:Bytecounter[i]",
> NULL
> };
>
>
> for (i=0; i < 50; i++)
> {
> flow1.bytes= rand();
> Bytecounter[i]=flow1.bytes;
> rrd_update(3,updateparams);
> }
>
> Please guide me how can I access the timestamp variable and write it in
> the update parameter at the place marked by ???.
>
> The code for creating the Flow1bytes.rrd database is this:
>
> char *createparams[] = {
> "rrdcreate",
> "Flow1bytes.rrd",
> "--step=1",
> "DS:Bytecounter:COUNTER:1000:0:800",
> "RRA:AVERAGE:0.5:1:50",
> NULL
> };
>
> rrd_create(5, createparams);
>
>
> Thank you.
>
>
>
> On Thu, Nov 28, 2013 at 11:01 AM, Fizza Hussain <
> 12mseefhussain at seecs.edu.pk> wrote:
>
>> Thank you so much Petteri for your help..
>>
>> I am definitely going to try this out..
>>
>>
>> On Thu, Nov 28, 2013 at 12:43 AM, Petteri Matilainen <pmatil at gmail.com>wrote:
>>
>>> On 27.11.2013 13:12, Fizza Hussain wrote:
>>> > Hi,
>>> >
>>> > I want to create and update the RRD database from a C code. For that
>>> > purpose, I have included rrd.h file in my source code and have linked
>>> > the C code against librrd library. These two steps are done perfectly.
>>> > However, I am facing some difficulties in figuring out what arguments
>>> > should I provide to the functions provided by C API? For example,
>>> > rrd_create( ) function takes an int and a char string as its arguments.
>>> > i.e. {int rrd_create(int , char **)}.
>>> >
>>> >
>>> > I have previously used rrdtool via CLI and am comfortable with its CLI
>>> > commands rrdtool create test.rrd --start 90234 (and so on). Please
>>> guide
>>> > me what should be the arguments to the rrd_create( ) function provided
>>> > by C API.
>>> >
>>> >
>>> >
>>> > Thanks,
>>> >
>>> > Fizza Hussain
>>> >
>>> >
>>> > _______________________________________________
>>> > rrd-users mailing list
>>> > rrd-users at lists.oetiker.ch
>>> > https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>>> >
>>>
>>> Hi Fizza,
>>>
>>> The create function takes only 2 arguments: the count and the array of
>>> pointers to the arguments. Among the first links in google I found this
>>> example: http://permalink.gmane.org/gmane.comp.db.rrdtool.devel/894
>>> There's an example on how to use the create function and many others.
>>> Note that the examples are for an older version of rrdtool so you may
>>> have to modify the code.
>>>
>>> regards,
>>>
>>> Pete
>>>
>>>
>>> _______________________________________________
>>> 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/20131128/65bece22/attachment-0001.htm
More information about the rrd-users
mailing list