From: Florian Forster Date: Tue, 10 Nov 2009 19:17:36 +0000 (+0100) Subject: Merge branch 'collectd-4.7' into collectd-4.8 X-Git-Tag: collectd-4.8.2~6 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=179242223f25937fc528e89ef433a80d4d614611;p=collectd.git Merge branch 'collectd-4.7' into collectd-4.8 Conflicts: src/snmp.c --- 179242223f25937fc528e89ef433a80d4d614611 diff --cc src/snmp.c index 7568cf67,5ccc93ab..ee402638 --- a/src/snmp.c +++ b/src/snmp.c @@@ -783,45 -793,25 +786,47 @@@ static value_t csnmp_value_list_to_valu } } - /* Check if an error occurred */ - if ((vl->val.string == NULL) || (endptr == (char *) vl->val.string)) + if (status != 0) { - if (type == DS_TYPE_COUNTER) - ret.counter = 0; - else if (type == DS_TYPE_GAUGE) - ret.gauge = NAN; + switch (type) + { + case DS_TYPE_COUNTER: + case DS_TYPE_DERIVE: + case DS_TYPE_ABSOLUTE: + memset (&ret, 0, sizeof (ret)); + break; + + case DS_TYPE_GAUGE: + ret.gauge = NAN; + break; + + default: + ERROR ("snmp plugin: csnmp_value_list_to_value: Unknown " + "data source type: %i.", type); + ret.gauge = NAN; + } } - } + } /* if (vl->type == ASN_OCTET_STR) */ else if (type == DS_TYPE_COUNTER) - ret.counter = temp; + { + ret.counter = tmp_unsigned; + } else if (type == DS_TYPE_GAUGE) { ret.gauge = NAN; if (defined != 0) - ret.gauge = (scale * temp) + shift; + ret.gauge = (scale * tmp_signed) + shift; } + else if (type == DS_TYPE_DERIVE) + ret.derive = (derive_t) temp; + else if (type == DS_TYPE_ABSOLUTE) + ret.absolute = (absolute_t) temp; + else + { + ERROR ("snmp plugin: csnmp_value_list_to_value: Unknown data source " + "type: %i.", type); + ret.gauge = NAN; + } return (ret); } /* value_t csnmp_value_list_to_value */