summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1aa8032)
raw | patch | inline | side by side (parent: 1aa8032)
author | Florian Forster <octo@collectd.org> | |
Sun, 12 Jan 2014 10:04:56 +0000 (11:04 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 12 Jan 2014 10:04:56 +0000 (11:04 +0100) |
src/memory.c | patch | blob | history |
diff --git a/src/memory.c b/src/memory.c
index 7f477ec5fd350b4394cbd1ca4068252e4983a926..160e1ee7c08a836f544534d7c208a3400c426bfd 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
/**
* collectd - src/memory.c
- * Copyright (C) 2005-2008 Florian octo Forster
+ * Copyright (C) 2005-2014 Florian octo Forster
* Copyright (C) 2009 Simon Kuhnle
* Copyright (C) 2009 Manuel Sanmartin
*
static _Bool values_absolute = 1;
static _Bool values_percentage = 0;
-static const char *config_keys[] =
+static int memory_config (oconfig_item_t *ci) /* {{{ */
{
- "ValuesAbsolute",
- "ValuesPercentage"
-};
-static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+ int i;
-static int memory_config (const char *key, const char *value) /* {{{ */
-{
- if (strcasecmp (key, "ValuesAbsolute") == 0)
+ for (i = 0; i < ci->children_num; i++)
{
- if (IS_TRUE (value))
- values_absolute = 1;
+ oconfig_item_t *child = ci->children + i;
+ if (strcasecmp ("ValuesAbsolute", child->key) == 0)
+ cf_util_get_boolean (child, &values_absolute);
+ else if (strcasecmp ("ValuesPercentage", child->key) == 0)
+ cf_util_get_boolean (child, &values_percentage);
else
- values_absolute = 0;
-
- return (0);
+ ERROR ("memory plugin: Invalid configuration option: "
+ "\"%s\".", child->key);
}
- else if (strcasecmp (key, "ValuesPercentage") == 0)
- {
- if (IS_TRUE (value))
- values_percentage = 1;
- else
- values_percentage = 0;
- return (0);
- }
- return (-1);
+ return (0);
} /* }}} int memory_config */
static int memory_init (void)
void module_register (void)
{
- plugin_register_config ("memory", memory_config,
- config_keys, config_keys_num);
+ plugin_register_complex_config ("memory", memory_config);
plugin_register_init ("memory", memory_init);
plugin_register_read ("memory", memory_read);
} /* void module_register */