/** Implements the start_interval function of the plugin API */ int bgpcorsaro_pacifier_start_interval(bgpcorsaro_t *bgpcorsaro, bgpcorsaro_interval_t *int_start) { struct bgpcorsaro_pacifier_state_t *state = STATE(bgpcorsaro); if(state->outfile == NULL) { if(( state->outfile_p[state->outfile_n] = bgpcorsaro_io_prepare_file(bgpcorsaro, PLUGIN(bgpcorsaro)->name, int_start)) == NULL) { bgpcorsaro_log(__func__, bgpcorsaro, "could not open %s output file", PLUGIN(bgpcorsaro)->name); return -1; } state->outfile = state-> outfile_p[state->outfile_n]; } bgpcorsaro_io_write_interval_start(bgpcorsaro, state->outfile, int_start); struct timeval tv; if(state->tv_start == 0) { gettimeofday_wrap(&tv); state->tv_start = tv.tv_sec; state->tv_first_time = state->tv_start; } // a new interval is starting state->intervals++; // fprintf(stderr, "START INTERVAL TIME: %d \n", state->tv_start); return 0; }
/** Implements the start_interval function of the plugin API */ int bgpcorsaro_pfxmonitor_start_interval(bgpcorsaro_t *bgpcorsaro, bgpcorsaro_interval_t *int_start) { struct bgpcorsaro_pfxmonitor_state_t *state = STATE(bgpcorsaro); /* open an output file */ if (state->outfile == NULL) { if ((state->outfile_p[state->outfile_n] = bgpcorsaro_io_prepare_file( bgpcorsaro, PLUGIN(bgpcorsaro)->name, int_start)) == NULL) { bgpcorsaro_log(__func__, bgpcorsaro, "could not open %s output file", PLUGIN(bgpcorsaro)->name); return -1; } state->outfile = state->outfile_p[state->outfile_n]; } bgpcorsaro_io_write_interval_start(bgpcorsaro, state->outfile, int_start); /* save the interval start to correctly output the time series values */ state->interval_start = int_start->time; return 0; }