projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
32ebb9e
)
snmp plugin: Fix handling of negative values.
author
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Mon, 9 Nov 2009 11:03:20 +0000
(12:03 +0100)
committer
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Mon, 9 Nov 2009 11:03:20 +0000
(12:03 +0100)
src/snmp.c
patch
|
blob
|
history
diff --git
a/src/snmp.c
b/src/snmp.c
index
23e199e
..
d8db544
100644
(file)
--- a/
src/snmp.c
+++ b/
src/snmp.c
@@
-724,7
+724,8
@@
static value_t csnmp_value_list_to_value (struct variable_list *vl, int type,
double scale, double shift)
{
value_t ret;
double scale, double shift)
{
value_t ret;
- uint64_t temp = 0;
+ uint64_t tmp_unsigned = 0;
+ int64_t tmp_signed = 0;
int defined = 1;
if ((vl->type == ASN_INTEGER)
int defined = 1;
if ((vl->type == ASN_INTEGER)
@@
-735,15
+736,17
@@
static value_t csnmp_value_list_to_value (struct variable_list *vl, int type,
#endif
|| (vl->type == ASN_GAUGE))
{
#endif
|| (vl->type == ASN_GAUGE))
{
- temp = (uint32_t) *vl->val.integer;
- DEBUG ("snmp plugin: Parsed int32 value is %"PRIu64".", temp);
+ tmp_unsigned = (uint32_t) *vl->val.integer;
+ tmp_signed = (int32_t) *vl->val.integer;
+ DEBUG ("snmp plugin: Parsed int32 value is %"PRIi64".", tmp_signed);
}
else if (vl->type == ASN_COUNTER64)
{
}
else if (vl->type == ASN_COUNTER64)
{
- temp = (uint32_t) vl->val.counter64->high;
- temp = temp << 32;
- temp += (uint32_t) vl->val.counter64->low;
- DEBUG ("snmp plugin: Parsed int64 value is %"PRIu64".", temp);
+ tmp_unsigned = (uint32_t) vl->val.counter64->high;
+ tmp_unsigned = tmp_unsigned << 32;
+ tmp_unsigned += (uint32_t) vl->val.counter64->low;
+ tmp_signed = (int64_t) tmp_unsigned;
+ DEBUG ("snmp plugin: Parsed int64 value is %"PRIu64".", tmp_unsigned);
}
else if (vl->type == ASN_OCTET_STR)
{
}
else if (vl->type == ASN_OCTET_STR)
{
@@
-801,13
+804,13
@@
static value_t csnmp_value_list_to_value (struct variable_list *vl, int type,
}
else if (type == DS_TYPE_COUNTER)
{
}
else if (type == DS_TYPE_COUNTER)
{
- ret.counter = t
emp
;
+ ret.counter = t
mp_unsigned
;
}
else if (type == DS_TYPE_GAUGE)
{
ret.gauge = NAN;
if (defined != 0)
}
else if (type == DS_TYPE_GAUGE)
{
ret.gauge = NAN;
if (defined != 0)
- ret.gauge = (scale * t
emp
) + shift;
+ ret.gauge = (scale * t
mp_signed
) + shift;
}
return (ret);
}
return (ret);