]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
added option to strip path away when using rrdcached
authorMartin Sperl <kernel@martin.sperl.org>
Mon, 5 May 2014 16:10:31 +0000 (16:10 +0000)
committerMartin Sperl <kernel@martin.sperl.org>
Mon, 5 May 2014 16:10:31 +0000 (16:10 +0000)
doc/rrdupdate.pod
src/rrd_client.c
src/rrd_client.h

index c5fdc34523dd9556c2e55c4ab3da5776f2149656..7be2da08913d3cbb116b932dd15cd37ab77f06bc 100644 (file)
@@ -120,6 +120,13 @@ If this environment variable is set it will have the same effect as specifying
 the C<--daemon> option on the command line. If both are present, the command
 line argument takes precedence.
 
+=item B<RRDCACHED_STRIPPATH>
+
+If this environment variable is set it will strip the leading string from the
+filename prior to sending the filename to rrdcached.
+This is mostly intended to allow rrdcached to work with xymon and cacti tools
+without having to modify those tools.
+
 =back
 
 =head1 EXAMPLES
index e2871e0eff5cefa924acc1ba0e68b4c3538faebc..6c7b46ceafb5a1be19307016afad9c7754d5b3c7 100644 (file)
@@ -84,6 +84,8 @@ static size_t inbuf_used = 0;
 static const char *get_path (const char *path, char *resolved_path) /* {{{ */
 {
   const char *ret = path;
+  const char *strip = getenv(ENV_RRDCACHED_STRIPPATH);
+  size_t len;
   int is_unix = 0;
 
   if ((path == NULL) || (resolved_path == NULL) || (sd_path == NULL))
@@ -104,7 +106,17 @@ static const char *get_path (const char *path, char *resolved_path) /* {{{ */
   {
     if (*path == '/') /* not absolute path */
     {
-      rrd_set_error ("absolute path names not allowed when talking "
+      /* if we are stripping, then check and remove the head */
+      if (strip) {
+             len = strlen(strip);
+             if (strncmp(path,strip,len)==0) {
+                     path += len;
+                     while (*path == '/')
+                             path++;
+                     return path;
+             }
+      } else
+        rrd_set_error ("absolute path names not allowed when talking "
           "to a remote daemon");
       return NULL;
     }
index af66d775c1cb0992957d621596dca37176db2be2..873f5b90f7d75b59cb55b42d80d51e0718e1da05 100644 (file)
@@ -40,7 +40,7 @@
 
 #define RRDCACHED_DEFAULT_PORT "42217"
 #define ENV_RRDCACHED_ADDRESS "RRDCACHED_ADDRESS"
-
+#define ENV_RRDCACHED_STRIPPATH "RRDCACHED_STRIPPATH"
 
 int rrdc_connect (const char *addr);
 int rrdc_is_connected(const char *daemon_addr);