[rrd-developers] [PATCH] Added <address>:<port> capability to the client side; updated docs to reflect.

kevin brintnall kbrint at rufus.net
Thu Sep 25 10:10:09 CEST 2008


---
 doc/rrdcached.pod     |    7 +++++++
 doc/rrddump.pod       |    6 ++----
 doc/rrdfetch.pod      |    6 ++----
 doc/rrdflush.pod      |    8 ++++----
 doc/rrdgraph.pod      |    6 ++----
 doc/rrdinfo.pod       |    6 ++----
 doc/rrdlast.pod       |    6 ++----
 doc/rrdlastupdate.pod |    6 ++----
 doc/rrdupdate.pod     |    9 +++------
 doc/rrdxport.pod      |   10 ++++------
 src/rrd_client.c      |    9 ++++++++-
 11 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/doc/rrdcached.pod b/doc/rrdcached.pod
index 0f34dc2..bdb8949 100644
--- a/doc/rrdcached.pod
+++ b/doc/rrdcached.pod
@@ -37,6 +37,13 @@ name are resolved using L<getaddrinfo>.
 For network sockets, a port may be specified by using the form
 I<address>:I<port>.  The default port is 42217.
 
+These formats are accepted:
+
+   unix:</path/to/unix.sock>
+   </path/to/unix.sock>
+   <hostname-or-ip>
+   <hostname-or-ip>:<port>
+
 If the B<-l> option is not specified the default address,
 C<unix:/tmp/rrdcached.sock>, will be used.
 
diff --git a/doc/rrddump.pod b/doc/rrddump.pod
index 89e378b..c26d31b 100644
--- a/doc/rrddump.pod
+++ b/doc/rrddump.pod
@@ -47,10 +47,8 @@ the xml headers.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows B<rrdtool> to return
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
  rrdtool dump --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd
 
diff --git a/doc/rrdfetch.pod b/doc/rrdfetch.pod
index d187b69..0052aa6 100644
--- a/doc/rrdfetch.pod
+++ b/doc/rrdfetch.pod
@@ -53,10 +53,8 @@ specify the end time.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows B<rrdtool> to return
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
  rrdtool fetch --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE
 
diff --git a/doc/rrdflush.pod b/doc/rrdflush.pod
index f691c21..a593821 100644
--- a/doc/rrdflush.pod
+++ b/doc/rrdflush.pod
@@ -24,10 +24,10 @@ The name of the B<RRD> that is to be written to disk.
 
 =item B<--daemon> I<address>
 
-Address of the L<rrdcached> daemon. If not specified, the RRDCACHED_ADDRESS
-environment variable must be set (see below). To specify a UNIX domain socket
-use the prefix C<unix:>, see example below. Other addresses are interpreted as
-normal network addresses, i.E<nbsp>e. IPv4 or IPv6 addresses in most cases.
+Address of the L<rrdcached> daemon. If not specified, the
+RRDCACHED_ADDRESS environment variable must be set (see below).  For a
+list of accepted formats, see the B<-l> option in the L<rrdcached>
+manual.
 
  rrdtool flush --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd
 
diff --git a/doc/rrdgraph.pod b/doc/rrdgraph.pod
index 2c57dbb..9a2f752 100644
--- a/doc/rrdgraph.pod
+++ b/doc/rrdgraph.pod
@@ -271,10 +271,8 @@ when using graphv and even when using PRINT.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows the graph to contain
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
  rrdtool graph [...] --daemon unix:/var/run/rrdcached.sock [...]
 
diff --git a/doc/rrdinfo.pod b/doc/rrdinfo.pod
index 2af411a..00e5d16 100644
--- a/doc/rrdinfo.pod
+++ b/doc/rrdinfo.pod
@@ -25,10 +25,8 @@ The name of the B<RRD> you want to examine.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows B<rrdtool> to return
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
  rrdtool info --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd
 
