mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Move all *-stats file to subdirectory stats/.
This commit is contained in:
parent
a5508583ee
commit
42229d1d84
@ -917,11 +917,11 @@ geoip_dirreq_stats_init(time_t now)
|
|||||||
start_of_dirreq_stats_interval = now;
|
start_of_dirreq_stats_interval = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Store all our geoip statistics into $DATADIR/dirreq-stats. */
|
/** Write dirreq statistics to $DATADIR/stats/dirreq-stats. */
|
||||||
void
|
void
|
||||||
geoip_dirreq_stats_write(time_t now)
|
geoip_dirreq_stats_write(time_t now)
|
||||||
{
|
{
|
||||||
char *filename = get_datadir_fname("dirreq-stats");
|
char *statsdir = NULL, *filename = NULL;
|
||||||
char *data_v2 = NULL, *data_v3 = NULL;
|
char *data_v2 = NULL, *data_v3 = NULL;
|
||||||
char written[ISO_TIME_LEN+1];
|
char written[ISO_TIME_LEN+1];
|
||||||
open_file_t *open_file = NULL;
|
open_file_t *open_file = NULL;
|
||||||
@ -935,6 +935,10 @@ geoip_dirreq_stats_write(time_t now)
|
|||||||
/* Discard all items in the client history that are too old. */
|
/* Discard all items in the client history that are too old. */
|
||||||
geoip_remove_old_clients(start_of_dirreq_stats_interval);
|
geoip_remove_old_clients(start_of_dirreq_stats_interval);
|
||||||
|
|
||||||
|
statsdir = get_datadir_fname("stats");
|
||||||
|
if (check_private_dir(statsdir, CPD_CREATE) < 0)
|
||||||
|
goto done;
|
||||||
|
filename = get_datadir_fname("stats"PATH_SEPARATOR"dirreq-stats");
|
||||||
data_v2 = geoip_get_client_history_dirreq(now,
|
data_v2 = geoip_get_client_history_dirreq(now,
|
||||||
GEOIP_CLIENT_NETWORKSTATUS_V2);
|
GEOIP_CLIENT_NETWORKSTATUS_V2);
|
||||||
data_v3 = geoip_get_client_history_dirreq(now,
|
data_v3 = geoip_get_client_history_dirreq(now,
|
||||||
@ -1029,6 +1033,7 @@ geoip_dirreq_stats_write(time_t now)
|
|||||||
if (open_file)
|
if (open_file)
|
||||||
abort_writing_to_file(open_file);
|
abort_writing_to_file(open_file);
|
||||||
tor_free(filename);
|
tor_free(filename);
|
||||||
|
tor_free(statsdir);
|
||||||
tor_free(data_v2);
|
tor_free(data_v2);
|
||||||
tor_free(data_v3);
|
tor_free(data_v3);
|
||||||
}
|
}
|
||||||
@ -1043,12 +1048,11 @@ geoip_entry_stats_init(time_t now)
|
|||||||
start_of_entry_stats_interval = now;
|
start_of_entry_stats_interval = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Store all our geoip statistics as entry guards into
|
/** Write entry statistics to $DATADIR/stats/entry-stats. */
|
||||||
* $DATADIR/entry-stats. */
|
|
||||||
void
|
void
|
||||||
geoip_entry_stats_write(time_t now)
|
geoip_entry_stats_write(time_t now)
|
||||||
{
|
{
|
||||||
char *filename = get_datadir_fname("entry-stats");
|
char *statsdir = NULL, *filename = NULL;
|
||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
char written[ISO_TIME_LEN+1];
|
char written[ISO_TIME_LEN+1];
|
||||||
open_file_t *open_file = NULL;
|
open_file_t *open_file = NULL;
|
||||||
@ -1060,6 +1064,10 @@ geoip_entry_stats_write(time_t now)
|
|||||||
/* Discard all items in the client history that are too old. */
|
/* Discard all items in the client history that are too old. */
|
||||||
geoip_remove_old_clients(start_of_entry_stats_interval);
|
geoip_remove_old_clients(start_of_entry_stats_interval);
|
||||||
|
|
||||||
|
statsdir = get_datadir_fname("stats");
|
||||||
|
if (check_private_dir(statsdir, CPD_CREATE) < 0)
|
||||||
|
goto done;
|
||||||
|
filename = get_datadir_fname("stats"PATH_SEPARATOR"entry-stats");
|
||||||
data = geoip_get_client_history_dirreq(now, GEOIP_CLIENT_CONNECT);
|
data = geoip_get_client_history_dirreq(now, GEOIP_CLIENT_CONNECT);
|
||||||
format_iso_time(written, now);
|
format_iso_time(written, now);
|
||||||
out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND,
|
out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND,
|
||||||
@ -1079,6 +1087,7 @@ geoip_entry_stats_write(time_t now)
|
|||||||
if (open_file)
|
if (open_file)
|
||||||
abort_writing_to_file(open_file);
|
abort_writing_to_file(open_file);
|
||||||
tor_free(filename);
|
tor_free(filename);
|
||||||
|
tor_free(statsdir);
|
||||||
tor_free(data);
|
tor_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1358,7 +1358,7 @@ rep_hist_exit_stats_init(time_t now)
|
|||||||
sizeof(uint32_t));
|
sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write exit stats for the current period to disk and reset counters. */
|
/** Write exit stats to $DATADIR/stats/exit-stats and reset counters. */
|
||||||
void
|
void
|
||||||
rep_hist_exit_stats_write(time_t now)
|
rep_hist_exit_stats_write(time_t now)
|
||||||
{
|
{
|
||||||
@ -1367,10 +1367,14 @@ rep_hist_exit_stats_write(time_t now)
|
|||||||
uint64_t *b, total_bytes, threshold_bytes, other_bytes;
|
uint64_t *b, total_bytes, threshold_bytes, other_bytes;
|
||||||
uint32_t other_streams;
|
uint32_t other_streams;
|
||||||
|
|
||||||
char *filename = get_datadir_fname("exit-stats");
|
char *statsdir = NULL, *filename = NULL;
|
||||||
open_file_t *open_file = NULL;
|
open_file_t *open_file = NULL;
|
||||||
FILE *out = NULL;
|
FILE *out = NULL;
|
||||||
|
|
||||||
|
statsdir = get_datadir_fname("stats");
|
||||||
|
if (check_private_dir(statsdir, CPD_CREATE) < 0)
|
||||||
|
goto done;
|
||||||
|
filename = get_datadir_fname("stats"PATH_SEPARATOR"exit-stats");
|
||||||
format_iso_time(t, now);
|
format_iso_time(t, now);
|
||||||
log_info(LD_HIST, "Writing exit port statistics to disk for period "
|
log_info(LD_HIST, "Writing exit port statistics to disk for period "
|
||||||
"ending at %s.", t);
|
"ending at %s.", t);
|
||||||
@ -1466,6 +1470,7 @@ rep_hist_exit_stats_write(time_t now)
|
|||||||
if (open_file)
|
if (open_file)
|
||||||
abort_writing_to_file(open_file);
|
abort_writing_to_file(open_file);
|
||||||
tor_free(filename);
|
tor_free(filename);
|
||||||
|
tor_free(statsdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Note that we wrote <b>num_bytes</b> to an exit connection to
|
/** Note that we wrote <b>num_bytes</b> to an exit connection to
|
||||||
@ -2663,11 +2668,11 @@ _buffer_stats_compare_entries(const void **_a, const void **_b)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Append buffer statistics to local file. */
|
/** Write buffer statistics to $DATADIR/stats/buffer-stats. */
|
||||||
void
|
void
|
||||||
rep_hist_buffer_stats_write(time_t now)
|
rep_hist_buffer_stats_write(time_t now)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *statsdir = NULL, *filename = NULL;
|
||||||
char written[ISO_TIME_LEN+1];
|
char written[ISO_TIME_LEN+1];
|
||||||
open_file_t *open_file = NULL;
|
open_file_t *open_file = NULL;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
@ -2706,7 +2711,10 @@ rep_hist_buffer_stats_write(time_t now)
|
|||||||
stat, tor_free(stat));
|
stat, tor_free(stat));
|
||||||
smartlist_clear(circuits_for_buffer_stats);
|
smartlist_clear(circuits_for_buffer_stats);
|
||||||
/* write to file */
|
/* write to file */
|
||||||
filename = get_datadir_fname("buffer-stats");
|
statsdir = get_datadir_fname("stats");
|
||||||
|
if (check_private_dir(statsdir, CPD_CREATE) < 0)
|
||||||
|
goto done;
|
||||||
|
filename = get_datadir_fname("stats"PATH_SEPARATOR"buffer-stats");
|
||||||
out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND,
|
out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND,
|
||||||
0600, &open_file);
|
0600, &open_file);
|
||||||
if (!out)
|
if (!out)
|
||||||
@ -2758,6 +2766,7 @@ rep_hist_buffer_stats_write(time_t now)
|
|||||||
if (open_file)
|
if (open_file)
|
||||||
abort_writing_to_file(open_file);
|
abort_writing_to_file(open_file);
|
||||||
tor_free(filename);
|
tor_free(filename);
|
||||||
|
tor_free(statsdir);
|
||||||
if (str_build) {
|
if (str_build) {
|
||||||
SMARTLIST_FOREACH(str_build, char *, c, tor_free(c));
|
SMARTLIST_FOREACH(str_build, char *, c, tor_free(c));
|
||||||
smartlist_free(str_build);
|
smartlist_free(str_build);
|
||||||
|
@ -1903,8 +1903,8 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
|||||||
time_t since = time(NULL) - (24*60*60);
|
time_t since = time(NULL) - (24*60*60);
|
||||||
log_info(LD_GENERAL, "Adding stats to extra-info descriptor.");
|
log_info(LD_GENERAL, "Adding stats to extra-info descriptor.");
|
||||||
if (options->DirReqStatistics &&
|
if (options->DirReqStatistics &&
|
||||||
load_stats_file("dirreq-stats", "dirreq-stats-end", since,
|
load_stats_file("stats"PATH_SEPARATOR"dirreq-stats",
|
||||||
&contents) > 0) {
|
"dirreq-stats-end", since, &contents) > 0) {
|
||||||
int pos = strlen(s);
|
int pos = strlen(s);
|
||||||
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
||||||
strlen(contents)) {
|
strlen(contents)) {
|
||||||
@ -1915,8 +1915,8 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
|||||||
tor_free(contents);
|
tor_free(contents);
|
||||||
}
|
}
|
||||||
if (options->EntryStatistics &&
|
if (options->EntryStatistics &&
|
||||||
load_stats_file("entry-stats", "entry-stats-end", since,
|
load_stats_file("stats"PATH_SEPARATOR"entry-stats",
|
||||||
&contents) > 0) {
|
"entry-stats-end", since, &contents) > 0) {
|
||||||
int pos = strlen(s);
|
int pos = strlen(s);
|
||||||
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
||||||
strlen(contents)) {
|
strlen(contents)) {
|
||||||
@ -1927,8 +1927,8 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
|||||||
tor_free(contents);
|
tor_free(contents);
|
||||||
}
|
}
|
||||||
if (options->CellStatistics &&
|
if (options->CellStatistics &&
|
||||||
load_stats_file("buffer-stats", "cell-stats-end", since,
|
load_stats_file("stats"PATH_SEPARATOR"buffer-stats",
|
||||||
&contents) > 0) {
|
"cell-stats-end", since, &contents) > 0) {
|
||||||
int pos = strlen(s);
|
int pos = strlen(s);
|
||||||
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
||||||
strlen(contents)) {
|
strlen(contents)) {
|
||||||
@ -1939,8 +1939,8 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
|||||||
tor_free(contents);
|
tor_free(contents);
|
||||||
}
|
}
|
||||||
if (options->ExitPortStatistics &&
|
if (options->ExitPortStatistics &&
|
||||||
load_stats_file("exit-stats", "exit-stats-end", since,
|
load_stats_file("stats"PATH_SEPARATOR"exit-stats",
|
||||||
&contents) > 0) {
|
"exit-stats-end", since, &contents) > 0) {
|
||||||
int pos = strlen(s);
|
int pos = strlen(s);
|
||||||
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
if (strlcpy(s + pos, contents, maxlen - strlen(s)) !=
|
||||||
strlen(contents)) {
|
strlen(contents)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user