This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/application/classes/model/node.php

127 lines
3.6 KiB
PHP
Raw Normal View History

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-04-07 05:03:05 +00:00
protected $_has_many = array(
'FILESPACE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'FILESPACE_NAME'),
);
2011-04-05 23:12:31 +00:00
protected $_formats = array(
'REG_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
'PWSET_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
'LASTACC_TIME'=>array('ORMTSM::date'=>array('d-M-Y')),
'LASTSESS_SENT'=>array('number_format'=>array(0)),
'LASTSESS_RECVD'=>array('number_format'=>array(0)),
'LASTSESS_DURATION'=>array('number_format'=>array(2)),
'LASTSESS_IDLEWAIT'=>array('number_format'=>array(2)),
'LASTSESS_COMMWAIT'=>array('number_format'=>array(2)),
'LASTSESS_MEDIAWAIT'=>array('number_format'=>array(2)),
);
protected $_sorting = array(
'NODE_NAME'=>'ASC',
);
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-07 05:03:05 +00:00
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
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
return _('N/A');
}
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
return _('N/A');
}
public function lastsendaggperformance() {
2011-04-07 05:03:05 +00:00
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
2011-04-05 23:12:31 +00:00
}
public function lastreceiveaggperformance() {
2011-04-07 05:03:05 +00:00
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
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() {
return $this->display('TXNGROUPMAX');
}
2011-04-07 05:03:05 +00:00
// 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();
}
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();
}
}
?>