Sets the type instance to use when dispatching the value to I<collectd>. If
unset, an empty string (no type instance) is used.
+=item B<Scale> I<Value>
+
+The values taken from collectd are multiplied by I<Value>. The field is optional
+and the default is B<1.0>.
+
+=item B<Shift> I<Value>
+
+I<Value> is added to values from collectd after they have been multiplied by
+B<Scale> value. The field is optional and the default value is B<0.0>.
+
=back
=item E<lt>B<Host> I<Name>E<gt> blocks
mb_mreg_type_t modbus_register_type;
char type[DATA_MAX_NAME_LEN];
char instance[DATA_MAX_NAME_LEN];
+ double scale;
+ double shift;
mb_data_t *next;
}; /* }}} */
#define CAST_TO_VALUE_T(ds, vt, raw) \
do { \
if ((ds)->ds[0].type == DS_TYPE_COUNTER) \
- (vt).counter = (counter_t)(raw); \
+ (vt).counter = (((counter_t)(raw) * ds[0].scale) + ds[0].shift); \
else if ((ds)->ds[0].type == DS_TYPE_GAUGE) \
- (vt).gauge = (gauge_t)(raw); \
+ (vt).gauge = (((gauge_t)(raw) * ds[0].scale) + ds[0].shift); \
else if ((ds)->ds[0].type == DS_TYPE_DERIVE) \
- (vt).derive = (derive_t)(raw); \
+ (vt).derive = (((derive_t)(raw) * ds[0].scale) + ds[0].shift); \
else /* if (ds->ds[0].type == DS_TYPE_ABSOLUTE) */ \
- (vt).absolute = (absolute_t)(raw); \
+ (vt).absolute = (((absolute_t)(raw) * ds[0].scale) + ds[0].shift); \
} while (0)
static int mb_read_data(mb_host_t *host, mb_slave_t *slave, /* {{{ */
data.name = NULL;
data.register_type = REG_TYPE_UINT16;
data.next = NULL;
+ data.scale = 1;
+ data.shift = 0;
status = cf_util_get_string(ci, &data.name);
if (status != 0)
else if (strcasecmp("Instance", child->key) == 0)
status = cf_util_get_string_buffer(child, data.instance,
sizeof(data.instance));
+ else if (strcasecmp("Scale", child->key) == 0)
+ status = cf_util_get_string_buffer(child, data.scale,
+ sizeof(data.scale));
+ else if (strcasecmp("Shift", child->key) == 0)
+ status = cf_util_get_string_buffer(child, data.shift,
+ sizeof(data.shift));
else if (strcasecmp("RegisterBase", child->key) == 0)
status = cf_util_get_int(child, &data.register_base);
else if (strcasecmp("RegisterType", child->key) == 0) {