Add env var toggle for StatsD

This commit is contained in:
Edznux
2020-10-08 20:48:46 +02:00
parent deab5a1532
commit 0220a8ff66
6 changed files with 23 additions and 17 deletions

View File

@ -316,6 +316,13 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
afl->afl_env.afl_cal_fast =
get_afl_env(afl_environment_variables[i]) ? 1 : 0;
} else if (!strncmp(env, "AFL_STATSD",
afl_environment_variable_len)) {
afl->afl_env.afl_statsd =
get_afl_env(afl_environment_variables[i]) ? 1 : 0;
} else if (!strncmp(env, "AFL_TMPDIR",
afl_environment_variable_len)) {

View File

@ -423,17 +423,18 @@ void show_stats(afl_state_t *afl) {
}
#ifdef USE_STATSD
if (cur_ms - afl->statsd_last_send_ms > STATSD_UPDATE_SEC * 1000) {
if (unlikely(afl->afl_env.afl_statsd == 1)) {
/* reset counter, even if send failed. */
afl->statsd_last_send_ms = cur_ms;
if (statsd_send_metric(afl)) { WARNF("coundln't send statsd metric."); }
if (cur_ms - afl->statsd_last_send_ms > STATSD_UPDATE_SEC * 1000) {
/* reset counter, even if send failed. */
afl->statsd_last_send_ms = cur_ms;
if (statsd_send_metric(afl)) { WARNF("coundln't send statsd metric."); }
}
}
#endif
/* Every now and then, write plot data. */
if (cur_ms - afl->stats_last_plot_ms > PLOT_UPDATE_SEC * 1000) {

View File

@ -194,7 +194,8 @@ static void usage(u8 *argv0, int more_help) {
"AFL_SKIP_BIN_CHECK: skip the check, if the target is an executable\n"
"AFL_SKIP_CPUFREQ: do not warn about variable cpu clocking\n"
"AFL_SKIP_CRASHES: during initial dry run do not terminate for crashing inputs\n"
"AFL_STATSD_HOST: change default statsd host. (default 127.0.0.1)"
"AFL_STATSD: enables StatsD metrics collection"
"AFL_STATSD_HOST: change default statsd host (default 127.0.0.1)"
"AFL_STATSD_PORT: change default statsd port (default: 8125)"
"AFL_STATSD_TAGS_FLAVOR: change default statsd tags format (default will disable tags)."
" Supported formats are: 'dogstatsd', 'librato', 'signalfx' and 'influxdb'"
@ -893,10 +894,7 @@ int main(int argc, char **argv_orig, char **envp) {
}
#ifdef USE_STATSD
statsd_setup_format(afl);
#endif
if (unlikely(afl->afl_env.afl_statsd == 1)) { statsd_setup_format(afl); }
if (strchr(argv[optind], '/') == NULL && !afl->unicorn_mode) {