[rrd-users] newbie question: C(++) integration with rrd
Mr Dash Four
mr.dash.four at googlemail.com
Fri Sep 28 01:14:09 CEST 2012
I am trying to use a C or C++ program, which needs to use various rrd databases to log data periodically (this is done at pre-set intervals, which may vary, depending on the data which needs to be logged to the rrd database).
Two simple examples of such use would be:
1. Integration with netfilter and a specific (understand custom) ulogd2 plugin I have written speciffically for this purpose, which reacts to various events, like creating a connection originating from a specific interface and destined to a specific IP address/subnet, closing such a connection, send/receive packets based on pre-defined custom "filters" and so on - you get the idea.
2. Reading temperature/fan sensors and reacting to events (like overheating for example), read (and log) free/used memory on the host system, read (and log) current cache/web cache memory used/available, react (and log) to an event when a particular program/process is started, and so on.
For the second example above, I am aware that I could accomplish some of the those things by executing various shell scripts or separate programs via cron jobs, but that is not good enough for me, because I would like to have everything under one roof so to speak. Besides, for some of these events, the logging will be dependant on a particular system event occurring/being fired, which will then use my event handler, and it, in turn, will record the relevant data to rrd.
Although I am very comfortable using C and C++, I have only used RRDtool from bash and perl scripts up until now.
So, my question is this: Is there a way I could integrate my C(++) program and ulogd2 plugin with RRD and record the data I would normally do with the rrdtool via bash/perl scripts?
Looking into the rrdtool-devel package there are 3 header files, which may allow the use of such functions: rrd.h, rrd_client.h and rrd_format.h, but I am not sure whether this is all I would need. Besides, as I already pointed out above, my rrd experience is very limited, so a good starting point (a tutorial perhaps or a good man page describing how to integrate a C or C++ program into rrd) would be just about perfect.
Also, I don't want to reinvent the wheel if something like what I described above is already done. Thanks in advance!
More information about the rrd-users