Instance "input-2"
</Data>
+ <Datagroup "device-type-1"
+ Collect "voltage-input-1"
+ Collect "voltage-input-2"
+ </Datagroup>
+
<Host "modbus.example.com">
Address "192.168.0.42"
Port "502"
Collect "voltage-input-1"
Collect "voltage-input-2"
</Slave>
+
+ <Slave 2>
+ Instance "power-supply"
+ Datagroup "device-type-1"
+ </Slave>
</Host>
=over 4
=back
+=item E<lt>B<Datagroup> I<Name>E<gt> blocks
+
+Datagroup blocks define a group of B<Data>-definitions. Datagroups can be used
+to collect the same data from a number of similar devices.
+
+Within E<lt>DatagroupE<nbsp>/E<gt> blocks, the following options are allowed:
+
+=over 4
+
+=item B<Collect> I<DataName>
+
+Specifies which data to include in the datagroup. I<DataName> must be the same
+string as the I<Name> argument passed to a B<Data> block. You can specify this
+option multiple times to include more than one value in the datagroup. All
+values in the datagroup will be collected from the devices that use is. At
+least one B<Collect> option is mandatory.
+
+=back
+
=item E<lt>B<Host> I<Name>E<gt> blocks
Host blocks are used to specify to which hosts to connect and what data to read
Specifies which data to retrieve from the device. I<DataName> must be the same
string as the I<Name> argument passed to a B<Data> block. You can specify this
option multiple times to collect more than one value from a slave. At least one
-B<Collect> option is mandatory.
+B<Collect> or B<Datagroup> option is mandatory.
+
+=item B<Datagroup> I<DatagroupName>
+
+Specifies which data to retrieve from the device. I<DatagroupName> must be the
+same string as the I<Name> argument passed to a B<Datagroup> block. All data
+specified in the Datagroup definition will be retrieved from the device. You
+can specify this option multiple or combine it with the B<Collect> option. At
+least one B<Collect> or B<Datagroup> option is mandatory.
=back
/**
* collectd - src/modbus.c
* Copyright (C) 2010 noris network AG
+ * Copyright (C) 2011 Universiteit Gent
*
* 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
*
* Authors:
* Florian Forster <octo at noris.net>
+ * Ivo De Decker <ivo.dedecker at ugent.be>
**/
#include "collectd.h"
mb_data_t *next;
}; /* }}} */
-struct mb_dataset_s;
-typedef struct mb_dataset_s mb_dataset_t;
-struct mb_dataset_s /* {{{ */
+struct mb_datagroup_s;
+typedef struct mb_datagroup_s mb_datagroup_t;
+struct mb_datagroup_s /* {{{ */
{
char *name;
mb_data_t *collect;
- mb_dataset_t *next;
+ mb_datagroup_t *next;
}; /* }}} */
struct mb_slave_s /* {{{ */
* Global variables
*/
static mb_data_t *data_definitions = NULL;
-static mb_dataset_t *data_sets = NULL;
+static mb_datagroup_t *data_groups = NULL;
/*
* Functions
return (data_copy (dst, ptr));
} /* }}} int data_copy_by_name */
-static mb_dataset_t *dataset_get_by_name (mb_dataset_t *src, /* {{{ */
+static mb_datagroup_t *datagroup_get_by_name (mb_datagroup_t *src, /* {{{ */
const char *name)
{
- mb_dataset_t *ptr;
+ mb_datagroup_t *ptr;
if (name == NULL)
return (NULL);
return (ptr);
return (NULL);
-} /* }}} mb_dataset_t *dataset_get_by_name */
+} /* }}} mb_datagroup_t *datagroup_get_by_name */
-static int dataset_append (mb_dataset_t **dst, mb_dataset_t *src) /* {{{ */
+static int datagroup_append (mb_datagroup_t **dst, mb_datagroup_t *src) /* {{{ */
{
- mb_dataset_t *ptr;
+ mb_datagroup_t *ptr;
if ((dst == NULL) || (src == NULL))
return (EINVAL);
ptr->next = src;
return (0);
-} /* }}} int dataset_append */
+} /* }}} int datagroup_append */
-/* Copy a single mb_dataset_t and append it to another list. */
-static int dataset_copy (mb_dataset_t **dst, const mb_dataset_t *src) /* {{{ */
+/* Copy a single mb_datagroup_t and append it to another list. */
+static int datagroup_copy (mb_datagroup_t **dst, const mb_datagroup_t *src) /* {{{ */
{
- mb_dataset_t *tmp;
+ mb_datagroup_t *tmp;
int status;
if ((dst == NULL) || (src == NULL))
return (ENOMEM);
}
- status = dataset_append (dst, tmp);
+ status = datagroup_append (dst, tmp);
if (status != 0)
{
sfree (tmp->name);
}
return (0);
-} /* }}} int dataset_copy */
+} /* }}} int datagroup_copy */
/* Read functions */
data_copy_by_name (&slave->collect, data_definitions, buffer);
status = 0; /* continue after failure. */
}
- else if (strcasecmp ("Dataset", child->key) == 0)
+ else if (strcasecmp ("Datagroup", child->key) == 0)
{
char buffer[1024];
- mb_dataset_t *ds;
+ mb_datagroup_t *ds;
status = cf_util_get_string_buffer (child, buffer, sizeof (buffer));
if (status == 0) {
- ds = dataset_get_by_name (data_sets, buffer);
+ ds = datagroup_get_by_name (data_groups, buffer);
if (ds) {
mb_data_t *data;
for (data = ds->collect; data != NULL; data = data->next)
} /* }}} int mb_config_add_host */
-static int mb_config_add_dataset (oconfig_item_t *ci) /* {{{ */
+static int mb_config_add_datagroup (oconfig_item_t *ci) /* {{{ */
{
- mb_dataset_t dataset;
+ mb_datagroup_t datagroup;
int status;
int i;
- memset (&dataset, 0, sizeof (dataset));
- dataset.name = NULL;
- dataset.collect = NULL;
- dataset.next = NULL;
+ memset (&datagroup, 0, sizeof (datagroup));
+ datagroup.name = NULL;
+ datagroup.collect = NULL;
+ datagroup.next = NULL;
- status = cf_util_get_string (ci, &dataset.name);
+ status = cf_util_get_string (ci, &datagroup.name);
for (i = 0; i < ci->children_num; i++)
{
char buffer[1024];
status = cf_util_get_string_buffer (child, buffer, sizeof (buffer));
if (status == 0) {
- data_copy_by_name (&dataset.collect, data_definitions, buffer);
+ data_copy_by_name (&datagroup.collect, data_definitions, buffer);
}
status = 0; /* continue after failure. */
}
break;
} /* for (i = 0; i < ci->children_num; i++) */
- if ((status == 0) && (dataset.collect == NULL))
+ if ((status == 0) && (datagroup.collect == NULL))
status = EINVAL;
if (status == 0)
- dataset_copy (&data_sets, &dataset);
+ datagroup_copy (&data_groups, &datagroup);
return (status);
-} /* }}} int mb_config_add_dataset */
+} /* }}} int mb_config_add_datagroup */
static int mb_config (oconfig_item_t *ci) /* {{{ */
{
mb_config_add_data (child);
else if (strcasecmp ("Host", child->key) == 0)
mb_config_add_host (child);
- else if (strcasecmp ("Dataset", child->key) == 0)
- mb_config_add_dataset (child);
+ else if (strcasecmp ("Datagroup", child->key) == 0)
+ mb_config_add_datagroup (child);
else
ERROR ("Modbus plugin: Unknown configuration option: %s", child->key);
}