Fixed Service Traffic alerting
This commit is contained in:
@@ -224,7 +224,10 @@ class Model_Service_ADSL extends Model_Service {
|
||||
);
|
||||
|
||||
$return = array();
|
||||
$allowance = $this->adsl_plan->allowance(FALSE);
|
||||
if ($this->service->product->prod_plugin_file != 'ADSL')
|
||||
throw new Kohana_Exception('Huh? How did this get called, for a non ADSL product (:ppf)',array(':ppf'=>$this->service_id));
|
||||
|
||||
$allowance = $this->service->product->plugin()->allowance(FALSE);
|
||||
|
||||
$period = strtotime('yesterday');
|
||||
$traffic_data = $this->get_traffic_data_daily($period,FALSE);
|
||||
@@ -249,7 +252,7 @@ class Model_Service_ADSL extends Model_Service {
|
||||
$google->series(array(
|
||||
'title'=>array((isset($friendly['cumulative_'.$k]) ? $friendly['cumulative_'.$k] : 'cumulative_'.$k)),
|
||||
'axis'=>'r',
|
||||
'data'=>array((isset($friendly['cumulative_'.$k]) ? $friendly['cumulative_'.$k] : 'cumulative_'.$k)=>$this->cumulative($traffic_data['cumulative_'.$k]))));
|
||||
'data'=>array((isset($friendly['cumulative_'.$k]) ? $friendly['cumulative_'.$k] : 'cumulative_'.$k)=>$this->cumulative($traffic_data[$k]))));
|
||||
|
||||
foreach ($array as $item) {
|
||||
switch ($item) {
|
||||
@@ -305,13 +308,17 @@ class Model_Service_ADSL extends Model_Service {
|
||||
* + last day of the period
|
||||
*/
|
||||
public function report_traffic() {
|
||||
$allowance = $this->adsl_plan->allowance(FALSE);
|
||||
if ($this->service->product->prod_plugin_file != 'ADSL')
|
||||
throw new Kohana_Exception('Huh? How did this get called, for a non ADSL product (:ppf)',array(':ppf'=>$this->service_id));
|
||||
|
||||
$allowance = $this->service->product->plugin()->allowance(FALSE);
|
||||
|
||||
$period = strtotime('yesterday');
|
||||
$traffic_data = $this->get_traffic_data_daily($period,FALSE);
|
||||
$traffic = $this->get_traffic_data_month($period);
|
||||
|
||||
$traffic_type = $this->get_traffic_data_daily($period,TRUE);
|
||||
// @todo If no data comes in, then this can be stuck reporting traffic for an old date.
|
||||
$day = count($traffic_type) ? max(array_keys($traffic_type)) : 1;
|
||||
$lastday = date('d',strtotime('last day of',$period));
|
||||
|
||||
@@ -321,11 +328,11 @@ class Model_Service_ADSL extends Model_Service {
|
||||
return TRUE;
|
||||
|
||||
// If we are at 80% usage
|
||||
if ($v/($allowance[$k] > 0 ? $allowance[$k] : 1) >= .8 AND $day%3 == 3)
|
||||
if ($v/($allowance[$k] > 0 ? $allowance[$k] : 1) >= .8 AND $day%3 == 0)
|
||||
return TRUE;
|
||||
|
||||
// If our average is greater than our allowance
|
||||
if ($day%5 == 5 AND ($v/$day > $allowance[$k]/$day))
|
||||
if ($day%5 == 0 AND ($v/$day > $allowance[$k]/$day))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -148,7 +148,7 @@ class Service_Traffic_ADSL {
|
||||
continue;
|
||||
|
||||
// Get our variable data
|
||||
$et->to = array($so->account->email=>sprintf('%s %s',$so->account->first_name,$so->account->last_name));
|
||||
$et->to = array('account'=>array($so->account_id));
|
||||
$et->variables = $so->service_adsl->template_variables($et->variables());
|
||||
|
||||
$et->send();
|
||||
|
Reference in New Issue
Block a user