Better "!stats"; can display peak and current bandwidth usage.

Network stats are now updated every minute, so that we have them handy for
printing in logs, or by issuing the !stats command.

Note: this checkin disables the once-per-hour stats logging.
I do not know wether or not that is useful functionality.
This commit is contained in:
Jan Vidar Krey
2009-03-04 18:36:45 +01:00
parent 8eb1726abb
commit d4c8b657bf
8 changed files with 52 additions and 32 deletions

View File

@@ -591,19 +591,6 @@ void net_stats_get(struct net_statistics** intermediate, struct net_statistics**
}
void net_stats_report()
{
int factor = (time(NULL) - stats.timestamp);
if (!factor) factor++;
hub_log(log_info, "Statistics NET: tx=%d KB/s, rx=%d KB/s, (acc=%d/cls=%d/err=%d)",
(int) ((stats.tx / factor) / 1024),
(int) ((stats.rx / factor) / 1024),
(int) stats.accept,
(int) stats.closed,
(int) stats.errors);
}
void net_stats_reset()
{
stats_total.tx += stats.tx;
@@ -619,8 +606,7 @@ void net_stats_reset()
int net_stats_timeout()
{
/* FIXME: Configurable time for dumping network statistics */
return (time(NULL) - stats.timestamp > 60) ? 1 : 0;
return (difftime(time(NULL), stats.timestamp) > TIMEOUT_STATS) ? 1 : 0;
}