From b578a6b9f331c11ebc70d153494c7b6113990ee7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 7 Sep 2010 16:44:26 +0200 Subject: [PATCH] Add stub for config handling wrt. data providers. --- share/collection.conf | 4 ++++ src/Makefile.am | 3 ++- src/data_provider.c | 33 +++++++++++++++++++++++++++++++++ src/data_provider.h | 3 +++ src/dp_rrdtool.c | 2 +- src/dp_rrdtool.h | 32 ++++++++++++++++++++++++++++++++ src/graph_config.c | 3 +++ 7 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 src/data_provider.c create mode 100644 src/dp_rrdtool.h diff --git a/share/collection.conf b/share/collection.conf index c2d501e..3634446 100644 --- a/share/collection.conf +++ b/share/collection.conf @@ -1,3 +1,7 @@ + + DataDir "/var/lib/collectd/rrd" + + Host "/any/" Plugin "cpu" diff --git a/src/Makefile.am b/src/Makefile.am index d5c74e1..741f7e5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,8 @@ collection_fcgi_SOURCES = main.c \ action_show_graph_json.c action_show_graph_json.h \ action_show_instance.c action_show_instance.h \ common.c common.h \ - dp_rrdtool.c \ + data_provider.c data_provider.h \ + dp_rrdtool.c dp_rrdtool.h \ filesystem.c filesystem.h \ graph_types.h \ graph.c graph.h \ diff --git a/src/data_provider.c b/src/data_provider.c new file mode 100644 index 0000000..bf4cf88 --- /dev/null +++ b/src/data_provider.c @@ -0,0 +1,33 @@ +/** + * collection4 - data_provider.c + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + +#include "data_provider.h" +#include "dp_rrdtool.h" + +int data_provider_config (const oconfig_item_t *ci) /* {{{ */ +{ + /* FIXME: Actually determine which data provider to call. */ + return (dp_rrdtool_config (ci)); +} /* }}} int data_provider_config */ + +/* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/data_provider.h b/src/data_provider.h index a5e9c76..6dbcd1e 100644 --- a/src/data_provider.h +++ b/src/data_provider.h @@ -25,6 +25,7 @@ #define DATA_PROVIDER_H 1 #include "graph_types.h" +#include "oconfig.h" #include @@ -63,5 +64,7 @@ struct data_provider_s }; typedef struct data_provider_s data_provider_t; +int data_provider_config (const oconfig_item_t *ci); + #endif /* DATA_PROVIDER_H */ /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/dp_rrdtool.c b/src/dp_rrdtool.c index 214603d..b72e512 100644 --- a/src/dp_rrdtool.c +++ b/src/dp_rrdtool.c @@ -351,7 +351,7 @@ static int print_graph (void *priv, return (-1); } /* }}} int print_graph */ -int dp_rrdtool_config (oconfig_item_t *ci) +int dp_rrdtool_config (const oconfig_item_t *ci) { /* {{{ */ dp_rrdtool_t *conf; diff --git a/src/dp_rrdtool.h b/src/dp_rrdtool.h new file mode 100644 index 0000000..5e1246b --- /dev/null +++ b/src/dp_rrdtool.h @@ -0,0 +1,32 @@ +/** + * collection4 - dp_rrdtool.h + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + +#ifndef DP_RRDTOOL_H +#define DP_RRDTOOL_H 1 + +#include "oconfig.h" + +int dp_rrdtool_config (const oconfig_item_t *ci); + +#endif /* DP_RRDTOOL_H */ +/* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/graph_config.c b/src/graph_config.c index 4f58df0..6d2402b 100644 --- a/src/graph_config.c +++ b/src/graph_config.c @@ -34,6 +34,7 @@ #include "graph_list.h" #include "oconfig.h" #include "common.h" +#include "data_provider.h" #ifndef CONFIGFILE # define CONFIGFILE "/etc/collection.conf" @@ -52,6 +53,8 @@ static int dispatch_config (const oconfig_item_t *ci) /* {{{ */ child = ci->children + i; if (strcasecmp ("Graph", child->key) == 0) graph_config_add (child); + else if (strcasecmp ("DataProvider", child->key) == 0) + data_provider_config (child); else { DEBUG ("Unknown config option: %s", child->key); -- 2.30.2