se->vl.values[ds_index].counter += value.counter;
else if (ds_type == DS_TYPE_GAUGE)
se->vl.values[ds_index].gauge = value.gauge;
+ else if (ds_type == DS_TYPE_DERIVE)
+ se->vl.values[ds_index].DERIVE += value.derive;
+ else if (ds_type == DS_TYPE_ABSOLUTE)
+ se->vl.values[ds_index].ABSOLUTE = value.absolute;
+
se->flags |= (0x01 << ds_index);
/* Check if all values have been set and submit if so. */
value_t value_counter;
value_t value_gauge;
+ value_t value_derive;
/* Fill in `host', `name', `value_counter', and `value_gauge' according to
* the value type, or return with an error. */
name = msg_uint.metric_id.name;
value_counter.counter = (counter_t) msg_uint.ui;
value_gauge.gauge = (gauge_t) msg_uint.ui;
+ value_derive.derive = (derive_t) msg_uint.ui;
break;
}
if ((endptr == msg_string.str) || (errno != 0))
value_gauge.gauge = NAN;
+ endptr = NULL;
+ errno = 0;
+ value_derive.derive = (derive_t) strtoll (msg_string.str,
+ &endptr, /* base = */ 0);
+ if ((endptr == msg_string.str) || (errno != 0))
+ value_derive.derive = 0;
+
break;
}
name = msg_float.metric_id.name;
value_counter.counter = (counter_t) msg_float.f;
value_gauge.gauge = (gauge_t) msg_float.f;
+ value_derive.derive = (derive_t) msg_float.f;
break;
}
name = msg_double.metric_id.name;
value_counter.counter = (counter_t) msg_double.d;
value_gauge.gauge = (gauge_t) msg_double.d;
+ value_derive.derive = (derive_t) msg_double.d;
break;
}
default:
map = metric_lookup (name);
if (map != NULL)
+ {
+ value_t val_copy;
+
+ val_copy = value_counter;
+ if (map->ds_type == DS_TYPE_GAUGE)
+ val_copy = value_gauge;
+ else if (map->ds_type == DS_TYPE_DERIVE)
+ val_copy = value_derive;
+
return (staging_entry_update (host, name,
map->type, map->type_instance,
map->ds_index, map->ds_type,
- (map->ds_type == DS_TYPE_COUNTER) ? value_counter : value_gauge));
+ val_copy));
+ }
DEBUG ("gmond plugin: Cannot find a translation for %s.", name);
return (-1);