Initial node display

This commit is contained in:
Deon George 2011-04-07 15:03:05 +10:00
parent 6d858a982a
commit d053493eeb
11 changed files with 485 additions and 8 deletions

View File

@ -0,0 +1,79 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides information on TSM Nodes.
*
* @package PTA
* @subpackage Nodes
* @category Controllers
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Controller_NODE extends Controller_TemplateDefault {
protected $control = array('Client Nodes'=>'node');
/**
* Default Index for Controller
*/
public function action_index() {
$no = ORM::factory('node');
$output = '';
$output .= sprintf(_('This server has <b>%s</b> defined nodes.'),$no->count_all());
$output .= '<br/>';
$output .= '<br/>';
$select = array();
$select[NULL] = '';
foreach ($no->find_all() as $node)
$select[$node->NODE_NAME] = $node->NODE_NAME;
$output .= Form::open('/node/detail',array('id'=>'node_detail'));
$output .= sprintf('%s: %s',_('Choose a new to view'),Form::select('node_name',$select,NULL,array('id'=>'node_name')));
$output .= Form::submit('form_submit',_('Go'));
$output .= Form::close();
Script::add(array(
'type'=>'stdin',
'data'=>'
$(document).ready(function () {$("#node_name").change(function () {
$("#node_detail").trigger("submit");
});});'
));
Block::add(array(
'title'=>_('TSM Nodes'),
'body'=>$output,
));
$this->template->content = Block::factory();
}
public function action_detail($node_name=NULL) {
if (is_null($node_name) AND (empty($_POST['node_name']) OR ! $node_name = $_POST['node_name']))
throw new Kohana_Exception('Missing NODE_NAME');
$no = ORM::factory('node',$node_name);
$output = View::factory('nodes/detail')
->set('node',$no);
Block::add(array(
'title'=>sprintf('%s %s',_('Detailed Node Information for'),$no->NODE_NAME),
'body'=>$output,
));
$output = View::factory('nodes/detail_filesystem')
->set('node',$no);
Block::add(array(
'title'=>_('Protected File System Information'),
'body'=>$output,
));
$this->template->content = Block::factory();
}
}
?>

View File

@ -19,15 +19,19 @@ class Database_TSM_Result extends Database_Result {
{
parent::__construct($result, $sql, $as_object, $params);
$start = FALSE;
foreach ($result as $line) {
if (! trim($line)) {
$this->_internal_row++;
if ($start)
$this->_internal_row++;
continue;
}
list($k,$v) = explode(':',$line,2);
$this->_rows[$this->_internal_row][trim($k)] = trim($v);
$start = TRUE;
}
$this->_total_rows = $this->_internal_row;

View 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();
}
}
?>

View File

@ -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
*/

View 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',
);
}
?>

View 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',
);
}
?>

View 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',
);
}
?>

View File

@ -23,7 +23,7 @@ class ORM extends Kohana_ORM {
// If we have found our item return
if ($this->_loaded)
return;
return $object;
}
}

View File

