[{
name => 'data_source_name',
- type => DS_TYPE_COUNTER || DS_TYPE_GAUGE || DS_TYPE_DERIVE || DS_TYPE_ABSOLUTE,
+ type => DS_TYPE_COUNTER || DS_TYPE_GAUGE || DS_TYPE_DERIVE,
min => value || undef,
max => value || undef
}, ...]
=item B<DS_TYPE_DERIVE>
-=item B<DS_TYPE_ABSOLUTE>
-
=back
=item B<:log>
=item type
A string that is equal to either of the variables B<DS_TYPE_COUNTER>,
-B<DS_TYPE_GAUGE>, B<DS_TYPE_DERIVE> or B<DS_TYPE_ABSOLUTE>.
+B<DS_TYPE_GAUGE>, or B<DS_TYPE_DERIVE>.
=item min
=item B<StoreRates> B<true>|B<false> (Publish only)
-Determines whether or not C<COUNTER>, C<DERIVE> and C<ABSOLUTE> data sources
-are converted to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the
-default), no conversion is performed. Otherwise the conversion is performed
-using the internal value cache.
+Determines whether or not C<COUNTER> and C<DERIVE> data sources are converted
+to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the default), no
+conversion is performed. Otherwise the conversion is performed using the
+internal value cache.
Please note that currently this option is only used if the B<Format> option has
been set to B<JSON>.
=item B<StoreRates> B<true>|B<false>
-Determines whether or not C<COUNTER>, C<DERIVE> and C<ABSOLUTE> data sources
-are converted to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the
-default), no conversion is performed. Otherwise the conversion is performed
-using the internal value cache.
+Determines whether or not C<COUNTER> and C<DERIVE> data sources are converted
+to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the default), no
+conversion is performed. Otherwise the conversion is performed using the
+internal value cache.
Please note that currently this option is only used if the B<Format> option has
been set to B<JSON>.
=item B<AbsoluteSet>
The matched number is a counter. Simply I<sets> the internal counter to this
-value. Variants exist for C<COUNTER>, C<DERIVE>, and C<ABSOLUTE> data sources.
+value. Variants exist for C<COUNTER> and C<DERIVE> data sources.
=item B<GaugeAdd>
=item B<StoreRates> B<true>|B<false>
-Determines whether or not C<COUNTER>, C<DERIVE> and C<ABSOLUTE> data sources
-are converted to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the
-default), no conversion is performed. Otherwise the conversion is performed
-using the internal value cache.
+Determines whether or not C<COUNTER> and C<DERIVE> data sources are converted
+to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the default), no
+conversion is performed. Otherwise the conversion is performed using the
+internal value cache.
Please note that currently this option is only used if the B<Format> option has
been set to B<JSON>.
for (size_t i = 0; i < ds->ds_num; i++) {
if ((ds->ds[i].type != DS_TYPE_COUNTER) &&
(ds->ds[i].type != DS_TYPE_GAUGE) &&
- (ds->ds[i].type != DS_TYPE_DERIVE) &&
- (ds->ds[i].type != DS_TYPE_ABSOLUTE)) {
+ (ds->ds[i].type != DS_TYPE_DERIVE)) {
sfree(rates);
return -1;
}
} else if (ds->ds[i].type == DS_TYPE_DERIVE) {
status = snprintf(buffer + offset, buffer_len - offset, ",%" PRIi64,
vl->values[i].derive);
- } else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) {
- status = snprintf(buffer + offset, buffer_len - offset, ",%" PRIu64,
- vl->values[i].absolute);
}
if ((status < 1) || (status >= (buffer_len - offset))) {
dstype |= UTILS_MATCH_CF_DERIVE_INC;
else
dstype = 0;
- } else if (strncasecmp("Absolute", ci->values[0].value.string,
- strlen("Absolute")) == 0) {
- dstype = UTILS_MATCH_DS_TYPE_ABSOLUTE;
- if (strcasecmp("AbsoluteSet", ci->values[0].value.string) ==
- 0) /* Absolute DS is reset-on-read so no sense doin anything else but
- set */
- dstype |= UTILS_MATCH_CF_ABSOLUTE_SET;
- else
- dstype = 0;
}
else {
(derive_t)strtoll(node_value,
/* endptr = */ NULL, /* base = */ 0);
break;
- case DS_TYPE_ABSOLUTE:
- vl->values[index].absolute =
- (absolute_t)strtoull(node_value,
- /* endptr = */ NULL, /* base = */ 0);
- break;
case DS_TYPE_GAUGE:
vl->values[index].gauge = (gauge_t)strtod(node_value,
/* endptr = */ NULL);
if (store_percentage)
vl->values[0].gauge *= sum ? (100.0 / sum) : NAN;
break;
- case DS_TYPE_ABSOLUTE:
- vl->values[0].absolute = va_arg(ap, absolute_t);
- break;
case DS_TYPE_COUNTER:
vl->values[0].counter = va_arg(ap, counter_t);
break;
#define DS_TYPE_COUNTER 0
#define DS_TYPE_GAUGE 1
#define DS_TYPE_DERIVE 2
-#define DS_TYPE_ABSOLUTE 3
#define DS_TYPE_TO_STRING(t) \
(t == DS_TYPE_COUNTER) \
? "counter" \
- : (t == DS_TYPE_GAUGE) \
- ? "gauge" \
- : (t == DS_TYPE_DERIVE) \
- ? "derive" \
- : (t == DS_TYPE_ABSOLUTE) ? "absolute" : "unknown"
+ : (t == DS_TYPE_GAUGE) ? "gauge" \
+ : (t == DS_TYPE_DERIVE) ? "derive" : "unknown"
#ifndef LOG_ERR
#define LOG_ERR 3
typedef unsigned long long counter_t;
typedef double gauge_t;
typedef int64_t derive_t;
-typedef uint64_t absolute_t;
union value_u {
counter_t counter;
gauge_t gauge;
derive_t derive;
- absolute_t absolute;
};
typedef union value_u value_t;
* "store_type":
*
* - "gauge_t" when "DS_TYPE_GAUGE"
- * - "absolute_t" when "DS_TYPE_ABSOLUTE"
* - "derive_t" when "DS_TYPE_DERIVE"
* - "counter_t" when "DS_TYPE_COUNTER"
*
dsrc->type = DS_TYPE_COUNTER;
else if (strcasecmp(fields[1], "DERIVE") == 0)
dsrc->type = DS_TYPE_DERIVE;
- else if (strcasecmp(fields[1], "ABSOLUTE") == 0)
- dsrc->type = DS_TYPE_ABSOLUTE;
else {
- ERROR("(fields[1] = %s) != (GAUGE || COUNTER || DERIVE || ABSOLUTE)",
- fields[1]);
+ ERROR("(fields[1] = %s) != (GAUGE || COUNTER || DERIVE)", fields[1]);
return -1;
}
ce->values_raw[i].derive = vl->values[i].derive;
break;
- case DS_TYPE_ABSOLUTE:
- ce->values_gauge[i] = NAN;
- if (vl->interval > 0)
- ce->values_gauge[i] =
- ((double)vl->values[i].absolute) / CDTIME_T_TO_DOUBLE(vl->interval);
- ce->values_raw[i].absolute = vl->values[i].absolute;
- break;
-
default:
/* This shouldn't happen. */
ERROR("uc_insert: Don't know how to handle data source type %i.",
ce->values_raw[i].derive = vl->values[i].derive;
} break;
- case DS_TYPE_ABSOLUTE:
- ce->values_gauge[i] = ((double)vl->values[i].absolute) /
- (CDTIME_T_TO_DOUBLE(vl->time - ce->last_time));
- ce->values_raw[i].absolute = vl->values[i].absolute;
- break;
-
default:
/* This shouldn't happen. */
pthread_mutex_unlock(&cache_lock);
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;
else
assert(23 == 42);
if (map != NULL) {
value_t val_copy;
- if ((map->ds_type == DS_TYPE_COUNTER) || (map->ds_type == DS_TYPE_ABSOLUTE))
+ if (map->ds_type == DS_TYPE_COUNTER)
val_copy = value_counter;
else if (map->ds_type == DS_TYPE_GAUGE)
val_copy = value_gauge;
break;
}
- default: { return -1; }
+ default: {
+ return -1;
+ }
}
return 0;
case DS_TYPE_DERIVE:
v->set_derive(vl->values[i].derive);
break;
- case DS_TYPE_ABSOLUTE:
- v->set_absolute(vl->values[i].absolute);
- break;
default:
ERROR("grpc: invalid value type (%d)", value_type);
return grpc::Status(grpc::StatusCode::INTERNAL,
return ctoj_jdouble_to_number(jvm_env, (jdouble)value.gauge);
if (ds_type == DS_TYPE_DERIVE)
return ctoj_jlong_to_number(jvm_env, (jlong)value.derive);
- if (ds_type == DS_TYPE_ABSOLUTE)
- return ctoj_jlong_to_number(jvm_env, (jlong)value.absolute);
else
return NULL;
} /* }}} jobject ctoj_value_to_number */
if (ds_type == DS_TYPE_DERIVE)
(*ret_value).derive = (derive_t)tmp_long;
- else if (ds_type == DS_TYPE_ABSOLUTE)
- (*ret_value).absolute = (absolute_t)tmp_long;
else
(*ret_value).counter = (counter_t)tmp_long;
}
host->is_connected = true;
return 0;
} /* }}} int mb_init_connection */
- /* #endif LEGACY_LIBMODBUS */
+/* #endif LEGACY_LIBMODBUS */
#else /* if !LEGACY_LIBMODBUS */
/* Version 2.9.2 */
(vt).gauge = (((gauge_t)(raw)*scale) + shift); \
else if ((ds)->ds[0].type == DS_TYPE_DERIVE) \
(vt).derive = (((derive_t)(raw)*scale) + shift); \
- else /* if (ds->ds[0].type == DS_TYPE_ABSOLUTE) */ \
- (vt).absolute = (((absolute_t)(raw)*scale) + shift); \
} while (0)
static int mb_read_data(mb_host_t *host, mb_slave_t *slave, /* {{{ */
if (data->register_type == REG_TYPE_FLOAT) {
float float_value;
- value_t vt;
+ value_t vt = {0};
float_value = mb_register_to_float(values[0], values[1]);
DEBUG("Modbus plugin: mb_read_data: "
mb_submit(host, slave, data, vt);
} else if (data->register_type == REG_TYPE_FLOAT_CDAB) {
float float_value;
- value_t vt;
+ value_t vt = {0};
float_value = mb_register_to_float(values[1], values[0]);
DEBUG("Modbus plugin: mb_read_data: "
uint32_t u32;
int32_t i32;
} v;
- value_t vt;
+ value_t vt = {0};
v.u32 = (((uint32_t)values[0]) << 16) | ((uint32_t)values[1]);
DEBUG("Modbus plugin: mb_read_data: "
uint32_t u32;
int32_t i32;
} v;
- value_t vt;
+ value_t vt = {0};
v.u32 = (((uint32_t)values[1]) << 16) | ((uint32_t)values[0]);
DEBUG("Modbus plugin: mb_read_data: "
uint16_t u16;
int16_t i16;
} v;
- value_t vt;
+ value_t vt = {0};
v.u16 = values[0];
mb_submit(host, slave, data, vt);
} else if (data->register_type == REG_TYPE_UINT32) {
uint32_t v32;
- value_t vt;
+ value_t vt = {0};
v32 = (((uint32_t)values[0]) << 16) | ((uint32_t)values[1]);
DEBUG("Modbus plugin: mb_read_data: "
mb_submit(host, slave, data, vt);
} else if (data->register_type == REG_TYPE_UINT32_CDAB) {
uint32_t v32;
- value_t vt;
+ value_t vt = {0};
v32 = (((uint32_t)values[1]) << 16) | ((uint32_t)values[0]);
DEBUG("Modbus plugin: mb_read_data: "
mb_submit(host, slave, data, vt);
} else if (data->register_type == REG_TYPE_UINT64) {
uint64_t v64;
- value_t vt;
+ value_t vt = {0};
v64 = (((uint64_t)values[0]) << 48) | (((uint64_t)values[1]) << 32) |
(((uint64_t)values[2]) << 16) | (((uint64_t)values[3]));
uint64_t u64;
int64_t i64;
} v;
- value_t vt;
+ value_t vt = {0};
v.u64 = (((uint64_t)values[0]) << 48) | (((uint64_t)values[1]) << 32) |
(((uint64_t)values[2]) << 16) | ((uint64_t)values[3]);
mb_submit(host, slave, data, vt);
} else /* if (data->register_type == REG_TYPE_UINT16) */
{
- value_t vt;
+ value_t vt = {0};
DEBUG("Modbus plugin: mb_read_data: "
"Returned uint16 value is %" PRIu16,
pkg_values[i].derive = htonll(vl->values[i].derive);
break;
- case DS_TYPE_ABSOLUTE:
- pkg_values[i].absolute = htonll(vl->values[i].absolute);
- break;
-
default:
free(pkg_values_types);
free(pkg_values);
pkg_values[i].derive = (derive_t)ntohll(pkg_values[i].derive);
break;
- case DS_TYPE_ABSOLUTE:
- pkg_values[i].absolute = (absolute_t)ntohll(pkg_values[i].absolute);
- break;
-
default:
NOTICE("network plugin: parse_part_values: "
"Don't know how to handle data source type %" PRIu8,
return 0;
} /* }}} int parse_part_sign_sha256 */
- /* #endif HAVE_GCRYPT_H */
+/* #endif HAVE_GCRYPT_H */
#else /* if !HAVE_GCRYPT_H */
static int parse_part_sign_sha256(sockent_t *se, /* {{{ */
return 0;
} /* }}} int parse_part_encr_aes256 */
- /* #endif HAVE_GCRYPT_H */
+/* #endif HAVE_GCRYPT_H */
#else /* if !HAVE_GCRYPT_H */
static int parse_part_encr_aes256(sockent_t *se, /* {{{ */
ERROR("network plugin: setsockopt (bind-if): %s", STRERRNO);
return -1;
}
- /* #endif HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */
+ /* #endif HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */
#else
WARNING("network plugin: Cannot set the interface on a unicast "
{"Collectd::DS_TYPE_COUNTER", DS_TYPE_COUNTER},
{"Collectd::DS_TYPE_GAUGE", DS_TYPE_GAUGE},
{"Collectd::DS_TYPE_DERIVE", DS_TYPE_DERIVE},
- {"Collectd::DS_TYPE_ABSOLUTE", DS_TYPE_ABSOLUTE},
{"Collectd::LOG_ERR", LOG_ERR},
{"Collectd::LOG_WARNING", LOG_WARNING},
{"Collectd::LOG_NOTICE", LOG_NOTICE},
ds->type = SvIV(*tmp);
if ((DS_TYPE_COUNTER != ds->type) && (DS_TYPE_GAUGE != ds->type) &&
- (DS_TYPE_DERIVE != ds->type) && (DS_TYPE_ABSOLUTE != ds->type)) {
+ (DS_TYPE_DERIVE != ds->type)) {
log_err("hv2data_source: Invalid DS type.");
return -1;
}
value[i].gauge = SvNV(*tmp);
else if (DS_TYPE_DERIVE == ds->ds[i].type)
value[i].derive = SvIV(*tmp);
- else if (DS_TYPE_ABSOLUTE == ds->ds[i].type)
- value[i].absolute = SvIV(*tmp);
} else {
return 0;
}
val = newSVnv(vl->values[i].gauge);
else if (DS_TYPE_DERIVE == ds->ds[i].type)
val = newSViv(vl->values[i].derive);
- else if (DS_TYPE_ABSOLUTE == ds->ds[i].type)
- val = newSViv(vl->values[i].absolute);
if (NULL == av_store(values, i, val)) {
av_undef(values);
if ((ds->ds[i].type != DS_TYPE_GAUGE) &&
(ds->ds[i].type != DS_TYPE_COUNTER) &&
- (ds->ds[i].type != DS_TYPE_DERIVE) &&
- (ds->ds[i].type != DS_TYPE_ABSOLUTE)) {
+ (ds->ds[i].type != DS_TYPE_DERIVE)) {
log_err("c_psql_write: Unknown data source type: %i", ds->ds[i].type);
sfree(rates);
return NULL;
(uint64_t)vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
status = ssnprintf(str_ptr, str_len, ",%" PRIi64, vl->values[i].derive);
- else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
- status = ssnprintf(str_ptr, str_len, ",%" PRIu64, vl->values[i].absolute);
if (status < 1) {
str_len = 0;
" name, type, min and max value.\n"
" 'name' is a string.\n"
" 'type' is a string that is equal to either DS_TYPE_COUNTER,\n"
- " DS_TYPE_GAUGE, DS_TYPE_DERIVE or DS_TYPE_ABSOLUTE.\n"
+ " DS_TYPE_GAUGE, or DS_TYPE_DERIVE.\n"
" 'min' and 'max' are either a float or None.";
static char flush_doc[] = "flush([plugin][, timeout][, identifier]) -> None\n"
} else if (ds->ds[i].type == DS_TYPE_DERIVE) {
PyList_SetItem(list, i,
PyLong_FromLongLong(value_list->values[i].derive));
- } else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) {
- PyList_SetItem(
- list, i, PyLong_FromUnsignedLongLong(value_list->values[i].absolute));
} else {
Py_BEGIN_ALLOW_THREADS;
ERROR("cpy_write_callback: Unknown value type %d.", ds->ds[i].type);
DS_TYPE_TO_STRING(DS_TYPE_GAUGE));
PyModule_AddStringConstant(module, "DS_TYPE_DERIVE",
DS_TYPE_TO_STRING(DS_TYPE_DERIVE));
- PyModule_AddStringConstant(module, "DS_TYPE_ABSOLUTE",
- DS_TYPE_TO_STRING(DS_TYPE_ABSOLUTE));
return 0;
}
Py_XDECREF(num);
}
break;
- case DS_TYPE_ABSOLUTE:
- /* This might overflow without raising an exception.
- * Not much we can do about it */
- num = PyNumber_Long(item); /* New reference. */
- if (num != NULL) {
- value[i].absolute = PyLong_AsUnsignedLongLong(num);
- Py_XDECREF(num);
- }
- break;
default:
free(value);
PyErr_Format(PyExc_RuntimeError, "unknown data type %d for %s",
Py_XDECREF(num);
}
break;
- case DS_TYPE_ABSOLUTE:
- /* This might overflow without raising an exception.
- * Not much we can do about it */
- num = PyNumber_Long(item); /* New reference. */
- if (num != NULL) {
- value[i].absolute = PyLong_AsUnsignedLongLong(num);
- Py_XDECREF(num);
- }
- break;
default:
free(value);
PyErr_Format(PyExc_RuntimeError, "unknown data type %d for %s",
else if (src_type == VAL_TYPE_REAL)
vl->derive = (derive_t)value->real;
break;
- case DS_TYPE_ABSOLUTE:
- if (src_type == VAL_TYPE_STR)
- vl->absolute = strtoull(value->string, NULL, 0);
- else if (src_type == VAL_TYPE_INT)
- vl->absolute = (absolute_t)value->integer;
- else if (src_type == VAL_TYPE_REAL)
- vl->absolute = (absolute_t)value->real;
- break;
default:
ERROR(PLUGIN_NAME ": Invalid data set type. Cannot convert value");
return -EINVAL;
EXPECT_EQ_INT(0, ret);
OK(vl.counter == 1);
- val.string = "1";
- src_type = VAL_TYPE_STR;
- dst_type = DS_TYPE_ABSOLUTE;
- ret = redfish_convert_val(&val, src_type, &vl, dst_type);
- EXPECT_EQ_INT(0, ret);
- OK(vl.absolute == 1);
-
- val.integer = 1;
- src_type = VAL_TYPE_INT;
- dst_type = DS_TYPE_ABSOLUTE;
- ret = redfish_convert_val(&val, src_type, &vl, dst_type);
- EXPECT_EQ_INT(0, ret);
- OK(vl.absolute == 1);
-
- val.real = 1.0;
- src_type = VAL_TYPE_REAL;
- dst_type = DS_TYPE_ABSOLUTE;
- ret = redfish_convert_val(&val, src_type, &vl, dst_type);
- EXPECT_EQ_INT(0, ret);
- OK(vl.absolute == 1);
-
return 0;
}
case DS_TYPE_DERIVE:
val.gauge = (derive_t)rr->integer;
break;
- case DS_TYPE_ABSOLUTE:
- val.gauge = (absolute_t)rr->integer;
- break;
}
break;
case REDIS_REPLY_STRING:
int offset = status;
for (size_t i = 0; i < ds->ds_num; i++) {
- if ((ds->ds[i].type != DS_TYPE_COUNTER) &&
- (ds->ds[i].type != DS_TYPE_GAUGE) &&
- (ds->ds[i].type != DS_TYPE_DERIVE) &&
- (ds->ds[i].type != DS_TYPE_ABSOLUTE))
- return -1;
-
if (ds->ds[i].type == DS_TYPE_COUNTER) {
status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64,
(uint64_t)vl->values[i].counter);
} else if (ds->ds[i].type == DS_TYPE_DERIVE) {
status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIi64,
vl->values[i].derive);
- } else /* if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */ {
- status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64,
- vl->values[i].absolute);
+ } else {
+ return -1;
}
if ((status < 1) || (status >= (buffer_len - offset)))
return status;
} /* int srrd_update */
- /* #endif HAVE_THREADSAFE_LIBRRD */
+/* #endif HAVE_THREADSAFE_LIBRRD */
#else /* !HAVE_THREADSAFE_LIBRRD */
static int srrd_update(char *filename, char *template, int argc,
offset = status;
for (size_t i = 0; i < ds->ds_num; i++) {
- if ((ds->ds[i].type != DS_TYPE_COUNTER) &&
- (ds->ds[i].type != DS_TYPE_GAUGE) &&
- (ds->ds[i].type != DS_TYPE_DERIVE) &&
- (ds->ds[i].type != DS_TYPE_ABSOLUTE))
- return -1;
-
if (ds->ds[i].type == DS_TYPE_COUNTER)
status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64,
(uint64_t)vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIi64,
vl->values[i].derive);
- else /*if (ds->ds[i].type == DS_TYPE_ABSOLUTE) */
- status = ssnprintf(buffer + offset, buffer_len - offset, ":%" PRIu64,
- vl->values[i].absolute);
+ else
+ return -1;
if ((status < 1) || (status >= (buffer_len - offset)))
return -1;
status = ssnprintf(buffer, buffer_len, "%u:%" PRIu64, (unsigned)tt,
(uint64_t)vl->values[0].counter);
break;
- case DS_TYPE_ABSOLUTE:
- status = ssnprintf(buffer, buffer_len, "%u:%" PRIu64, (unsigned)tt,
- vl->values[0].absolute);
- break;
default:
return EINVAL;
}
switch (type) {
case DS_TYPE_COUNTER:
case DS_TYPE_DERIVE:
- case DS_TYPE_ABSOLUTE:
memset(&ret, 0, sizeof(ret));
break;
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 "
"type: %i.",
case DS_TYPE_COUNTER:
*value = (long)((val->counter * scale) + shift);
break;
- case DS_TYPE_ABSOLUTE:
- *value = (long)((val->absolute * scale) + shift);
- break;
case DS_TYPE_DERIVE:
*value = (long)((val->derive * scale) + shift);
break;
cm->flags |= UTILS_MATCH_CF_DERIVE_INC;
else
cm->flags = 0;
- } else if (strncasecmp("Absolute", ds_type, strlen("Absolute")) == 0) {
- cm->flags = UTILS_MATCH_DS_TYPE_ABSOLUTE;
- if (strcasecmp("AbsoluteSet", ds_type) == 0)
- cm->flags |= UTILS_MATCH_CF_ABSOLUTE_SET;
- else
- cm->flags = 0;
} else {
cm->flags = 0;
}
return 0;
} /* }}} int ts_invoke_derive */
-static int ts_invoke_absolute(const data_set_t *ds, value_list_t *vl, /* {{{ */
- ts_data_t *data, int dsrc_index) {
- uint64_t curr_absolute;
- double rate;
- int status;
-
- /* Required meta data */
- double int_fraction;
- char key_int_fraction[128];
-
- curr_absolute = (uint64_t)vl->values[dsrc_index].absolute;
-
- snprintf(key_int_fraction, sizeof(key_int_fraction),
- "target_scale[%p,%i]:int_fraction", (void *)data, dsrc_index);
-
- int_fraction = 0.0;
-
- /* Query the meta data */
- status = uc_meta_data_get_double(vl, key_int_fraction, &int_fraction);
- if (status != 0)
- int_fraction = 0.0;
-
- rate = ((double)curr_absolute) / CDTIME_T_TO_DOUBLE(vl->interval);
-
- /* Modify the rate. */
- if (!isnan(data->factor))
- rate *= data->factor;
- if (!isnan(data->offset))
- rate += data->offset;
-
- /* Calculate the new absolute. */
- int_fraction += (rate * CDTIME_T_TO_DOUBLE(vl->interval));
- curr_absolute = (uint64_t)int_fraction;
- int_fraction -= ((double)curr_absolute);
-
- vl->values[dsrc_index].absolute = (absolute_t)curr_absolute;
-
- /* Update to the new absolute value */
- uc_meta_data_add_double(vl, key_int_fraction, int_fraction);
-
- return 0;
-} /* }}} int ts_invoke_absolute */
-
static int ts_config_set_double(double *ret, oconfig_item_t *ci) /* {{{ */
{
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) {
ts_invoke_gauge(ds, vl, data, i);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
ts_invoke_derive(ds, vl, data, i);
- else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
- ts_invoke_absolute(ds, vl, data, i);
else
ERROR("Target `scale': Ignoring unknown data source type %i",
ds->ds[i].type);
-absolute value:ABSOLUTE:0:U
apache_bytes value:DERIVE:0:U
apache_connections value:GAUGE:0:65535
apache_idle_workers value:GAUGE:0:65535
=item
-I<ds-type> may be B<DERIVE>, B<GAUGE>, or B<COUNTER>. For historic reasons a
-type called B<ABSOLUTE> is also supported, but its use is strongly discouraged,
-and it should not be used for new metric type definitions.
+I<ds-type> may be B<DERIVE>, B<GAUGE>, or B<COUNTER>.
=item
strbuf_printf(&buf, ":%" PRIu64, (uint64_t)vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
strbuf_printf(&buf, ":%" PRIi64, vl->values[i].derive);
- else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
- strbuf_printf(&buf, ":%" PRIu64, vl->values[i].absolute);
else {
ERROR("format_values: Unknown data source type: %i", ds->ds[i].type);
sfree(rates);
ret_value->derive = (derive_t)strtoll(value, &endptr, 0);
break;
- case DS_TYPE_ABSOLUTE:
- ret_value->absolute = (absolute_t)strtoull(value, &endptr, 0);
- break;
-
default:
sfree(value);
P_ERROR("parse_value: Invalid data source type: %i.", ds_type);
/* Counter and absolute can't handle negative rates. Reset "last time"
* to zero, so that the next valid rate will re-initialize the
* structure. */
- if ((rate < 0.0) &&
- ((ds_type == DS_TYPE_COUNTER) || (ds_type == DS_TYPE_ABSOLUTE))) {
+ if ((rate < 0.0) && (ds_type == DS_TYPE_COUNTER)) {
memset(state, 0, sizeof(*state));
return EINVAL;
}
} else if (ds_type == DS_TYPE_COUNTER) {
state->last_value.counter = (counter_t)rate;
state->residual = rate - ((gauge_t)state->last_value.counter);
- } else if (ds_type == DS_TYPE_ABSOLUTE) {
- state->last_value.absolute = (absolute_t)rate;
- state->residual = rate - ((gauge_t)state->last_value.absolute);
} else {
assert(23 == 42);
}
state->last_value.counter += delta_counter;
state->residual = delta_gauge - ((gauge_t)delta_counter);
- } else if (ds_type == DS_TYPE_ABSOLUTE) {
- absolute_t delta_absolute = (absolute_t)delta_gauge;
-
- state->last_value.absolute = delta_absolute;
- state->residual = delta_gauge - ((gauge_t)delta_absolute);
} else {
assert(23 == 42);
}
*ret_rate = ((gauge_t)diff) / ((gauge_t)interval);
break;
}
- case DS_TYPE_ABSOLUTE: {
- absolute_t diff = value.absolute;
- *ret_rate = ((gauge_t)diff) / ((gauge_t)interval);
- break;
- }
default:
return EINVAL;
}
BUFFER_ADD("%" PRIu64, (uint64_t)vl->values[ds_num].counter);
else if (ds->ds[ds_num].type == DS_TYPE_DERIVE)
BUFFER_ADD("%" PRIi64, vl->values[ds_num].derive);
- else if (ds->ds[ds_num].type == DS_TYPE_ABSOLUTE)
- BUFFER_ADD("%" PRIu64, vl->values[ds_num].absolute);
else {
P_ERROR("gr_format_values: Unknown data source type: %i",
ds->ds[ds_num].type);
BUFFER_ADD("%" PRIu64, (uint64_t)vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
BUFFER_ADD("%" PRIi64, vl->values[i].derive);
- else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
- BUFFER_ADD("%" PRIu64, vl->values[i].absolute);
else {
ERROR("format_json: Unknown data source type: %i", ds->ds[i].type);
sfree(rates);
BUFFER_ADD("%" PRIu64, CDTIME_T_TO_MS(vl->time));
BUFFER_ADD(",");
BUFFER_ADD("%" PRIi64, vl->values[ds_idx].derive);
- } else if (ds->ds[ds_idx].type == DS_TYPE_ABSOLUTE) {
- BUFFER_ADD("[[");
- BUFFER_ADD("%" PRIu64, CDTIME_T_TO_MS(vl->time));
- BUFFER_ADD(",");
- BUFFER_ADD("%" PRIu64, vl->values[ds_idx].absolute);
} else {
ERROR("format_kairosdb: Unknown data source type: %i", ds->ds[ds_idx].type);
sfree(rates);
ssnprintf(integer, sizeof(integer), "%llu", diff);
break;
}
- case DS_TYPE_ABSOLUTE: {
- ssnprintf(integer, sizeof(integer), "%" PRIu64, v.absolute);
- break;
- }
default: {
ERROR("format_typed_value: unknown value type %d.", ds_type);
return EINVAL;
static int format_metric_kind(yajl_gen gen, int ds_type) {
switch (ds_type) {
case DS_TYPE_GAUGE:
- case DS_TYPE_ABSOLUTE:
return json_string(gen, "GAUGE");
case DS_TYPE_COUNTER:
case DS_TYPE_DERIVE:
return -1;
}
- data->values_num++;
- } else if (data->ds_type & UTILS_MATCH_DS_TYPE_ABSOLUTE) {
- absolute_t value;
- char *endptr = NULL;
-
- if (matches_num < 2)
- return -1;
-
- value = (absolute_t)strtoull(matches[1], &endptr, 0);
- if (matches[1] == endptr)
- return -1;
-
- if (data->ds_type & UTILS_MATCH_CF_ABSOLUTE_SET)
- data->value.absolute = value;
- else {
- ERROR("utils_match: default_callback: obj->ds_type is invalid!");
- return -1;
- }
-
data->values_num++;
} else {
ERROR("utils_match: default_callback: obj->ds_type is invalid!");
#define UTILS_MATCH_DS_TYPE_GAUGE 0x1000
#define UTILS_MATCH_DS_TYPE_COUNTER 0x2000
#define UTILS_MATCH_DS_TYPE_DERIVE 0x4000
-#define UTILS_MATCH_DS_TYPE_ABSOLUTE 0x8000
#define UTILS_MATCH_CF_GAUGE_AVERAGE 0x01
#define UTILS_MATCH_CF_GAUGE_MIN 0x02
#define UTILS_MATCH_CF_DERIVE_ADD 0x02
#define UTILS_MATCH_CF_DERIVE_INC 0x04
-#define UTILS_MATCH_CF_ABSOLUTE_SET 0x01
-#define UTILS_MATCH_CF_ABSOLUTE_ADD 0x02
-#define UTILS_MATCH_CF_ABSOLUTE_INC 0x04
-
/*
* Data types
*/
type = "GAUGE";
else if (d->type == DS_TYPE_DERIVE)
type = "DERIVE";
- else if (d->type == DS_TYPE_ABSOLUTE)
- type = "ABSOLUTE";
else {
P_ERROR("ds_get: Unknown DS type: %i", d->type);
break;
return status;
} /* }}} int srrd_create */
- /* #endif HAVE_THREADSAFE_LIBRRD */
+/* #endif HAVE_THREADSAFE_LIBRRD */
#else /* !HAVE_THREADSAFE_LIBRRD */
static int srrd_create(const char *filename, /* {{{ */
v.derive = (derive_t)lua_tointeger(L, /* stack pos = */ -1);
else if (ds_type == DS_TYPE_COUNTER)
v.counter = (counter_t)lua_tointeger(L, /* stack pos = */ -1);
- else if (ds_type == DS_TYPE_ABSOLUTE)
- v.absolute = (absolute_t)lua_tointeger(L, /* stack pos = */ -1);
return v;
} /* }}} value_t luaC_tovalue */
lua_pushinteger(L, (lua_Integer)v.derive);
else if (ds_type == DS_TYPE_COUNTER)
lua_pushinteger(L, (lua_Integer)v.counter);
- else if (ds_type == DS_TYPE_ABSOLUTE)
- lua_pushinteger(L, (lua_Integer)v.absolute);
else
return -1;
return 0;
for (size_t i = 0; i < ds->ds_num; i++) {
if ((ds->ds[i].type != DS_TYPE_COUNTER) &&
(ds->ds[i].type != DS_TYPE_GAUGE) &&
- (ds->ds[i].type != DS_TYPE_DERIVE) &&
- (ds->ds[i].type != DS_TYPE_ABSOLUTE)) {
+ (ds->ds[i].type != DS_TYPE_DERIVE)) {
sfree(rates);
return -1;
}
BUFFER_ADD(",");
BUFFER_ADD("%s=%" PRIi64 "i", ds->ds[i].name, vl->values[i].derive);
have_values = true;
- } else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) {
- if (have_values)
- BUFFER_ADD(",");
- BUFFER_ADD("%s=%" PRIu64 "i", ds->ds[i].name, vl->values[i].absolute);
- have_values = true;
}
} /* for ds->ds_num */
BSON_APPEND_INT64(&subarray, key, vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
BSON_APPEND_INT64(&subarray, key, vl->values[i].derive);
- else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
- BSON_APPEND_INT64(&subarray, key, vl->values[i].absolute);
else {
ERROR("write_mongodb plugin: Unknown ds_type %d for index %" PRIsz,
ds->ds[i].type, i);
}
switch (ds_type) {
- case DS_TYPE_ABSOLUTE:
- m->counter->value = (double)value.absolute;
- break;
case DS_TYPE_COUNTER:
m->counter->value = (double)value.counter;
break;
if (ds->ds[index].type == DS_TYPE_DERIVE)
metric = (int64_t)vl->values[index].derive;
- else if (ds->ds[index].type == DS_TYPE_ABSOLUTE)
- metric = (int64_t)vl->values[index].absolute;
else
metric = (int64_t)vl->values[index].counter;
ERROR("write_sensu plugin: Unable to alloc memory");
return NULL;
}
- } else if (ds->ds[index].type == DS_TYPE_ABSOLUTE) {
- res = my_asprintf(&value_str, "%" PRIu64, vl->values[index].absolute);
- if (res == -1) {
- free(ret_str);
- ERROR("write_sensu plugin: Unable to alloc memory");
- return NULL;
- }
} else {
res = my_asprintf(&value_str, "%" PRIu64,
(uint64_t)vl->values[index].counter);
BUFFER_ADD("%" PRIu64, (uint64_t)vl->values[ds_num].counter);
else if (ds->ds[ds_num].type == DS_TYPE_DERIVE)
BUFFER_ADD("%" PRIi64, vl->values[ds_num].derive);
- else if (ds->ds[ds_num].type == DS_TYPE_ABSOLUTE)
- BUFFER_ADD("%" PRIu64, vl->values[ds_num].absolute);
else {
ERROR("format_values plugin: Unknown data source type: %i",
ds->ds[ds_num].type);
BUFFER_ADD("%" PRIu64, (uint64_t)vl->values[ds_num].counter);
else if (ds->ds[ds_num].type == DS_TYPE_DERIVE)
BUFFER_ADD("%" PRIi64, vl->values[ds_num].derive);
- else if (ds->ds[ds_num].type == DS_TYPE_ABSOLUTE)
- BUFFER_ADD("%" PRIu64, vl->values[ds_num].absolute);
else {
ERROR("format_values plugin: Unknown data source type: %i",
ds->ds[ds_num].type);