diff --git a/doc/rrdlast.pod b/doc/rrdlast.pod
index ecec65a..a8bf757 100644
--- a/doc/rrdlast.pod
+++ b/doc/rrdlast.pod
@@ -22,10 +22,8 @@ The name of the B<RRD> that contains the data.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows B<rrdtool> to return
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
  rrdtool last --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd
 
diff --git a/doc/rrdlastupdate.pod b/doc/rrdlastupdate.pod
index db506ab..ecdff8d 100644
--- a/doc/rrdlastupdate.pod
+++ b/doc/rrdlastupdate.pod
@@ -22,10 +22,8 @@ The name of the B<RRD> that contains the data.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows B<rrdtool> to return
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
  rrdtool lastupdate --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd
 
diff --git a/doc/rrdupdate.pod b/doc/rrdupdate.pod
index 82c6603..c285ee3 100644
--- a/doc/rrdupdate.pod
+++ b/doc/rrdupdate.pod
@@ -65,12 +65,9 @@ for the COMPUTE B<DST>.
 If given, B<RRDTool> will try to connect to the caching daemon L<rrdcached>
 at I<address> and will fail if the connection cannot be established. If the
 connection is successfully established the values will be sent to the daemon
-instead of accessing the files directly. If I<address> begins with C<unix:>
-then everything after this prefix will be considered to be a UNIX domain
-socket, see L<EXAMPLES> below. Otherwise the address is interpreted as network
-address or node name as understood by L<getaddrinfo>. One practical
-consequence is that both, IPv4 and IPv6, may be used if the system supports
-it. This option is available for the B<update> command only.
+instead of accessing the files directly.
+
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
 =item B<N>|I<timestamp>B<:>I<value>[B<:>I<value>...]
 
diff --git a/doc/rrdxport.pod b/doc/rrdxport.pod
index 11159e4..d7e6bb3 100644
--- a/doc/rrdxport.pod
+++ b/doc/rrdxport.pod
@@ -53,14 +53,12 @@ See L<rrdgraph> documentation.
 
 Address of the L<rrdcached> daemon. If specified, a C<flush> command is sent
 to the server before reading the RRD files. This allows B<rrdtool> to return
-fresh data even if the daemon is configured to cache values for a long time. To
-specify a UNIX domain socket use the prefix C<unix:>, see example below. Other
-addresses are interpreted as normal network addresses, i.E<nbsp>e. IPv4 or IPv6
-addresses in most cases.
+fresh data even if the daemon is configured to cache values for a long time.
+For a list of accepted formats, see the B<-l> option in the L<rrdcached> manual.
 
- rrdtool xport --daemon unix:/var/run/rrdcached.sock ...
+  rrdtool xport --daemon unix:/var/run/rrdcached.sock ...
 
-=item B<--enumds> 
+=item B<--enumds>
 
 The generated xml should contain the data values in enumerated tags.
 
diff --git a/src/rrd_client.c b/src/rrd_client.c
index 11fb80d..c573dad 100644
--- a/src/rrd_client.c
+++ b/src/rrd_client.c
@@ -352,6 +352,7 @@ static int rrdc_connect_network (const char *addr) /* {{{ */
   struct addrinfo ai_hints;
   struct addrinfo *ai_res;
   struct addrinfo *ai_ptr;
+  char *port;
 
   assert (addr != NULL);
   assert (sd == -1);
@@ -365,8 +366,14 @@ static int rrdc_connect_network (const char *addr) /* {{{ */
   ai_hints.ai_family = AF_UNSPEC;
   ai_hints.ai_socktype = SOCK_STREAM;
 
+  port = rindex(addr, ':');
+  if (port != NULL)
+    *port++ = '\0';
+
   ai_res = NULL;
-  status = getaddrinfo (addr, RRDCACHED_DEFAULT_PORT, &ai_hints, &ai_res);
+  status = getaddrinfo (addr,
+                        port == NULL ? RRDCACHED_DEFAULT_PORT : port,
+                        &ai_hints, &ai_res);
   if (status != 0)
     return (status);
 
-- 
1.6.0.2



More information about the rrd-developers mailing list