Alias for `service_name`.
+### stats_period
+
+Sets how often the averages shown in various `SHOW` commands are
+updated and how often aggregated statistics are written to the log
+(but see `log_stats`). [seconds]
+
+Default: 60
+
## Log settings
Default: 1
-### stats_period
+### log_stats
-Period for writing aggregated stats into log.
+Write aggregated statistics into the log, every `stats_period`. This
+can be disabled if external monitoring tools are used to grab the same
+data from `SHOW` commands.
-Default: 60
+Default: 1
### verbose
char *cf_admin_users;
char *cf_stats_users;
int cf_stats_period;
+int cf_log_stats;
int cf_log_connections;
int cf_log_disconnections;
CF_ABS("admin_users", CF_STR, cf_admin_users, 0, ""),
CF_ABS("stats_users", CF_STR, cf_stats_users, 0, ""),
CF_ABS("stats_period", CF_INT, cf_stats_period, 0, "60"),
+CF_ABS("log_stats", CF_INT, cf_log_stats, 0, "1"),
CF_ABS("log_connections", CF_INT, cf_log_connections, 0, "1"),
CF_ABS("log_disconnections", CF_INT, cf_log_disconnections, 0, "1"),
CF_ABS("log_pooler_errors", CF_INT, cf_log_pooler_errors, 0, "1"),
struct List *item;
PgPool *pool;
struct timeval period = { cf_stats_period, 0 };
- PgStats old_total, cur_total, avg;
+ PgStats old_total, cur_total;
reset_stats(&old_total);
reset_stats(&cur_total);
pool->older_stats = pool->newer_stats;
pool->newer_stats = pool->stats;
- stat_add(&cur_total, &pool->stats);
- stat_add(&old_total, &pool->older_stats);
+ if (cf_log_stats) {
+ stat_add(&cur_total, &pool->stats);
+ stat_add(&old_total, &pool->older_stats);
+ }
+ }
+
+ if (cf_log_stats) {
+ PgStats avg;
+
+ calc_average(&avg, &cur_total, &old_total);
+
+ log_info("stats: %" PRIu64 " xacts/s,"
+ " %" PRIu64 " queries/s,"
+ " in %" PRIu64 " B/s,"
+ " out %" PRIu64 " B/s,"
+ " xact %" PRIu64 " us,"
+ " query %" PRIu64 " us,"
+ " wait %" PRIu64 " us",
+ avg.xact_count, avg.query_count,
+ avg.client_bytes, avg.server_bytes,
+ avg.xact_time, avg.query_time,
+ avg.wait_time);
}
- calc_average(&avg, &cur_total, &old_total);
- /* send totals to logfile */
- log_info("stats: %" PRIu64 " xacts/s,"
- " %" PRIu64 " queries/s,"
- " in %" PRIu64 " B/s,"
- " out %" PRIu64 " B/s,"
- " xact %" PRIu64 " us,"
- " query %" PRIu64 " us,"
- " wait %" PRIu64 " us",
- avg.xact_count, avg.query_count,
- avg.client_bytes, avg.server_bytes,
- avg.xact_time, avg.query_time,
- avg.wait_time);
safe_evtimer_add(&ev_stats, &period);
}