TODO: Updated the todo file.
[collectd.git] / src / configfile.c
index e6b8ce8..706e2d1 100644 (file)
@@ -27,6 +27,8 @@
 #include "common.h"
 #include "plugin.h"
 #include "configfile.h"
+#include "types_list.h"
+#include "utils_threshold.h"
 
 #define ESCAPE_NULL(str) ((str) == NULL ? "(null)" : (str))
 
@@ -65,6 +67,7 @@ typedef struct cf_global_option_s
 /*
  * Prototypes of callback functions
  */
+static int dispatch_value_typesdb (const oconfig_item_t *ci);
 static int dispatch_value_plugindir (const oconfig_item_t *ci);
 static int dispatch_value_loadplugin (const oconfig_item_t *ci);
 
@@ -76,6 +79,7 @@ static cf_complex_callback_t *complex_callback_head = NULL;
 
 static cf_value_map_t cf_value_map[] =
 {
+       {"TypesDB",    dispatch_value_typesdb},
        {"PluginDir",  dispatch_value_plugindir},
        {"LoadPlugin", dispatch_value_loadplugin}
 };
@@ -83,15 +87,17 @@ static int cf_value_map_num = STATIC_ARRAY_LEN (cf_value_map);
 
 static cf_global_option_t cf_global_options[] =
 {
-       {"BaseDir",   NULL, PKGLOCALSTATEDIR},
-       {"PIDFile",   NULL, PIDFILE},
-       {"Hostname",  NULL, NULL},
-       {"Interval",  NULL, "10"},
-       {"ReadThreads", NULL, "5"},
-       {"TypesDB",   NULL, PLUGINDIR"/types.db"} /* FIXME: Configure path */
+       {"BaseDir",     NULL, PKGLOCALSTATEDIR},
+       {"PIDFile",     NULL, PIDFILE},
+       {"Hostname",    NULL, NULL},
+       {"FQDNLookup",  NULL, "false"},
+       {"Interval",    NULL, "10"},
+       {"ReadThreads", NULL, "5"}
 };
 static int cf_global_options_num = STATIC_ARRAY_LEN (cf_global_options);
 
+static int cf_default_typesdb = 1;
+
 /*
  * Functions to handle register/unregister, search, and other plugin related
  * stuff
@@ -175,10 +181,38 @@ static int dispatch_global_option (const oconfig_item_t *ci)
                tmp[127] = '\0';
                return (global_option_set (ci->key, tmp));
        }
+       else if (ci->values[0].type == OCONFIG_TYPE_BOOLEAN)
+       {
+               if (ci->values[0].value.boolean)
+                       return (global_option_set (ci->key, "true"));
+               else
+                       return (global_option_set (ci->key, "false"));
+       }
 
        return (-1);
 } /* int dispatch_global_option */
 
+static int dispatch_value_typesdb (const oconfig_item_t *ci)
+{
+       int i = 0;
+
+       assert (strcasecmp (ci->key, "TypesDB") == 0);
+
+       cf_default_typesdb = 0;
+
+       if (ci->values_num < 1)
+               return (-1);
+
+       for (i = 0; i < ci->values_num; ++i)
+       {
+               if (OCONFIG_TYPE_STRING != ci->values[i].type)
+                       continue;
+
+               read_types_list (ci->values[i].value.string);
+       }
+       return (0);
+} /* int dispatch_value_typesdb */
+
 static int dispatch_value_plugindir (const oconfig_item_t *ci)
 {
        assert (strcasecmp (ci->key, "PluginDir") == 0);
@@ -300,6 +334,8 @@ static int dispatch_block (oconfig_item_t *ci)
 {
        if (strcasecmp (ci->key, "Plugin") == 0)
                return (dispatch_block_plugin (ci));
+       else if (strcasecmp (ci->key, "Threshold") == 0)
+               return (ut_config (ci));
 
        return (0);
 }
@@ -582,5 +618,7 @@ int cf_read (char *filename)
                        dispatch_block (conf->children + i);
        }
 
+       if (cf_default_typesdb)
+               read_types_list (PLUGINDIR"/types.db"); /* FIXME: Configure path */
        return (0);
 } /* int cf_read */