diff options
author | unixninja92 <charles@unixninja92.com> | 2016-01-03 23:02:44 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-01-08 15:52:10 -0800 |
commit | 4f0e28977d6376ccba599e7089aeb9e3b4f25e5f (patch) | |
tree | 4eab9c52a3395e7976cb36335031e5caa55adf26 /src/or/status.c | |
parent | cdbb04be102969bd2cece9daf42896e061cc8880 (diff) | |
download | tor-4f0e28977d6376ccba599e7089aeb9e3b4f25e5f.tar.gz tor-4f0e28977d6376ccba599e7089aeb9e3b4f25e5f.zip |
Added AccountRule in and AccountingRule out options
Diffstat (limited to 'src/or/status.c')
-rw-r--r-- | src/or/status.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/or/status.c b/src/or/status.c index 8f7be0aa3c..69d10721d2 100644 --- a/src/or/status.c +++ b/src/or/status.c @@ -164,24 +164,38 @@ log_accounting(const time_t now, const or_options_t *options) or_state_t *state = get_or_state(); char *acc_rcvd = bytes_to_usage(state->AccountingBytesReadInInterval); char *acc_sent = bytes_to_usage(state->AccountingBytesWrittenInInterval); + char *acc_used = bytes_to_usage(get_accounting_bytes()); uint64_t acc_bytes = options->AccountingMax; char *acc_max; time_t interval_end = accounting_get_end_time(); char end_buf[ISO_TIME_LEN + 1]; char *remaining = NULL; - if (options->AccountingRule == ACCT_SUM) - acc_bytes *= 2; acc_max = bytes_to_usage(acc_bytes); format_local_iso_time(end_buf, interval_end); remaining = secs_to_uptime(interval_end - now); + const char *acc_rule; + switch (options->AccountingRule) { + case ACCT_MAX: acc_rule = "max"; + break; + case ACCT_SUM: acc_rule = "sum"; + break; + case ACCT_OUT: acc_rule = "out"; + break; + case ACCT_IN: acc_rule = "in"; + break; + default: acc_rule = "max"; + break; + } + log_notice(LD_HEARTBEAT, "Heartbeat: Accounting enabled. " - "Sent: %s / %s, Received: %s / %s. The " + "Sent: %s, Received: %s, Used: %s / %s, Rule: %s. The " "current accounting interval ends on %s, in %s.", - acc_sent, acc_max, acc_rcvd, acc_max, end_buf, remaining); + acc_sent, acc_rcvd, acc_used, acc_max, acc_rule, end_buf, remaining); tor_free(acc_rcvd); tor_free(acc_sent); + tor_free(acc_used); tor_free(acc_max); tor_free(remaining); } |