2011-04-05 23:12:31 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package PTA
|
|
|
|
* @subpackage Nodes
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 phpTSMadmin Development Team
|
|
|
|
* @license http://phptsmadmin.sf.net/license.html
|
|
|
|
*/
|
|
|
|
class Model_NODE extends ORMTSM {
|
|
|
|
protected $_table_name = 'NODES';
|
|
|
|
protected $_primary_key = 'NODE_NAME';
|
2011-05-23 15:04:40 +00:00
|
|
|
protected $_sorting = array(
|
|
|
|
'NODE_NAME'=>'ASC',
|
2011-04-07 05:03:05 +00:00
|
|
|
);
|
2011-04-05 23:12:31 +00:00
|
|
|
|
2011-05-23 15:04:40 +00:00
|
|
|
protected $_has_many = array(
|
|
|
|
'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'),
|
|
|
|
'MGMTCLASS'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
|
|
|
|
'CLIENTOPT'=>array('foreign_key'=>'OPTIONSET_NAME','far_key'=>'OPTION_SET'),
|
|
|
|
'SUMMARY'=>array('foreign_key'=>'ENTITY','far_key'=>'NODE_NAME'),
|
|
|
|
'EVENT'=>array('foreign_key'=>'NODE_NAME','far_key'=>'NODE_NAME'),
|
2011-04-05 23:12:31 +00:00
|
|
|
);
|
|
|
|
|
2011-05-23 15:04:40 +00:00
|
|
|
protected $_display_filters = array(
|
|
|
|
'REG_TIME'=>array(
|
|
|
|
array('ORMTSM::date',array(':value','d-M-Y')),
|
|
|
|
),
|
|
|
|
'PWSET_TIME'=>array(
|
|
|
|
array('ORMTSM::date',array(':value','d-M-Y')),
|
|
|
|
),
|
|
|
|
'LASTACC_TIME'=>array(
|
|
|
|
array('ORMTSM::date',array(':value','d-M-Y')),
|
|
|
|
),
|
|
|
|
'LASTSESS_SENT'=>array(
|
|
|
|
array('number_format',array(':value',0)),
|
|
|
|
),
|
|
|
|
'LASTSESS_RECVD'=>array(
|
|
|
|
array('number_format',array(':value',0)),
|
|
|
|
),
|
|
|
|
'LASTSESS_DURATION'=>array(
|
|
|
|
array('number_format',array(':value',2)),
|
|
|
|
),
|
|
|
|
'LASTSESS_IDLEWAIT'=>array(
|
|
|
|
array('number_format',array(':value',2)),
|
|
|
|
),
|
|
|
|
'LASTSESS_COMMWAIT'=>array(
|
|
|
|
array('number_format',array(':value',2)),
|
|
|
|
),
|
|
|
|
'LASTSESS_MEDIAWAIT'=>array(
|
|
|
|
array('number_format',array(':value',2)),
|
|
|
|
),
|
2011-04-05 23:12:31 +00:00
|
|
|
);
|
|
|
|
|
2011-04-07 05:03:05 +00:00
|
|
|
// Pools used by a node.
|
|
|
|
private $pools = array();
|
|
|
|
|
2011-04-05 23:12:31 +00:00
|
|
|
public function tsmclientversion() {
|
|
|
|
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// @todo This needs to return the global configuration.
|
|
|
|
public function passexp() {
|
|
|
|
if ($this->PASSEXP)
|
|
|
|
return 'TBA';
|
|
|
|
else
|
|
|
|
return _('No Set');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function lasttransferpercent() {
|
2011-04-07 05:03:05 +00:00
|
|
|
return 100-($this->LASTSESS_IDLEWAIT+$this->LASTSESS_COMMWAIT+$this->LASTSESS_MEDIAWAIT);
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function lasttransfertime() {
|
2011-04-08 05:34:04 +00:00
|
|
|
if ($this->LASTSESS_DURATION)
|
|
|
|
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
|
|
|
|
else
|
|
|
|
return 0;
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function lastsendperformance() {
|
|
|
|
if ($this->lasttransfertime())
|
2011-04-07 05:03:05 +00:00
|
|
|
return $this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024;
|
2011-04-05 23:12:31 +00:00
|
|
|
else
|
2011-04-08 05:34:04 +00:00
|
|
|
return 0;
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function lastreceiveperformance() {
|
|
|
|
if ($this->lasttransfertime())
|
2011-04-07 05:03:05 +00:00
|
|
|
return $this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024;
|
2011-04-05 23:12:31 +00:00
|
|
|
else
|
2011-04-08 05:34:04 +00:00
|
|
|
return 0;
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function lastsendaggperformance() {
|
2011-04-08 05:34:04 +00:00
|
|
|
if ((real)$this->LASTSESS_DURATION)
|
|
|
|
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
|
|
|
|
else
|
|
|
|
return 0;
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function lastreceiveaggperformance() {
|
2011-04-08 05:34:04 +00:00
|
|
|
if ((real)$this->LASTSESS_DURATION)
|
|
|
|
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
|
|
|
|
else
|
|
|
|
return 0;
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// @todo This should return the system setting (cloptset), if the node setting is not configured.
|
|
|
|
public function txngroupmax() {
|
2011-05-23 15:04:40 +00:00
|
|
|
return $this->TXNGROUPMAX;
|
2011-04-05 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 05:03:05 +00:00
|
|
|
// Work out all the storage pools used by a node.
|
2011-05-30 09:27:08 +00:00
|
|
|
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
|
2011-05-23 15:04:40 +00:00
|
|
|
public function getStoragePools($dtype) {
|
2011-04-07 05:03:05 +00:00
|
|
|
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
|
|
|
|
}
|
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
|
2011-04-07 05:03:05 +00:00
|
|
|
private function _getpools($dtype) {
|
|
|
|
$this->pools[$dtype] = array();
|
|
|
|
|
2011-05-23 15:04:40 +00:00
|
|
|
foreach ($this->FILESPACE->find_all() as $fso)
|
|
|
|
foreach ($fso->storagepools($dtype) as $po)
|
2011-05-30 09:27:08 +00:00
|
|
|
if (! isset($this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME]))
|
|
|
|
$this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME] = $po;
|
2011-04-07 05:03:05 +00:00
|
|
|
|
|
|
|
return $this->pools[$dtype];
|
|
|
|
}
|
|
|
|
|
2011-05-29 01:41:36 +00:00
|
|
|
public function getAllStoragePoolsType($ptype) {
|
2011-05-30 09:27:08 +00:00
|
|
|
$result = array();
|
|
|
|
|
|
|
|
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
|
|
|
|
$result = array_merge($result,$this->getStoragePoolsType($btype,$ptype));
|
|
|
|
|
|
|
|
return $result;
|
2011-05-29 01:41:36 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 05:03:05 +00:00
|
|
|
// Return the storage pools used for a backup type
|
2011-05-29 01:41:36 +00:00
|
|
|
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
|
2011-05-23 15:04:40 +00:00
|
|
|
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
|
|
|
public function getStoragePoolsType($dtype,$ptype) {
|
2011-04-07 05:03:05 +00:00
|
|
|
if (! isset($this->pools[$dtype]))
|
|
|
|
$this->_getpools($dtype);
|
|
|
|
|
|
|
|
return isset($this->pools[$dtype][$ptype]) ? $this->pools[$dtype][$ptype] : array();
|
|
|
|
}
|
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
// $dtype is BACKUP or ARCHIVE
|
|
|
|
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
|
|
|
public function getStorageModeVols($dtype,$ptype,$spo='') {
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
foreach ($this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->find_all() as $vo)
|
|
|
|
if ((! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $ptype)
|
|
|
|
if (! isset($result[$vo->VOLUME_NAME]))
|
|
|
|
$result[$vo->VOLUME_NAME] = $vo;
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
|
|
|
public function getStorageTypeVols($ptype,$spo='') {
|
|
|
|
$result = array();
|
2011-05-29 01:41:36 +00:00
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
|
|
|
|
$result = array_merge($result,$this->getStorageModeVols($ctype,$ptype,$spo));
|
2011-05-29 01:41:36 +00:00
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
return $result;
|
2011-05-29 01:41:36 +00:00
|
|
|
}
|
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
|
|
|
|
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
|
|
|
public function getStorageModeFiles($dtype,$ptype,$spo='') {
|
2011-05-23 15:04:40 +00:00
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
foreach ($this->FILESPACE->find_all() as $fo)
|
2011-05-30 09:27:08 +00:00
|
|
|
foreach ($fo->OCCUPANCY->where('TYPE','=',$dtype)->find_all() as $oa)
|
|
|
|
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
|
2011-05-23 15:04:40 +00:00
|
|
|
$count += $oa->NUM_FILES;
|
|
|
|
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
public function getStorageTypeFiles($ptype,$spo='') {
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
|
|
|
|
$count += $this->getStorageModeFiles($btype,$ptype,$spo);
|
|
|
|
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
|
|
|
|
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
|
|
|
|
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
|
|
|
|
public function getStorageModeData($dtype,$ptype,$spo='') {
|
2011-05-23 15:04:40 +00:00
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
foreach ($this->FILESPACE->find_all() as $fo)
|
2011-05-30 09:27:08 +00:00
|
|
|
foreach ($fo->OCCUPANCY->where('TYPE','=',$dtype)->find_all() as $oa)
|
|
|
|
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
|
2011-05-23 15:04:40 +00:00
|
|
|
$count += $oa->LOGICAL_MB;
|
|
|
|
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
|
2011-05-30 09:27:08 +00:00
|
|
|
public function getStorageTypeData($ptype,$spo='') {
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
|
|
|
|
$count += $this->getStorageModeData($btype,$ptype,$spo);
|
|
|
|
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
|
2011-05-23 15:04:40 +00:00
|
|
|
// Return the volumes that this node uses
|
|
|
|
// $dtype is BACKUP or ARCHIVE
|
|
|
|
public function volumes($dtype) {
|
|
|
|
$volumes = array();
|
|
|
|
|
2011-05-28 09:46:46 +00:00
|
|
|
$v = array();
|
2011-05-23 15:04:40 +00:00
|
|
|
foreach ($this->VOLUMEUSAGE->where('COPY_TYPE','=',$dtype)->order_by('STGPOOL_NAME,FILESPACE_NAME')->find_all() as $vol)
|
2011-05-28 09:46:46 +00:00
|
|
|
if (! in_array($vol->VOLUME->VOLUME_NAME,$v)) {
|
|
|
|
$volumes[$vol->STGPOOL_NAME][] = $vol->VOLUME;
|
|
|
|
array_push($v,$vol->VOLUME->VOLUME_NAME);
|
|
|
|
}
|
2011-05-23 15:04:40 +00:00
|
|
|
|
|
|
|
return $volumes;
|
|
|
|
}
|
|
|
|
|
2011-04-05 23:12:31 +00:00
|
|
|
/**
|
|
|
|
* Get all the nodes by OS
|
|
|
|
*/
|
|
|
|
public function byos() {
|
|
|
|
$a = $this->select('count(*) AS node_name,platform_name')
|
|
|
|
->group_by('platform_name')
|
|
|
|
->order_by('platform_name');
|
|
|
|
|
|
|
|
return $a->find_all();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|