Added Node activity

This commit is contained in:
Deon George
2012-12-07 16:12:58 +11:00
parent 7a3539cb95
commit c9a1d39912
5 changed files with 60 additions and 2 deletions

View File

@@ -15,5 +15,20 @@ class Model_ACTLOG extends ORM_TSM {
protected $_sorting = array(
'DATE_TIME'=>'ASC',
);
protected $_display_filters = array(
'DATE_TIME'=>array(
array('ORM_TSM::date',array(':value','d-M H:i')),
),
);
private $_msgno_ba_objects = array(4952,4953,4954,4958,4960,4957,4970,4959,4982);
private $_msgno_ba_bytes = array(4977,4975,4984,4198,4961);
private $_msgno_ba_transfer = array(4963,4966,4967,4964);
private $_msgno_ba_reduction = array(4968,4981,4976);
public function exclude_ba() {
return $this->where('MSGNO','NOT IN',array_merge($this->_msgno_ba_objects,$this->_msgno_ba_bytes,$this->_msgno_ba_transfer,$this->_msgno_ba_reduction));
}
}
?>

View File

@@ -20,6 +20,7 @@ class Model_NODE extends ORM_TSM {
'DOMAIN'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
);
protected $_has_many = array(
'ACTLOG'=>array('foreign_key'=>'NODENAME','far_key'=>'NODE_NAME'),
'FILESPACE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
'VOLUMEUSAGE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
'ASSOCIATION'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
@@ -267,6 +268,25 @@ class Model_NODE extends ORM_TSM {
return $this->vols_byctype($type) ? TRUE : FALSE;
}
public function activity() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
$result = $this->ACTLOG->exclude_ba()->find_all();
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/**
* Return the BACKUP TYPES used by this NODE
* ie: Bkup/Arch/SpMg
@@ -278,7 +298,7 @@ class Model_NODE extends ORM_TSM {
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$x = $result = array();
$result = array();
foreach ($this->_occupancy() as $oo)
if (! in_array($oo->TYPE,$result))