[rrd-developers] [PATCH 6 of 7] * URL support for rrd_fetch

Peter Stamfest peter at stamfest.at
Mon Mar 7 20:28:08 CET 2011


# HG changeset patch
# User Peter Stamfest <peter at stamfest.at>
# Date 1299524684 -3600
# Node ID ca194c6734f0c3251b389c4603919f9687588691
# Parent  66ab2898ff2c8fdcdb03f1da63514ac55e616496
* URL support for rrd_fetch

diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c
--- a/src/rrd_fetch.c
+++ b/src/rrd_fetch.c
@@ -54,6 +54,7 @@
 
 #include "rrd_tool.h"
 #include "rrd_client.h"
+#include "rrd_source.h"
 
 #include "rrd_is_thread_safe.h"
 /* #define DEBUG */
@@ -75,6 +76,7 @@
     const char *cf;
     char *opt_daemon = NULL;
     int status = -1;
+    rrd_base_source_t *source = NULL;
 
     rrd_time_value_t start_tv, end_tv;
     char     *parsetime_error = NULL;
@@ -169,20 +171,28 @@
 
     cf = argv[optind + 1];
 
-    const char *addr = want_rrdc_connection(opt_daemon);
-    if (addr != NULL) {
-        rrdc_connection_t *conn = new_rrdc_connection(addr);
-        if (conn != NULL) {
-            status = rrdc_fetch (conn, argv[optind], cf, start, end, step,
+    source = parse_source_string(argv[optind]);
+    if (source) {
+        status = source->vtab->fetch_m(source, cf, start, end, step,
+                                       ds_cnt, ds_namv, data);
+
+        delete_source_obj(source);
+    } else {
+        const char *addr = want_rrdc_connection(opt_daemon);
+        if (addr != NULL) {
+            rrdc_connection_t *conn = new_rrdc_connection(addr);
+            if (conn != NULL) {
+                status = rrdc_fetch (conn, argv[optind], cf, start, end, step,
+                                     ds_cnt, ds_namv, data);
+                delete_rrdc_connection(conn);
+            }
+        }
+        else
+        {
+            status = rrd_fetch_r(argv[optind], cf, start, end, step,
                                  ds_cnt, ds_namv, data);
-            delete_rrdc_connection(conn);
         }
     }
-    else
-    {
-      status = rrd_fetch_r(argv[optind], cf, start, end, step,
-                           ds_cnt, ds_namv, data);
-    }
 
     if (opt_daemon != NULL) free(opt_daemon);
 



More information about the rrd-developers mailing list