@ -13,6 +13,8 @@
abstract class ORMTSM extends ORM {
// Suppress ORMs inclusion of <table_name>.*
protected $_disable_wild_select = TRUE;
// Suppress ORMs inclusion of <table_name>. to column joins
protected $_disable_join_table_name = TRUE;
// Enable the formating of columns
protected $_object_formated = array();

View File

@ -0,0 +1,141 @@
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;">
<table class="box-full">
<tr>
<td class="head" colspan="2">Node Information</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td style="width: 40%;">Node Name</td>
<td style="width: 60%;" class="head"><?php echo $node->display('NODE_NAME'); ?> (<?php echo $node->display('TCP_ADDRESS'); ?>)</td>
</tr>
<tr>
<td>Operating Sytem</td>
<td class="head"><?php printf('%s (%s)',$node->display('PLATFORM_NAME'),$node->display('CLIENT_OS_LEVEL')); ?></td>
</tr>
<tr>
<td>TSM Client Version</td>
<td class="head"><?php echo $node->tsmclientversion(); ?></td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>Date Registered</td>
<td class="head"><?php echo $node->display('REG_TIME'); ?> (by <?php echo $node->display('REG_ADMIN'); ?>)</td>
</tr>
<tr>
<td>Date Last Password Change</td>
<td class="head"><?php echo $node->display('PWSET_TIME'); ?></td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>Password Expiry</td>
<td class="head"><?php echo $node->passexp(); ?></td>
</tr>
<tr>
<td>Invalid Password Count</td>
<td class="head"><?php echo $node->display('INVALID_PW_COUNT'); ?> (<?php echo $node->LOCKED == 'NO' ? _('Not Locked') : _('Locked'); ?>)</td>
</tr>
</table>
</td>
<td style="width: 50%; vertical-align: top;">
<table width="100%">
<tr>
<td class="head" colspan="2">Last Backup Performance Information</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td style="width: 40%;">Last Access</td>
<td style="width: 60%;" class="head"><?php echo $node->display('LASTACC_TIME'); ?></td>
</tr>
<tr>
<td>Last Sent</td>
<td class="head"><?php echo number_format($node->LASTSESS_SENT/1024/1024,2); ?> MB</td>
</tr>
<tr>
<td>Last Receive</td>
<td class="head"><?php echo number_format($node->LASTSESS_RECVD/1024/1024,2); ?> MB</td>
</tr>
<tr>
<td>Last Duration</td>
<td class="head"><?php echo number_format($node->LASTSESS_DURATION/60,2); ?> min</td>
</tr>
<tr>
<td>Last Session Idle Wait Percent</td>
<td class="head"><?php echo $node->display('LASTSESS_IDLEWAIT'); ?>% (<?php echo number_format($node->LASTSESS_DURATION*($node->LASTSESS_IDLEWAIT/100),2); ?>s)</td>
</tr>
<tr>
<td>Last Session Comm Wait Percent</td>
<td class="head"><?php echo $node->display('LASTSESS_COMMWAIT'); ?>% (<?php echo number_format($node->LASTSESS_DURATION*($node->LASTSESS_COMMWAIT/100),2); ?>s)</td>
</tr>
<tr>
<td>Last Session Media Wait Percent</td>
<td class="head"><?php echo $node->display('LASTSESS_MEDIAWAIT'); ?>% (<?php echo number_format($node->LASTSESS_DURATION*($node->LASTSESS_MEDIAWAIT/100),2); ?>s)</td>
</tr>
<tr>
<td>Last Session Transfer Percent</td>
<td class="head"><?php echo number_format($node->lasttransferpercent(),2); ?>% (<?php echo number_format($node->lasttransfertime(),2); ?>s)</td>
</tr>
<tr>
<td>Last Session Send Performance</td>
<td class="head"><?php echo number_format($node->lastsendperformance(),2); ?> MB/s (<?php echo number_format($node->lastsendaggperformance(),2); ?> MB/s Aggregate)</td>
</tr>
<tr>
<td>Last Session Receive Performance</td>
<td class="head"><?php echo number_format($node->lastreceiveperformance(),2); ?> MB/s (<?php echo number_format($node->lastreceiveaggperformance(),2); ?> MB/s Aggregate)</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 50%; vertical-align: top;">
<table class="box-full">
<tr>
<td class="head" colspan="2">Backup Settings</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td style="width: 40%;">Client Option Set</td>
<td style="width: 60%;" class="head"><?php echo $node->display('OPTION_SET'); ?></td>
</tr>
<tr>
<td>Collocation Group</td>
<td class="head"><?php echo $node->COLLOCGROUP_NAME ? $node->display('COLLOCGROUP_NAME') : 'Not Set'; ?></td>
</tr>
<tr>
<td>Client Compression</td>
<td class="head"><?php echo $node->display('COMPRESSION'); ?></td>
</tr>
<tr>
<td>TXN Group Max</td>
<td class="head"><?php echo $node->txngroupmax(); ?></td>
</tr>
<tr>
<td>Delete Archives</td>
<td class="head"><?php echo $node->display('ARCHDELETE'); ?></td>
</tr>
<tr>
<td>Delete Backups</td>
<td class="head"><?php echo $node->display('BACKDELETE'); ?></td>
</tr>
<tr>
<td>Keep Mount Points</td>
<td class="head"><?php echo $node->display('KEEP_MP'); ?> (<?php echo $node->display('MAX_MP_ALLOWED'); ?>)</td>
</tr>
</table>
</td>
<td style="width: 50%; vertical-align: top;">
[PERFORMANCE PIE-GRAPH?]
</td>
</tr>
</table>

View File

@ -0,0 +1,80 @@
<table width="100%">
<tr>
<?php if ($node->storagepools('BACKUP')) { ?>
<td style="width: 50%; vertical-align: top;">
<table class="box-full">
<tr>
<td class="head" colspan="2">Backup Information</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>File Space</td>
<td>Last Date</td>
<td style="text-align: right;">Utilisation</td>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type)
if (count($pools = $node->getStoragePools('BACKUP',$type)))
foreach ($pools as $pool_name) { ?>
<td style="text-align: right;"><?php echo $pool_name; ?> <span style="vertical-align: super; font-size: 60%;"><?echo $type; ?></span></td>
<?php } ?>
</tr>
<?php foreach ($node->FILESPACE->find_all() as $fso) { ?>
<tr>
<td class="head"><?php echo $fso->display('FILESPACE_NAME'); ?></td>
<td class="head"><?php echo $fso->display('BACKUP_END'); ?></td>
<td class="head" style="text-align: right;"><?php echo number_format($fso->utilsation(),2); ?></td>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type)
if (count($pools = $node->getStoragePools('BACKUP',$type)))
foreach ($pools as $pool_name) { ?>
<td class="head" style="text-align: right;"><?php echo number_format($fso->pool_logical_util($pool_name),2); ?> (<?php echo $fso->pool_numvols($pool_name); ?>)</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</td>
<?php } ?>
<td style="width: 50%; vertical-align: top;">
&nbsp;
</td>
</tr>
<tr>
<?php if ($node->storagepools('ARCHIVE')) { ?>
<td style="width: 50%; vertical-align: top;">
<table class="box-full">
<tr>
<td class="head" colspan="2">Backup Information</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>File Space</td>
<td>Utilisation</td>
<td>Last Date</td>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type)
if (count($pools = $node->getStoragePools('ARCHIVE',$type)))
foreach ($pools as $pool_name) { ?>
<td style="text-align: right;"><?php echo $pool_name; ?> <span style="vertical-align: super; font-size: 60%;"><?echo $type; ?></span></td>
<?php } ?>
</tr>
<?php foreach ($node->FILESPACE->find_all() as $fso) { ?>
<tr>
<td class="head"><?php echo $fso->display('FILESPACE_NAME'); ?></td>
<td class="head"><?php echo number_format($fso->utilsation(),2); ?></td>
<td class="head"><?php echo $fso->display('BACKUP_END'); ?></td>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type)
if (count($pools = $node->getStoragePools('ARCHIVE',$type)))
foreach ($pools as $pool_name) { ?>
<td class="head" style="text-align: right;"><?php echo number_format($fso->pool_logical_util($pool_name),2); ?> (<?php echo $fso->pool_numvols($pool_name); ?>)</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</td>
<?php } ?>
<td style="width: 50%; vertical-align: top;">
&nbsp;
</td>
</tr>
</table>