author | Florian Forster <github@nospam.verplant.org> | |
Sun, 11 Mar 2012 12:11:33 +0000 (05:11 -0700) | ||
committer | Florian Forster <github@nospam.verplant.org> | |
Sun, 11 Mar 2012 12:11:33 +0000 (05:11 -0700) |
Fix race condition in the Perl plugin.
src/collectd.conf.pod | patch | blob | history | |
src/libcollectdclient/client.c | patch | blob | history | |
src/network.c | patch | blob | history | |
src/snmp.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 62374b625cb204ab9aa3f6dc9c6a8f73fa8c5e37..74249d7f7ff3008185d11fef57a3af70bb5dd8d7 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
multicast group is C<239.192.74.66>. The default I<UDP> port is B<25826>.
Both, B<Server> and B<Listen> can be used as single option or as block. When
-used as block, given options are valid for this socket only. For example:
+used as block, given options are valid for this socket only. The following
+example will export the metrics twice: Once to an "internal" server (without
+encryption and signing) and one to an external server (with cryptographic
+signature):
<Plugin "network">
+ # Export to an internal server
+ # (demonstrates usage without additional options)
Server "collectd.internal.tld"
+
+ # Export to an external server
+ # (demonstrates usage with signature options)
<Server "collectd.external.tld">
SecurityLevel "sign"
Username "myhostname"
index 0c748ba7fa47e3b30f1d2a8d5c30dffdfd70d3e3..2f427a832927112b4d7ea0945f37e8b3a9ea9427 100644 (file)
if (ret_values_names != NULL)
*ret_values_names = values_names;
+ lcc_response_free (&res);
+
return (0);
} /* }}} int lcc_getval */
diff --git a/src/network.c b/src/network.c
index 700b27f09c0613e45b3d01e46c3847eb98da3af6..06cc2c5012554dfae90be5c2c8411574cb3039ba 100644 (file)
--- a/src/network.c
+++ b/src/network.c
exp_size = 3 * sizeof (uint16_t)
+ pkg_numval * (sizeof (uint8_t) + sizeof (value_t));
- if ((buffer_len < 0) || (buffer_len < exp_size))
+ if (buffer_len < exp_size)
{
WARNING ("network plugin: parse_part_values: "
"Packet too short: "
uint16_t pkg_length;
- if ((buffer_len < 0) || ((size_t) buffer_len < exp_size))
+ if (buffer_len < exp_size)
{
WARNING ("network plugin: parse_part_number: "
"Packet too short: "
uint16_t pkg_length;
- if ((buffer_len < 0) || (buffer_len < header_size))
+ if (buffer_len < header_size)
{
WARNING ("network plugin: parse_part_string: "
"Packet too short: "
diff --git a/src/snmp.c b/src/snmp.c
index 1c2828c1fb2469494e84aafebb6a77d01fadcde9..5c6cce267854f1d41504eea4ef854bade8eb9f9b 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
value_t ret;
uint64_t tmp_unsigned = 0;
int64_t tmp_signed = 0;
- int defined = 1;
+ _Bool defined = 1;
+ /* Set to true when the original SNMP type appears to have been signed. */
+ _Bool prefer_signed = 0;
if ((vl->type == ASN_INTEGER)
|| (vl->type == ASN_UINTEGER)
{
tmp_unsigned = (uint32_t) *vl->val.integer;
tmp_signed = (int32_t) *vl->val.integer;
- DEBUG ("snmp plugin: Parsed int32 value is %"PRIi64".", tmp_signed);
+
+ if ((vl->type == ASN_INTEGER)
+ || (vl->type == ASN_GAUGE))
+ prefer_signed = 1;
+
+ DEBUG ("snmp plugin: Parsed int32 value is %"PRIu64".", tmp_unsigned);
}
else if (vl->type == ASN_COUNTER64)
{
}
else if (type == DS_TYPE_GAUGE)
{
- ret.gauge = NAN;
- if (defined != 0)
+ if (!defined)
+ ret.gauge = NAN;
+ else if (prefer_signed)
ret.gauge = (scale * tmp_signed) + shift;
+ else
+ ret.gauge = (scale * tmp_unsigned) + shift;
}
else if (type == DS_TYPE_DERIVE)
- ret.derive = (derive_t) tmp_signed;
+ {
+ if (prefer_signed)
+ ret.derive = (derive_t) tmp_signed;
+ else
+ ret.derive = (derive_t) tmp_unsigned;
+ }
else if (type == DS_TYPE_ABSOLUTE)
+ {
ret.absolute = (absolute_t) tmp_unsigned;
+ }
else
{
ERROR ("snmp plugin: csnmp_value_list_to_value: Unknown data source "