[rrd-developers] Re: c API for rrd

Beat Zahnd beat.zahnd at phim.unibe.ch
Mon Nov 22 17:13:36 MET 2004

siddharth khullar wrote:

> Hi guys,
> I am new to RRD tool. I want to collect data from a database (MySQL or 
> Oracle or any other database) and create a RRD file and update it 
> periodically (every 5 mins) such that I will be able to monitor the my 
> system (The values of which are available in the database from which I want 
> to generate the RRD file).

Here a function which stores the pressure in one of our ultra-high 
vacuum chambers in a rrd file:

/* global data */
unsigned int sensor_stat;
double pres;

void store_data() {
   char buf[128];
   char r_name[] = "/var/scada/stabil_ion.rrd";
   char r_buf[1024];
   char *r_update[3] = {"update", r_name, r_buf};

   if(isnan(pres) || sensor_stat != 1)
     sprintf(buf, "U");
     snprintf(buf, 128, "%e", pres);

   snprintf(r_buf, 64, "N:%s", buf);

   rrd_update(3, r_update);
   if(rrd_test_error()) {
     device_warning("Stabil-Ion RRD error", rrd_get_error());

Compilation/linking flags: -lrrd

I create the rrd files from a Makefile during 'make install' using 
'rrdtool create':

         rrdtool create $@ \
           --step 10 \
           DS:pres:GAUGE:60:U:U \

Regards, Beat

Physics Institute
University of Bern                   phone  +41 31 631 3466
Sidlerstrasse 5                      fax    +41 31 631 4405
CH-3012 Bern (Switzerland)  mailto:beat.zahnd at phim.unibe.ch

Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-developers mailing list