From cd194ba57239af2c596b24c81ca022a5e264364b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 17 Oct 2016 09:40:22 +0200 Subject: [PATCH] Improve the RRD client API (#742) * RRD client: Add an interface allowing for multiple client connections. Add a client object which resembles a persistent connection to a server. Multiple such objects may be used in parallel. The old, "simple" interface is a wrapper around the new interface now, using a default client connection. As before, this can only be used for one connection. --- doc/librrd.pod | 70 +++++- src/rrd_client.c | 612 +++++++++++++++++++++++++++++++---------------- src/rrd_client.h | 90 +++++-- 3 files changed, 538 insertions(+), 234 deletions(-) diff --git a/doc/librrd.pod b/doc/librrd.pod index ef877422..141dbcfc 100644 --- a/doc/librrd.pod +++ b/doc/librrd.pod @@ -255,33 +255,75 @@ The following functions are used to connected to an rrdcached instance, either via a unix or inet address, and create, update, or gather statistics about a specified RRD database file. -All of the following functions are specified in the C -header file. +There are two different interfaces: The B family of functions +operate on a user-provided client object (B) and support +multiple concurrent connections to rrdcache instances. The simpler B +family of functions handles connections transparently but can only be used +for one connection at a time. + +All of the following functions and data types are specified in the +C header file. =over 4 -=item B +=item B + +Create a new client connection object. If specified, connect to the daemon at +C. The connection can later be changed by calling +B. + +=item B + +Close a client connection and destroy the object by freeing all dynamically +allocated memory. After calling this function, C can no longer be +used. + +=item B + +=item B -Connect to a running rrdcached instance, specified via C. +Connect to a running rrdcached instance, specified via C. Any +previous connection will be closed. If C is C, it defaults +to the value of the C environment address. + +=item B + +Return a boolean int if the client is connected to the server. + +=item B + +Returns the server address belonging to the current connection. =item B Return a boolean int to determine if the client is connected to the rrdcache daemon specified by the C parameter. +=item B + +=item B + +Check the client connection by pinging the remote side. + =item B Return a boolean int if any daemon connections are connected. +=item B + =item B -Disconnect gracefully from all present daemon connections. +Disconnect gracefully from the present daemon connection. + +=item B =item B Update the RRD C via the rrdcached. Where C is the number of values to update and C are the new values to add. +=item B + =item B Grab rrd info of the RRD C from the connected cache daemon. @@ -314,10 +356,14 @@ This function returns an rrd_info_t structure of the following format: struct rrd_info_t *next; } rrd_info_t; +=item B + =item B Grab the unix epoch of the last time RRD C was updated. +=item B + =item B Get the first value of the first sample of the RRD C, @@ -325,6 +371,8 @@ of the C RRA (Round Robin Archive) index number. The RRA index number can be determined by pulling the rrd_info_t off the RRD. +=item B + =item B Create RRD database of path C. @@ -334,9 +382,11 @@ the definitions of the data sources and RRAs C. Lastly whether or not to overwrite an existing RRD if one is found with the same filename; C. +=item B + =item B -Create and RRD database in the daemon. B has the same +Create an RRD database in the daemon. B has the same parameters as B with two added parameters of; C and C