From daab0f59284deb8ba91f9d87498a98846f2f87a0 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 15 Mar 2013 07:55:37 +0545 Subject: bandwidthd - rotate log files when output_cdf is enabled --- config/bandwidthd/bandwidthd.inc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc index 47a4b1fd..4e0107eb 100644 --- a/config/bandwidthd/bandwidthd.inc +++ b/config/bandwidthd/bandwidthd.inc @@ -46,6 +46,8 @@ function bandwidthd_install_deinstall() { exec("rm -f /usr/local/etc/rc.d/bandwidthd*"); exec("rm -rf " . PKG_BANDWIDTHD_BASE . "/htdocs"); exec("rm -f /usr/local/www/bandwidthd"); + // Remove the cron job, if it is there + install_cron_job("/bin/kill -HUP `cat /var/run/bandwidthd.pid`", false); conf_mount_ro(); config_unlock(); } @@ -79,7 +81,9 @@ function bandwidthd_install_config() { $recover_cdf = "recover_cdf true\n"; $output_cdf = $config['installedpackages']['bandwidthd']['config'][0]['outputcdf']; if($output_cdf) - $output_cdf = "output_cdf true\n"; + $output_cdf_string = "output_cdf true\n"; + else + $output_cdf_string = ""; $promiscuous = $config['installedpackages']['bandwidthd']['config'][0]['promiscuous']; if($promiscuous) $promiscuous = "promiscuous true\n"; @@ -180,7 +184,7 @@ $graph_cutoff $promiscuous #Log data to cdf file htdocs/log.cdf -$output_cdf +$output_cdf_string #Read back the cdf file on startup $recover_cdf @@ -297,6 +301,16 @@ EOD; if (!file_exists($bandwidthd_index_file)) { exec("echo \"Please start bandwidthd to populate this directory.\" > " . $bandwidthd_index_file); } + + if($output_cdf) { + // Use cron job to rotate logs every day at 00:01 + install_cron_job("/bin/kill -HUP `cat /var/run/bandwidthd.pid`", true, "1", "0"); + } + else + { + // Remove the cron job, if it is there + install_cron_job("/bin/kill -HUP `cat /var/run/bandwidthd.pid`", false); + } conf_mount_ro(); config_unlock(); stop_service("bandwidthd"); -- cgit v1.2.3 From d65240f91973c031ab2f3147ff927c662cb27f84 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 15 Mar 2013 07:58:04 +0545 Subject: bandwidthd - rotate log files when output_cdf is enabled Improve the documentation of options on the GUI, including what happens when output_cdf is on. --- config/bandwidthd/bandwidthd.xml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/config/bandwidthd/bandwidthd.xml b/config/bandwidthd/bandwidthd.xml index f82ac69d..161280cf 100644 --- a/config/bandwidthd/bandwidthd.xml +++ b/config/bandwidthd/bandwidthd.xml @@ -96,7 +96,7 @@ Skip intervals skipintervals - Number of intervals (2.5 minute) to skip between graphing. Default 0. + Number of intervals to skip between graphing. Default 0. Each interval is 200 seconds = 3 min 20 sec. input @@ -108,19 +108,20 @@ Promiscuous promiscuous - Put interface in promiscuous mode to score to traffic that may not be routing through the host machine. + Put interface in promiscuous mode to see traffic that may not be routing through the host machine.<br> + Note: If the interface is connected to a switch then the interface will only see the traffic on its port. checkbox output_cdf outputcdf - Log data to cdf file htdocs/log.cdf + Log data to cdf files log*.cdf checkbox recover_cdf recovercdf - Read back the cdf file on startup + Read back the cdf files on startup checkbox @@ -139,9 +140,24 @@ Meta Refresh meta_refresh - Set META REFRESH seconds (default 150, use 0 to disable). + Sets the interval (seconds) at which the browser graph display refreshes (default 150, use 0 to disable). input + + Graph and Log Info + graph_log_info + If draw graphs is on, then the daily report and graph html data is regenerated every (skip intervals + 1) * 200 seconds. The data volumes in the report are for the same period as the span of the graph.<br> + If output_cdf is on, then a cron job is added to rotate the log files at 00:01 each day. 6 log files are kept for each log frequency (daily, weekly, monthly, yearly). At the respective rotation intervals, the oldest log is deleted, the others are shuffled back and a new log is created.<br> + <table cellpadding=1 cellspacing=0 style="text-align: left;"> <tbody> + <tr><th> </th><th> Data Interval </th><th> Graph Span </th><th> Log Rotation </th><th> Log File Name </th></tr> + <tr><th> Daily </th><td> 200 seconds </td><td> 2 days </td><td> 1 day </td><td> log.1.[0-5].cdf </td></tr> + <tr><th> Weekly </th><td> 10 minutes </td><td> 7 days </td><td> 7 days </td><td> log.2.[0-5].cdf </td></tr> + <tr><th> Monthly </th><td> 1 hour </td><td> 35 days </td><td> 35 days </td><td> log.3.[0-5].cdf </td></tr> + <tr><th> Yearly </th><td> 12 hours </td><td> 412.5 days </td><td> 412.5 days </td><td> log.4.[0-5].cdf </td></tr> + </tbody> </table> + + info + bandwidthd_install_config(); -- cgit v1.2.3