gettimeofday(&ts, NULL);
char name[1024];
- snprintf(name, sizeof(name), "graph_%ld_%ld.json", ts.tv_sec, ts.tv_usec/1000);
+ snprintf(name, sizeof(name), "graph_%ld_%03ld.json", ts.tv_sec, ts.tv_usec/1000);
exportmeshgraph(name);
}
/* Install timer_handler as the signal handler for SIGALRM. */
signal(SIGALRM, exportmeshgraph_timer);
- /* Configure the timer to expire after X msec... */
+ /* Configure the timer to expire immediately... */
struct itimerval timer;
- timer.it_value.tv_sec = timeout_sec;
- timer.it_value.tv_usec = timeout_msec * 1000;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = 1000;
/* ... and every X msec after that. */
timer.it_interval.tv_sec = timeout_sec;
int main(int argc, char *argv[]) {
const char *basebase = ".manynodes";
const char *namesprefix = "machine1";
+ const char *graphexporttimeout = NULL;
char buf[1024];
if(argc > 1)
n = atoi(argv[1]);
if(n < 1) {
- fprintf(stderr, "Usage: %s [number of local nodes] [confbase] [prefixnodenames]\n", argv[0]);
+ fprintf(stderr, "Usage: %s [number of local nodes] [confbase] [prefixnodenames] [graphexport timeout]\n", argv[0]);
return 1;
}
if(argc > 3)
namesprefix = argv[3];
+ if(argc > 4)
+ graphexporttimeout = argv[4];
+
mesh = calloc(n, sizeof *mesh);
meshlink_set_log_cb(NULL, MESHLINK_WARNING, log_message);
return 1;
}
+ if(graphexporttimeout)
+ { exportmeshgraph_begin(graphexporttimeout); }
+
printf("%d nodes started.\nType /help for a list of commands.\n", started);
// handle input
while(fgets(buf, sizeof buf, stdin))
parse_input(buf);
+ exportmeshgraph_end(NULL);
+
printf("Nodes stopping.\n");
for(int i = 0; i < n; i++)