/* * txerrs_metric_get_metric_value * * txerrs metric module get_metric_value function */ static int txerrs_metric_get_metric_value(unsigned int *metric_value_type, unsigned int *metric_value_len, void **metric_value) { u_int32_t txerrsval; u_int32_t *txerrsptr = NULL; int rv = -1; if (!metric_value_type || !metric_value_len || !metric_value) { CEREBRO_DBG(("invalid parameters")); return -1; } if (cerebro_metric_get_network(NULL, NULL, NULL, NULL, NULL, &txerrsval) < 0) goto cleanup; if (!(txerrsptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } *txerrsptr = txerrsval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; *metric_value_len = sizeof(u_int32_t); *metric_value = (void *)txerrsptr; rv = 0; cleanup: if (rv < 0 && txerrsptr) free(txerrsptr); return rv; }
/* * bytesin_metric_get_metric_value * * bytesin metric module get_metric_value function */ static int bytesin_metric_get_metric_value(unsigned int *metric_value_type, unsigned int *metric_value_len, void **metric_value) { u_int64_t bytesinval; u_int64_t *bytesinptr = NULL; int rv = -1; if (!metric_value_type || !metric_value_len || !metric_value) { CEREBRO_DBG(("invalid parameters")); return -1; } if (cerebro_metric_get_network(&bytesinval, NULL, NULL, NULL, NULL, NULL) < 0) goto cleanup; if (!(bytesinptr = (u_int64_t *)malloc(sizeof(u_int64_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } *bytesinptr = bytesinval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT64; *metric_value_len = sizeof(u_int64_t); *metric_value = (void *)bytesinptr; rv = 0; cleanup: if (rv < 0 && bytesinptr) free(bytesinptr); return rv; }