--- conf/accounting.attrs 2003-10-20 18:39:38.000000000 +0200 +++ accounting.attrs 2006-04-22 17:31:40.152836224 +0200 @@ -18,3 +18,4 @@ 7 server yes no yes 8 terminate cause yes no yes 9 callerid yes yes yes +10 total yes no no --- conf/admin.conf 2004-04-16 17:03:13.000000000 +0200 +++ conf/admin.conf 2006-04-22 21:09:18.197711664 +0200 @@ -303,3 +303,20 @@ # it configurable # This is not needed if the monthly limit is not none #counter_monthly_calculate_usage: true + +#Define when the colors will turn into Orange +acct_warning_perc: 80 + +# +# These are the attributes specified in sqlcounter.conf for volume limits +max_total_volume_attr: Max-Octets +max_upload_volume_attr: Max-Octets-Upload +max_download_volume_attr: Max-Octets-Download + +# +# Volume multiplier for volume limits +# 1 = limit specified in bytes +# 1024 = limit specified in kilobytes +# 1048576 = limit specified in megabytes +# Default is MB +acct_volume_multiplier: 1048576 --- dialup_admin/htdocs/user_accounting.php3 2004-04-06 21:37:48.000000000 +0200 +++ /usr/share/freeradius-dialupadmin/htdocs/user_accounting.php3 2006-04-22 20:59:09.067313560 +0200 @@ -24,6 +24,10 @@ exit(); } +if (is_file("../lib/$config[general_lib_type]/user_info.php3")){ + include("../lib/$config[general_lib_type]/user_info.php3"); +} + $now = time(); $now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400); $prev_str = ($prev_str != '') ? "$prev_str" : date($config[sql_date_format], $now - 604800 ); @@ -39,6 +43,8 @@ $selected[$order] = 'selected'; $now_str = da_sql_escape_string($now_str); $prev_str = da_sql_escape_string($prev_str); +$now_static = date($config[sql_date_format], mktime(0, 0, 0, date("m")+1, 1, date("Y"))); +$month_prev_str = date($config[sql_date_format], mktime(0, 0, 0, date("m"), 1, date("Y"))); echo <<= '$month_prev_str' ORDER BY acctstarttime $order;"); + if ($monthly){ + while( $row = @da_sql_fetch_array($monthly,$config) ){ + $acct_monthly_upload = $row[acctinputoctets]; + $acct_monthly_upload_sum += $acct_monthly_upload; + $acct_monthly_upload = bytes2str($acct_monthly_upload); + $acct_monthly_download = $row[acctoutputoctets]; + $acct_monthly_download_sum += $acct_monthly_download; + $acct_monthly_download = bytes2str($acct_monthly_download); + } + $acct_limit_total = ($item_vals[$config[max_total_volume_attr]][0] != '') ? $item_vals[$config[max_total_volume_attr]][0] : $default_vals[$config[max_total_volume_attr]][0]; + $acct_limit_total = $acct_vol_multi * $acct_limit_total; + $acct_limit_total = ($acct_limit_total) ? $acct_limit_total : '-'; + $acct_limit_download = ($item_vals[$config[max_download_volume_attr]][0] != '') ? $item_vals[$config[max_download_volume_attr]][0] : $default_vals[$config[max_download_volume_attr]][0]; + $acct_limit_download = $acct_vol_multi * $acct_limit_download; + $acct_limit_download = ($acct_limit_download) ? $acct_limit_download : '-'; + $acct_limit_upload = ($item_vals[$config[max_upload_volume_attr]][0] != '') ? $item_vals[$config[max_upload_volume_attr]][0] : $default_vals[$config[max_upload_volume_attr]][0]; + $acct_limit_upload = $acct_vol_multi * $acct_limit_upload; + $acct_limit_upload = ($acct_limit_upload) ? $acct_limit_upload : '-'; + //Declare TOTAL SUM + $acct_monthly_total_sum = $acct_monthly_download_sum + $acct_monthly_upload_sum; + //Calculate if volume limits are reached + if ( $acct_limit_total != '-' ) { + $percenttot = round(100 * ($acct_monthly_total_sum / $acct_limit_total),2); + //Color scheme for volume stats + if ( $percenttot < $acct_warning_perc ) { $volcoltot="green"; } + elseif ( $percenttot >= 100 ) { $volcoltot="red"; } + else { $volcoltot="orange";} + $acct_limit_total = bytes2str($acct_limit_total); + } + if ( $acct_limit_download != '-' ) { + $percentdownload = round(100 * ($acct_monthly_download_sum / $acct_limit_download),2); + //Color scheme for volume stats + if ( $percentdownload < $acct_warning_perc ) { $volcoldown="green"; } + elseif ( $percentdownload >= 100 ) { $volcoldown="red"; } + else { $volcoldown="orange"; } + $acct_limit_download = bytes2str($acct_limit_download); + } + if ( $acct_limit_upload != '-' ) { + $percentup = round(100 * ($acct_monthly_upload_sum / $acct_limit_upload),2); + //Color scheme for volume stats + if ( $percentup < $acct_warning_perc ) { $volcolup="green"; } + elseif ( $percentup >= 100 ) { $volcolup="red"; } + else { $volcolup="orange"; } + $acct_limit_upload = bytes2str($acct_limit_upload); + } + // Changes vars into strings + $acct_monthly_total_sum = bytes2str($acct_monthly_total_sum); + $acct_monthly_upload_sum = bytes2str($acct_monthly_upload_sum); + $acct_monthly_download_sum = bytes2str($acct_monthly_download_sum); + } + else + echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; +} + + print <<
@@ -74,6 +147,38 @@ + + " . $acct_attrs['ua']["$i"] . "\n"; } @@ -95,7 +200,6 @@ $acct_server\n"; if ($acct_attrs[ua][8] != '') echo "\n"; if ($acct_attrs[ua][9] != '') echo "\n"; + if ($acct_attrs[ua][10] != '') echo "\n"; echo "\n"; } $acct_sessiontime_sum = time2str($acct_sessiontime_sum); $acct_upload_sum = bytes2str($acct_upload_sum); $acct_download_sum = bytes2str($acct_download_sum); + $acct_total_sum = bytes2str($acct_download_sum + $acct_upload_sum); } else echo "Database query failed: " . da_sql_error($link,$config) . "
\n"; @@ -186,6 +294,7 @@ if ($acct_attrs[ua][7] != '') echo "\n"; if ($acct_attrs[ua][8] != '') echo "\n"; if ($acct_attrs[ua][9] != '') echo "\n"; + if ($acct_attrs[ua][10] != '') echo "\n"; ?>
+ Period overview from $month_prev_str up to $now_static + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Maximum allowed volume
Used% used
Download volume$acct_limit_download$acct_monthly_download_sum$percentdown
Upstream volume$acct_limit_upload$acct_monthly_upload_sum$percentup
Total volume$acct_limit_total$acct_monthly_total_sum$percenttot
+ +
$prev_str up to $now_str EOM; @@ -84,7 +189,7 @@
#
$acct_terminate_cause$acct_callerid$acct_session_volume
   $acct_total_sum