[Aggregator] Add -F option (don't flush output)

Add the -F option to turn off flushing of the output file after each
analyse of the requests' list.
This commit is contained in:
Matteo Cypriani 2013-06-12 15:11:31 -04:00
parent 6761650648
commit 3a9ce442d1
3 changed files with 14 additions and 4 deletions

View File

@ -89,8 +89,6 @@ Work to do in OwlPS
- Test for the maximum verbose level.
- Add an option to (not) flush the output file.
- Outputs should include all the timestamps
The CSV output file and the socket should include the capture

View File

@ -25,7 +25,7 @@
/* Arguments & program configuration */
#define OPTIONS "Ac:C:Df:GhH:i:k:K:l:o:O:p:qt:vV" // getopt string
#define OPTIONS "Ac:C:Df:FGhH:i:k:K:l:o:O:p:qt:vV" // getopt string
#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-aggregator.conf"
#define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds

View File

@ -255,6 +255,9 @@ int parse_config_file(int argc, char **argv)
// Output file (default is the standard output)
CFG_STR("output_file", "-", CFGF_NONE),
// Flush the output file or not
CFG_BOOL("flush_output", cfg_true, CFGF_NONE),
// Timeouts (in milliseconds):
CFG_INT("aggregate_timeout", DEFAULT_AGGREGATE_TIMEOUT, CFGF_NONE),
CFG_INT("keep_timeout", DEFAULT_KEEP_TIMEOUT, CFGF_NONE),
@ -370,6 +373,9 @@ int parse_command_line(int argc, char **argv)
break ;
case 'f' : // Config file
break ; // (already parsed)
case 'F' :
cfg_setbool(cfg, "flush_output", cfg_false) ;
break ;
case 'G' :
dump_configuration = true ;
/* We must not turn owl_run false here, to avoid the default
@ -807,7 +813,10 @@ void* monitor_requests(void *NULL_value)
sem_post(&lock_requests) ;
fflush(NULL) ;
if (cfg_getbool(cfg, "flush_output"))
if (fflush(fd))
perror("Failed to flush the output file") ;
// Wait to check again:
owl_msleep(cfg_getint(cfg, "check_interval")) ;
}
@ -1441,6 +1450,7 @@ void print_usage()
" [-v[v[v[v]]] | -q]"
"\n\t"
" [-o out_file]"
" [-F]"
" [-i positionner_ip]"
" [-p positioner_port]"
"\n\t"
@ -1478,6 +1488,8 @@ void print_usage()
"\t-o out_file\t\tAggregated requests will be appended to"
" this CSV\n\t\t\t\tfile (default is \"-\", i.e. the standard"
" output).\n"
"\t-F\t\t\tDo not flush the output file after each analyse"
"\n\t\t\t\tof the requests' list.\n"
"\t-i positionner_ip\tIP address of the localisation server"
" (default:\n\t\t\t\t%s).\n"
"\t-p positioner_port\tAggregated requests are transmitted to"