author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 7 Feb 2011 07:46:04 +0000 (08:46 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 7 Feb 2011 07:46:04 +0000 (08:46 +0100) |
1 | 2 | |||
---|---|---|---|---|
src/collectd.conf.pod | patch | | diff1 | | diff2 | | blob | history |
src/modbus.c | patch | | diff1 | | diff2 | | blob | history |
diff --combined src/collectd.conf.pod
index 36efacd3e9e12626a072412267d8ba891fe23bf8,e91730eb0ba12aff2d5784f56975f4eff77fa300..ed979c48f5a5477b0712d2f73dd1bbd6181dd045
+++ b/src/collectd.conf.pod
B<RegisterType> has been set to B<Uint32> or B<Float>, this and the next
register will be read (the register number is increased by one).
- =item B<RegisterType> B<Uint16>|B<Uint32>|B<Float>
+ =item B<RegisterType> B<Int16>|B<Int32>|B<Uint16>|B<Uint32>|B<Float>
- Specifies what kind of data is returned by the device. If the type is B<Uint32>
- or B<Float>, two 16E<nbsp>bit registers will be read and the data is combined
- into one value. Defaults to B<Uint16>.
+ Specifies what kind of data is returned by the device. If the type is B<Int32>,
+ B<Uint32> or B<Float>, two 16E<nbsp>bit registers will be read and the data is
+ combined into one value. Defaults to B<Uint16>.
=item B<Type> I<Type>
=head2 Plugin C<swap>
The I<Swap plugin> collects information about used and available swap space. On
-I<Solaris>, the following options are available:
+I<Linux> and I<Solaris>, the following options are available:
=over 4
=item B<ReportByDevice> B<false>|B<true>
-Configures how to report physical swap devices. If set to B<false> is used (the
+Configures how to report physical swap devices. If set to B<false> (the
default), the summary over all swap devices is reported only, i.e. the globally
used and available space over all devices. If B<true> is configured, the used
and available space of each device will be reported separately.
-This option is only available if the I<Swap plugin> can use the L<swapctl(2)>
-mechanism under I<Solaris>.
+This option is only available if the I<Swap plugin> can read C</proc/swaps>
+(under Linux) or use the L<swapctl(2)> mechanism (under I<Solaris>).
=back
diff --combined src/modbus.c
index cad4b2cf4dd01b7b1a4e5352608823f24dfdf88d,a14ccedb291433d3ea9b76391f7e1b8f1e249c55..19848b0b330c056b71a82b92888631c0f1b59830
--- 1/src/modbus.c
--- 2/src/modbus.c
+++ b/src/modbus.c
/**
* collectd - src/modbus.c
- * Copyright (C) 2010 noris network AG
+ * Copyright (C) 2010,2011 noris network AG
*
* This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; only version 2 of the License is applicable.
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; only version 2.1 of the License is
+ * applicable.
*
* 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
- * General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
* Florian Forster <octo at noris.net>
*/
enum mb_register_type_e /* {{{ */
{
+ REG_TYPE_INT16,
+ REG_TYPE_INT32,
REG_TYPE_UINT16,
REG_TYPE_UINT32,
REG_TYPE_FLOAT
}
if ((ds->ds[0].type != DS_TYPE_GAUGE)
+ && (data->register_type != REG_TYPE_INT32)
&& (data->register_type != REG_TYPE_UINT32))
{
NOTICE ("Modbus plugin: The data source of type \"%s\" is %s, not gauge. "
}
memset (values, 0, sizeof (values));
- if ((data->register_type == REG_TYPE_UINT32)
+ if ((data->register_type == REG_TYPE_INT32)
+ || (data->register_type == REG_TYPE_UINT32)
|| (data->register_type == REG_TYPE_FLOAT))
values_num = 2;
else
CAST_TO_VALUE_T (ds, vt, float_value);
mb_submit (host, slave, data, vt);
}
+ else if (data->register_type == REG_TYPE_INT32)
+ {
+ union
+ {
+ uint32_t u32;
+ int32_t i32;
+ } v;
+ value_t vt;
+
+ v.u32 = (((uint32_t) values[0]) << 16)
+ | ((uint32_t) values[1]);
+ DEBUG ("Modbus plugin: mb_read_data: "
+ "Returned int32 value is %"PRIi32, v.i32);
+
+ CAST_TO_VALUE_T (ds, vt, v.i32);
+ mb_submit (host, slave, data, vt);
+ }
+ else if (data->register_type == REG_TYPE_INT16)
+ {
+ union
+ {
+ uint16_t u16;
+ int16_t i16;
+ } v;
+ value_t vt;
+
+ v.u16 = values[0];
+
+ DEBUG ("Modbus plugin: mb_read_data: "
+ "Returned int16 value is %"PRIi16, v.i16);
+
+ CAST_TO_VALUE_T (ds, vt, v.i16);
+ mb_submit (host, slave, data, vt);
+ }
else if (data->register_type == REG_TYPE_UINT32)
{
uint32_t v32;
value_t vt;
- v32 = (values[0] << 16) | values[1];
+ v32 = (((uint32_t) values[0]) << 16)
+ | ((uint32_t) values[1]);
DEBUG ("Modbus plugin: mb_read_data: "
"Returned uint32 value is %"PRIu32, v32);
status = cf_util_get_string_buffer (child, tmp, sizeof (tmp));
if (status != 0)
/* do nothing */;
+ else if (strcasecmp ("Int16", tmp) == 0)
+ data.register_type = REG_TYPE_INT16;
+ else if (strcasecmp ("Int32", tmp) == 0)
+ data.register_type = REG_TYPE_INT32;
else if (strcasecmp ("Uint16", tmp) == 0)
data.register_type = REG_TYPE_UINT16;
else if (strcasecmp ("Uint32", tmp) == 0)