Initial node display
This commit is contained in:
56
application/classes/model/filespace.php
Normal file
56
application/classes/model/filespace.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package PTA
|
||||
* @subpackage File Spaces
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 phpTSMadmin Development Team
|
||||
* @license http://phptsmadmin.sf.net/license.html
|
||||
*/
|
||||
class Model_FILESPACE extends ORMTSM {
|
||||
protected $_table_name = 'FILESPACES';
|
||||
protected $_primary_key = 'FILESPACE_NAME';
|
||||
protected $_has_many = array(
|
||||
'VOLUMEUSAGE'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'),
|
||||
'OCCUPANCY'=>array('foreign_key'=>array('NODE_NAME','FILESPACE_NAME'),'far_key'=>'FILESPACE_NAME'),
|
||||
);
|
||||
|
||||
protected $_formats = array(
|
||||
'BACKUP_END'=>array('ORMTSM::date'=>array('d-M-Y')),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'NODE_NAME'=>'ASC',
|
||||
);
|
||||
|
||||
public function utilsation() {
|
||||
return $this->CAPACITY * ($this->PCT_UTIL/100);
|
||||
}
|
||||
|
||||
public function storagepools($dtype) {
|
||||
$pool = array();
|
||||
|
||||
foreach ($this->VOLUMEUSAGE
|
||||
->select('STGPOOL_NAME')
|
||||
->where('COPY_TYPE','=',$dtype)
|
||||
->group_by('STGPOOL_NAME')
|
||||
->order_by('STGPOOL_NAME')
|
||||
->find_all() as $vo) {
|
||||
|
||||
array_push($pool,$vo->STGPOOL_NAME);
|
||||
}
|
||||
|
||||
return $pool;
|
||||
}
|
||||
|
||||
public function pool_logical_util($pool) {
|
||||
return $this->OCCUPANCY->where('STGPOOL_NAME','=',$pool)->find()->LOGICAL_MB;
|
||||
}
|
||||
|
||||
public function pool_numvols($pool) {
|
||||
return $this->VOLUMEUSAGE->where('STGPOOL_NAME','=',$pool)->find_all()->count();
|
||||
}
|
||||
}
|
||||
?>
|
@@ -12,6 +12,9 @@
|
||||
class Model_NODE extends ORMTSM {
|
||||
protected $_table_name = 'NODES';
|
||||
protected $_primary_key = 'NODE_NAME';
|
||||
protected $_has_many = array(
|
||||
'FILESPACE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'FILESPACE_NAME'),
|
||||
);
|
||||
|
||||
protected $_formats = array(
|
||||
'REG_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
|
||||
@@ -29,6 +32,9 @@ class Model_NODE extends ORMTSM {
|
||||
'NODE_NAME'=>'ASC',
|
||||
);
|
||||
|
||||
// Pools used by a node.
|
||||
private $pools = array();
|
||||
|
||||
public function tsmclientversion() {
|
||||
return sprintf('%s.%s.%s.%s',$this->CLIENT_VERSION,$this->CLIENT_RELEASE,$this->CLIENT_LEVEL,$this->CLIENT_SUBLEVEL);
|
||||
}
|
||||
@@ -42,33 +48,33 @@ class Model_NODE extends ORMTSM {
|
||||
}
|
||||
|
||||
public function lasttransferpercent() {
|
||||
return number_format(100-($this->LASTSESS_IDLEWAIT+$this->LASTSESS_COMMWAIT+$this->LASTSESS_MEDIAWAIT),2);
|
||||
return 100-($this->LASTSESS_IDLEWAIT+$this->LASTSESS_COMMWAIT+$this->LASTSESS_MEDIAWAIT);
|
||||
}
|
||||
|
||||
public function lasttransfertime() {
|
||||
return number_format($this->LASTSESS_DURATION*($this->lasttransferpercent()/100),2);
|
||||
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
|
||||
}
|
||||
|
||||
public function lastsendperformance() {
|
||||
if ($this->lasttransfertime())
|
||||
return number_format($this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024,2);
|
||||
return $this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024;
|
||||
else
|
||||
return _('N/A');
|
||||
}
|
||||
|
||||
public function lastreceiveperformance() {
|
||||
if ($this->lasttransfertime())
|
||||
return number_format($this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024,2);
|
||||
return $this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024;
|
||||
else
|
||||
return _('N/A');
|
||||
}
|
||||
|
||||
public function lastsendaggperformance() {
|
||||
return number_format($this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024,2);
|
||||
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
|
||||
}
|
||||
|
||||
public function lastreceiveaggperformance() {
|
||||
return number_format($this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024,2);
|
||||
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
|
||||
}
|
||||
|
||||
// @todo This should return the system setting (cloptset), if the node setting is not configured.
|
||||
@@ -76,6 +82,36 @@ class Model_NODE extends ORMTSM {
|
||||
return $this->display('TXNGROUPMAX');
|
||||
}
|
||||
|
||||
// Work out all the storage pools used by a node.
|
||||
// $dtype is BACKUP or ARCHIVE
|
||||
public function storagepools($dtype) {
|
||||
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
|
||||
}
|
||||
|
||||
private function _getpools($dtype) {
|
||||
$this->pools[$dtype] = array();
|
||||
|
||||
foreach ($this->FILESPACE->find_all() as $fso) {
|
||||
foreach ($fso->storagepools($dtype) as $pool_name) {
|
||||
$po = ORM::Factory('stgpool',$pool_name);
|
||||
|
||||
if (! isset($this->pools[$dtype][$po->POOLTYPE]) OR ! in_array($pool_name,$this->pools[$dtype][$po->POOLTYPE]))
|
||||
$this->pools[$dtype][$po->POOLTYPE][] = $pool_name;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->pools[$dtype];
|
||||
}
|
||||
|
||||
// Return the storage pools used for a backup type
|
||||
// $dtype is BACKUP or ARCHIVE
|
||||
public function getStoragePools($dtype,$ptype) {
|
||||
if (! isset($this->pools[$dtype]))
|
||||
$this->_getpools($dtype);
|
||||
|
||||
return isset($this->pools[$dtype][$ptype]) ? $this->pools[$dtype][$ptype] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the nodes by OS
|
||||
*/
|
||||
|
27
application/classes/model/occupancy.php
Normal file
27
application/classes/model/occupancy.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package PTA
|
||||
* @subpackage Occupancy
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 phpTSMadmin Development Team
|
||||
* @license http://phptsmadmin.sf.net/license.html
|
||||
*/
|
||||
class Model_OCCUPANCY extends ORMTSM {
|
||||
protected $_table_name = 'OCCUPANCY';
|
||||
protected $_primary_key = 'FILESPACE_NAME';
|
||||
protected $_has_many = array(
|
||||
);
|
||||
|
||||
protected $_formats = array(
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'NODE_NAME'=>'ASC',
|
||||
'FILESPACE_NAME'=>'ASC',
|
||||
'STGPOOL_NAME'=>'ASC',
|
||||
);
|
||||
}
|
||||
?>
|
25
application/classes/model/stgpool.php
Normal file
25
application/classes/model/stgpool.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package PTA
|
||||
* @subpackage Storage Pools
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 phpTSMadmin Development Team
|
||||
* @license http://phptsmadmin.sf.net/license.html
|
||||
*/
|
||||
class Model_STGPOOL extends ORMTSM {
|
||||
protected $_table_name = 'STGPOOLS';
|
||||
protected $_primary_key = 'STGPOOL_NAME';
|
||||
protected $_has_many = array(
|
||||
);
|
||||
|
||||
protected $_formats = array(
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'STGPOOL_NAME'=>'ASC',
|
||||
);
|
||||
}
|
||||
?>
|
27
application/classes/model/volumeusage.php
Normal file
27
application/classes/model/volumeusage.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package PTA
|
||||
* @subpackage Volume Usage
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 phpTSMadmin Development Team
|
||||
* @license http://phptsmadmin.sf.net/license.html
|
||||
*/
|
||||
class Model_VOLUMEUSAGE extends ORMTSM {
|
||||
protected $_table_name = 'VOLUMEUSAGE';
|
||||
protected $_primary_key = 'FILESPACE_NAME';
|
||||
protected $_has_many = array(
|
||||
);
|
||||
|
||||
protected $_formats = array(
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'NODE_NAME'=>'ASC',
|
||||
'FILESPACE_NAME'=>'ASC',
|
||||
'VOLUME_NAME'=>'ASC',
|
||||
);
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user