Example #1
0
/**
 * This is the thread that is invoked to handle flushing metrics
 */
static void* flush_thread(void *arg) {
    // Cast the args
    metrics *m = arg;

    // Get the current time
    struct timeval tv;
    gettimeofday(&tv, NULL);

    // Stream the records
    int res = stream_to_command(m, &tv, stream_formatter, GLOBAL_CONFIG->stream_cmd);
    if (res != 0) {
        syslog(LOG_WARNING, "Streaming command exited with status %d", res);
    }

    // Cleanup
    destroy_metrics(m);
    free(m);
}
Example #2
0
static int wrap_stream(struct sink* sink, metrics* m, void* data) {
    sink_config_stream *sc = (sink_config_stream*)sink->sink_config;
    stream_callback cb = (sc->binary_stream) ? stream_formatter_bin : stream_formatter;
    struct config_time ct = {
        .tv = data,
        .global_config = sink->global_config
    };
    return stream_to_command(m, &ct, cb, sc->stream_cmd);
}

/**
 * Build a stream sink - this is a basic form which has no actual parameters
 * and simply stores both configs.
 */
sink* init_stream_sink(const sink_config_stream* sc, const statsite_config* config) {
    sink* ss = calloc(1, sizeof(sink));
    ss->sink_config = (const sink_config*)sc;
    ss->global_config = config;
    ss->command = wrap_stream;
    return (sink*)ss;
}
Example #3
0
/**
 * This is the thread that is invoked to handle flushing metrics
 */
static void* flush_thread(void *arg) {
    // Cast the args
    metrics *m = arg;

    // Get the current time
    struct timeval tv;
    gettimeofday(&tv, NULL);

    // Determine which callback to use
    stream_callback cb = (GLOBAL_CONFIG->binary_stream)? stream_formatter_bin: stream_formatter;

    // Stream the records
    int res = stream_to_command(m, &tv, cb, GLOBAL_CONFIG->stream_cmd);
    if (res != 0) {
        syslog(LOG_WARNING, "Streaming command exited with status %d", res);
    }

    // Cleanup
    destroy_metrics(m);
    free(m);
    return NULL;
}