Fixed Service Traffic alerting
This commit is contained in:
parent
ee0cc6aac5
commit
8598408a59
@ -149,7 +149,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
|
|
||||||
if ($this->auto_render) {
|
if ($this->auto_render) {
|
||||||
// Application Title
|
// Application Title
|
||||||
$this->meta->title = 'Application Title';
|
$this->meta->title = Kohana::Config('config.appname');
|
||||||
$this->template->title = '';
|
$this->template->title = '';
|
||||||
|
|
||||||
// Style Sheets Properties
|
// Style Sheets Properties
|
||||||
|
@ -19,7 +19,6 @@ class EmailTemplate {
|
|||||||
private $components = array('subject','message_text','message_html');
|
private $components = array('subject','message_text','message_html');
|
||||||
|
|
||||||
public function __construct($template,$language_id=NULL) {
|
public function __construct($template,$language_id=NULL) {
|
||||||
|
|
||||||
$this->template = ORM::factory('emailtemplate',array('name'=>$template));
|
$this->template = ORM::factory('emailtemplate',array('name'=>$template));
|
||||||
|
|
||||||
if (! $this->template->loaded())
|
if (! $this->template->loaded())
|
||||||
@ -107,7 +106,8 @@ class EmailTemplate {
|
|||||||
|
|
||||||
public function send($admin=FALSE) {
|
public function send($admin=FALSE) {
|
||||||
$e = Email::connect();
|
$e = Email::connect();
|
||||||
$sm = Swift_Message::newInstance();
|
$sm = Swift_Message::newInstance()
|
||||||
|
->setFrom(Kohana::config('config.email_from'));
|
||||||
|
|
||||||
foreach ($this->components as $component) {
|
foreach ($this->components as $component) {
|
||||||
$s = $this->template_mail->$component;
|
$s = $this->template_mail->$component;
|
||||||
@ -131,7 +131,6 @@ class EmailTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @todo This should go to the admin defined in email_setup
|
// @todo This should go to the admin defined in email_setup
|
||||||
if ($admin OR ($admin = Config::testmail($this->template->name))) {
|
if ($admin OR ($admin = Config::testmail($this->template->name))) {
|
||||||
$sm->setTo($admin);
|
$sm->setTo($admin);
|
||||||
|
@ -224,7 +224,10 @@ class Model_Service_ADSL extends Model_Service {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$return = array();
|
$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');
|
$period = strtotime('yesterday');
|
||||||
$traffic_data = $this->get_traffic_data_daily($period,FALSE);
|
$traffic_data = $this->get_traffic_data_daily($period,FALSE);
|
||||||
@ -249,7 +252,7 @@ class Model_Service_ADSL extends Model_Service {
|
|||||||
$google->series(array(
|
$google->series(array(
|
||||||
'title'=>array((isset($friendly['cumulative_'.$k]) ? $friendly['cumulative_'.$k] : 'cumulative_'.$k)),
|
'title'=>array((isset($friendly['cumulative_'.$k]) ? $friendly['cumulative_'.$k] : 'cumulative_'.$k)),
|
||||||
'axis'=>'r',
|
'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) {
|
foreach ($array as $item) {
|
||||||
switch ($item) {
|
switch ($item) {
|
||||||
@ -305,13 +308,17 @@ class Model_Service_ADSL extends Model_Service {
|
|||||||
* + last day of the period
|
* + last day of the period
|
||||||
*/
|
*/
|
||||||
public function report_traffic() {
|
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');
|
$period = strtotime('yesterday');
|
||||||
$traffic_data = $this->get_traffic_data_daily($period,FALSE);
|
$traffic_data = $this->get_traffic_data_daily($period,FALSE);
|
||||||
$traffic = $this->get_traffic_data_month($period);
|
$traffic = $this->get_traffic_data_month($period);
|
||||||
|
|
||||||
$traffic_type = $this->get_traffic_data_daily($period,TRUE);
|
$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;
|
$day = count($traffic_type) ? max(array_keys($traffic_type)) : 1;
|
||||||
$lastday = date('d',strtotime('last day of',$period));
|
$lastday = date('d',strtotime('last day of',$period));
|
||||||
|
|
||||||
@ -321,11 +328,11 @@ class Model_Service_ADSL extends Model_Service {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
// If we are at 80% usage
|
// 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;
|
return TRUE;
|
||||||
|
|
||||||
// If our average is greater than our allowance
|
// 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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class Service_Traffic_ADSL {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get our variable data
|
// 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->variables = $so->service_adsl->template_variables($et->variables());
|
||||||
|
|
||||||
$et->send();
|
$et->send();
|
||||||
|
@ -67,6 +67,10 @@ class Model_Task extends ORMOSB {
|
|||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$tlo->result = $e->getCode();
|
$tlo->result = $e->getCode();
|
||||||
$tlo->message = $e->getMessage();
|
$tlo->message = $e->getMessage();
|
||||||
|
|
||||||
|
$this->running = 0;
|
||||||
|
$this->running_host = NULL;
|
||||||
|
$this->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user