From 8b0969137815ed206f9326cbed0b6c399bb914d0 Mon Sep 17 00:00:00 2001 From: oetiker Date: Thu, 25 Sep 2008 15:25:51 +0000 Subject: [PATCH] This adds support for
: in the rrd client library. Obviously this is required to take advantage of the server's ability to bind to a non-standard port -- kevin brintnall git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1522 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/doc/rrdcached.pod | 7 +++++++ program/doc/rrddump.pod | 6 ++---- program/doc/rrdfetch.pod | 6 ++---- program/doc/rrdflush.pod | 8 ++++---- program/doc/rrdgraph.pod | 6 ++---- program/doc/rrdinfo.pod | 6 ++---- program/doc/rrdlast.pod | 6 ++---- program/doc/rrdlastupdate.pod | 6 ++---- program/doc/rrdupdate.pod | 9 +++------ program/doc/rrdxport.pod | 10 ++++------ program/src/rrd_client.c | 9 ++++++++- 11 files changed, 38 insertions(+), 41 deletions(-) diff --git a/program/doc/rrdcached.pod b/program/doc/rrdcached.pod index 0f34dc20..bdb8949a 100644 --- a/program/doc/rrdcached.pod +++ b/program/doc/rrdcached.pod @@ -37,6 +37,13 @@ name are resolved using L. For network sockets, a port may be specified by using the form I
:I. The default port is 42217. +These formats are accepted: + + unix: + + + : + If the B<-l> option is not specified the default address, C, will be used. diff --git a/program/doc/rrddump.pod b/program/doc/rrddump.pod index 89e378bc..c26d31bc 100644 --- a/program/doc/rrddump.pod +++ b/program/doc/rrddump.pod @@ -47,10 +47,8 @@ the xml headers. Address of the L daemon. If specified, a C command is sent to the server before reading the RRD files. This allows B 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 manual. rrdtool dump --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd diff --git a/program/doc/rrdfetch.pod b/program/doc/rrdfetch.pod index d187b69e..0052aa65 100644 --- a/program/doc/rrdfetch.pod +++ b/program/doc/rrdfetch.pod @@ -53,10 +53,8 @@ specify the end time. Address of the L daemon. If specified, a C command is sent to the server before reading the RRD files. This allows B 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 manual. rrdtool fetch --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd AVERAGE diff --git a/program/doc/rrdflush.pod b/program/doc/rrdflush.pod index f691c211..a5938212 100644 --- a/program/doc/rrdflush.pod +++ b/program/doc/rrdflush.pod @@ -24,10 +24,10 @@ The name of the B that is to be written to disk. =item B<--daemon> I
-Address of the L daemon. If not specified, the RRDCACHED_ADDRESS -environment variable must be set (see below). To specify a UNIX domain socket -use the prefix C, see example below. Other addresses are interpreted as -normal network addresses, i.Ee. IPv4 or IPv6 addresses in most cases. +Address of the L 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 +manual. rrdtool flush --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd diff --git a/program/doc/rrdgraph.pod b/program/doc/rrdgraph.pod index 2c57dbb1..9a2f752d 100644 --- a/program/doc/rrdgraph.pod +++ b/program/doc/rrdgraph.pod @@ -271,10 +271,8 @@ when using graphv and even when using PRINT. Address of the L daemon. If specified, a C 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 manual. rrdtool graph [...] --daemon unix:/var/run/rrdcached.sock [...] diff --git a/program/doc/rrdinfo.pod b/program/doc/rrdinfo.pod index 2af411a5..00e5d165 100644 --- a/program/doc/rrdinfo.pod +++ b/program/doc/rrdinfo.pod @@ -25,10 +25,8 @@ The name of the B you want to examine. Address of the L daemon. If specified, a C command is sent to the server before reading the RRD files. This allows B 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 manual. rrdtool info --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd diff --git a/program/doc/rrdlast.pod b/program/doc/rrdlast.pod index ecec65a9..a8bf7574 100644 --- a/program/doc/rrdlast.pod +++ b/program/doc/rrdlast.pod @@ -22,10 +22,8 @@ The name of the B that contains the data. Address of the L daemon. If specified, a C command is sent to the server before reading the RRD files. This allows B 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 manual. rrdtool last --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd diff --git a/program/doc/rrdlastupdate.pod b/program/doc/rrdlastupdate.pod index db506abd..ecdff8da 100644 --- a/program/doc/rrdlastupdate.pod +++ b/program/doc/rrdlastupdate.pod @@ -22,10 +22,8 @@ The name of the B that contains the data. Address of the L daemon. If specified, a C command is sent to the server before reading the RRD files. This allows B 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 manual. rrdtool lastupdate --daemon unix:/var/run/rrdcached.sock /var/lib/rrd/foo.rrd diff --git a/program/doc/rrdupdate.pod b/program/doc/rrdupdate.pod index 82c66037..c285ee37 100644 --- a/program/doc/rrdupdate.pod +++ b/program/doc/rrdupdate.pod @@ -65,12 +65,9 @@ for the COMPUTE B. If given, B will try to connect to the caching daemon L at I
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
begins with C -then everything after this prefix will be considered to be a UNIX domain -socket, see L below. Otherwise the address is interpreted as network -address or node name as understood by L. One practical -consequence is that both, IPv4 and IPv6, may be used if the system supports -it. This option is available for the B command only. +instead of accessing the files directly. + +For a list of accepted formats, see the B<-l> option in the L manual. =item B|IB<:>I[B<:>I...] diff --git a/program/doc/rrdxport.pod b/program/doc/rrdxport.pod index 11159e47..d7e6bb34 100644 --- a/program/doc/rrdxport.pod +++ b/program/doc/rrdxport.pod @@ -53,14 +53,12 @@ See L documentation. Address of the L daemon. If specified, a C command is sent to the server before reading the RRD files. This allows B 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, see example below. Other -addresses are interpreted as normal network addresses, i.Ee. 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 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/program/src/rrd_client.c b/program/src/rrd_client.c index 11fb80dc..c573dad3 100644 --- a/program/src/rrd_client.c +++ b/program/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); -- 2.30.2