Added Node Summary

This commit is contained in:
Deon George 2011-05-30 19:27:08 +10:00
parent d3b97ae485
commit d29b29fa07
13 changed files with 305 additions and 62 deletions

View File

@ -118,16 +118,6 @@ Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))',
'directory' => '('.implode('|',Kohana::config('config.method_directory')).')'
));
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
// Static file serving (CSS, JS, images)
Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
->defaults(array(
@ -135,4 +125,14 @@ Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
'action' => 'media',
'file' => NULL,
));
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id' => '[a-zA-Z0-9_.]+'))
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
?>

View File

@ -79,5 +79,12 @@ abstract class Controller_lnApp_Default extends Controller {
}
}
}
public function after() {
parent::after();
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
}
}
?>

View File

@ -53,37 +53,35 @@ $(document).ready(function () {$("#node_name").change(function () {
$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,
'body'=>View::factory('nodes/detail')->set('node',$no),
));
$output = View::factory('nodes/detail_filesystem')
->set('node',$no);
Block::add(array(
'title'=>_('Protected File System Information'),
'body'=>$output,
'body'=>View::factory('nodes/detail_filesystem')->set('node',$no),
));
$output = View::factory('nodes/detail_volumes')
->set('node',$no);
Block::add(array(
'title'=>_('Sequential Volume Usage Information'),
'body'=>$output,
'body'=>View::factory('nodes/detail_volumes')->set('node',$no),
));
$output = View::factory('nodes/detail_schedule')
->set('node',$no);
Block::add(array(
'title'=>_('Schedule Information'),
'body'=>$output,
'body'=>View::factory('nodes/detail_schedule')->set('node',$no),
));
}
public function action_summary() {
$do = ORM::factory('domain');
foreach ($do->find_all() as $domain)
Block::add(array(
'title'=>_('Node Information by Domain'),
'body'=>View::factory('nodes/summary')->set('do',$domain)
));
}
}
?>

View File

@ -31,6 +31,14 @@ class Controller_Tree extends Controller_lnApp_Tree {
'attr_href'=>URL::Site('/node'),
));
array_push($data,array(
'id'=>'node_summary',
'name'=>'Node Summary',
'state'=>'none',
'attr_id'=>'1',
'attr_href'=>URL::Site('/node/summary'),
));
array_push($data,array(
'id'=>'activity',
'name'=>'Server Activity Gantt',

View File

@ -173,7 +173,7 @@ class Database_TSM extends Database {
}
SystemMessage::TSM_Error($stdout,$sql);
return FALSE;
Request::current()->redirect('welcome');
}
if (isset($benchmark))

View File

@ -25,6 +25,6 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
));
Request::factory()->redirect('/welcome');
Request::factory()->redirect('welcome');
}
}

View File

@ -0,0 +1,87 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Domain
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_DOMAIN extends ORMTSM {
protected $_table_name = 'DOMAINS';
protected $_primary_key = 'DOMAIN_NAME'; // We need a primary key to detect that the object is loaded.
protected $_sorting = array(
'DOMAIN_NAME'=>'ASC',
);
protected $_has_many = array(
'NODE'=>array('foreign_key'=>'DOMAIN_NAME','far_key'=>'DOMAIN_NAME'),
);
// Pools used by a domain.
private $pools = array();
// Work out all the storage pools used by a domain.
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function getStoragePools($dtype) {
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
}
private function _getpools($dtype) {
$this->pools[$dtype] = array();
foreach ($this->NODE->find_all() as $no)
foreach ($no->getStoragePools($dtype) as $ptype => $stgpools)
foreach ($stgpools as $spo)
if (! isset($this->pools[$dtype][$ptype]) OR ! in_array($spo,$this->pools[$dtype][$ptype]))
$this->pools[$dtype][$ptype][] = $spo;
return $this->pools[$dtype];
}
// Return the storage pools used for a domain by backup type
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStoragePoolsType($dtype,$ptype) {
if (! isset($this->pools[$dtype]))
$this->_getpools($dtype);
return isset($this->pools[$dtype][$ptype]) ? $this->pools[$dtype][$ptype] : array();
}
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeVols($dtype,$ptype,$spo='') {
$result = array();
foreach ($this->NODE->find_all() as $no)
$result = array_merge($result,$no->getStorageModeVols($dtype,$ptype,$spo));
return $result;
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeFiles($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->NODE->find_all() as $no)
$count += $no->getStorageModeFiles($dtype,$ptype,$spo);
return $count;
}
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeData($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->NODE->find_all() as $no)
$count += $no->getStorageModeData($dtype,$ptype,$spo);
return $count;
}
}
?>

View File

@ -32,6 +32,7 @@ class Model_FILESPACE extends ORMTSM {
return $this->CAPACITY * ($this->PCT_UTIL/100);
}
// $dtype must be Bkup or Arch
public function storagepools($dtype) {
$pool = array();
@ -40,10 +41,9 @@ class Model_FILESPACE extends ORMTSM {
->where('TYPE','=',$dtype)
->group_by('STGPOOL_NAME')
->order_by('STGPOOL_NAME')
->find_all() as $oo) {
->find_all() as $oo)
array_push($pool,$oo->STGPOOL);
}
return $pool;
}

View File

@ -116,24 +116,30 @@ class Model_NODE extends ORMTSM {
}
// Work out all the storage pools used by a node.
// $dtype is BACKUP or ARCHIVE
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
public function getStoragePools($dtype) {
return isset($this->pools[$dtype]) ? $this->pools[$dtype] : $this->_getpools($dtype);
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
private function _getpools($dtype) {
$this->pools[$dtype] = array();
foreach ($this->FILESPACE->find_all() as $fso)
foreach ($fso->storagepools($dtype) as $po)
if (! isset($this->pools[$dtype][$po->POOLTYPE]) OR ! in_array($po->STGPOOL_NAME,$this->pools[$dtype][$po->POOLTYPE]))
$this->pools[$dtype][$po->POOLTYPE][] = $po;
if (! isset($this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME]))
$this->pools[$dtype][$po->POOLTYPE][$po->STGPOOL_NAME] = $po;
return $this->pools[$dtype];
}
public function getAllStoragePoolsType($ptype) {
return array_merge($this->getStoragePoolsType('Bkup',$ptype),$this->getStoragePoolsType('Arch',$ptype));
$result = array();
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$result = array_merge($result,$this->getStoragePoolsType($btype,$ptype));
return $result;
}
// Return the storage pools used for a backup type
@ -146,42 +152,73 @@ class Model_NODE extends ORMTSM {
return isset($this->pools[$dtype][$ptype]) ? $this->pools[$dtype][$ptype] : array();
}
// @todo This routine should be cached.
public function getStorageTypeVols($type,$spo='') {
$count = array();
// $dtype is BACKUP or ARCHIVE
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeVols($dtype,$ptype,$spo='') {
$result = array();
foreach ($this->VOLUMEUSAGE->find_all() as $vo)
if ((! $spo OR $vo->STGPOOL_NAME == $spo) AND $vo->STGPOOL->POOLTYPE == $type)
if (! in_array($vo->VOLUME_NAME,$count))
array_push($count,$vo->VOLUME_NAME);
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 count($count);
return $result;
}
// @todo This routine should be cached.
public function getStorageTypeFiles($type,$spo='') {
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageTypeVols($ptype,$spo='') {
$result = array();
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$result = array_merge($result,$this->getStorageModeVols($ctype,$ptype,$spo));
return $result;
}
// $dtype is BACKUP (Bkup) or ARCHIVE (Arch)
// $ptype is pool type (PRIMARY,ACTIVE,COPY)
public function getStorageModeFiles($dtype,$ptype,$spo='') {
$count = 0;
foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $type)
foreach ($fo->OCCUPANCY->where('TYPE','=',$dtype)->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
$count += $oa->NUM_FILES;
return $count;
}
// @todo This routine should be cached.
public function getStorageTypeData($type,$spo='') {
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='') {
$count = 0;
foreach ($this->FILESPACE->find_all() as $fo)
foreach ($fo->OCCUPANCY->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $type)
foreach ($fo->OCCUPANCY->where('TYPE','=',$dtype)->find_all() as $oa)
if ((! $spo OR $oa->STGPOOL_NAME == $spo) AND $oa->STGPOOL->POOLTYPE == $ptype)
$count += $oa->LOGICAL_MB;
return $count;
}
public function getStorageTypeData($ptype,$spo='') {
$count = 0;
foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype)
$count += $this->getStorageModeData($btype,$ptype,$spo);
return $count;
}
// Return the volumes that this node uses
// $dtype is BACKUP or ARCHIVE
public function volumes($dtype) {

View File

@ -16,6 +16,7 @@ return array(
'client_errorlogname' => '/tmp/pta-tsm-errorlog.log',
'date_format' => 'd-m-Y',
'tsmpooltypes' => array('PRIMARY','ACTIVEDATA','COPY'),
'tsmdatatypes' => array('Bkup'=>'BACKUP','Arch'=>'ARCHIVE'),
'email_admin_only'=> array(
'method'=>array('wurley@users.sf.net'=>'Deon George'),
),
@ -23,12 +24,9 @@ return array(
),
'method_security' => TRUE, // Enables Method Security. Setting to false means any method can be run without authentication
'site' => array(
'172.31.9.4'=>1,
),
'site_debug' => FALSE,
'site_mode' => array(
'172.31.9.4'=>Kohana::DEVELOPMENT,
'phptsmadmin.sf.net'=>Kohana::PRODUCTION,
)
);
?>

View File

@ -53,7 +53,7 @@
<?php $i=0; foreach (Kohana::config('config.tsmpooltypes') as $type) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data" colspan="2"><?php echo $type; ?></td>
<td class="data-right"><?php echo $node->getStorageTypeVols($type); ?></td>
<td class="data-right"><?php echo count($node->getStorageTypeVols($type)); ?></td>
<td class="data-right"><?php echo $node->getStorageTypeFiles($type); ?></td>
<td class="data-right"><?php echo $node->getStorageTypeData($type); ?></td>
</tr>
@ -61,7 +61,7 @@
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td>&nbsp;</td>
<td><?php echo $spo; ?></td>
<td class="right"><?php echo $node->getStorageTypeVols($type,$spo); ?></td>
<td class="right"><?php echo count($node->getStorageTypeVols($type,$spo)); ?></td>
<td class="right"><?php echo $node->getStorageTypeFiles($type,$spo); ?></td>
<td class="right"><?php echo $node->getStorageTypeData($type,$spo); ?></td>
</tr>

View File

@ -1,12 +1,12 @@
<table width="100%">
<?php foreach (array('BACKUP','ARCHIVE') as $dtype) { ?>
<?php foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype) { ?>
<tr>
<td style="width: 100%; vertical-align: top;">
<table class="box-full">
<tr>
<td class="head" colspan="2"><?php echo $dtype=='BACKUP' ? _('Backup Volumes') : _('Archive Volumes'); ?></td>
<td class="head" colspan="2"><?php echo $ctype=='BACKUP' ? _('Backup Volumes') : _('Archive Volumes'); ?></td>
</tr>
<?php if ($node->volumes($dtype)) { ?>
<?php if ($node->volumes($ctype)) { ?>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
@ -22,7 +22,7 @@
<td class="right">Other FS</td>
<td class="right">Other Node</td>
</tr>
<?php $i=0; foreach ($node->volumes($dtype) as $stgpool => $vols) {
<?php $i=0; foreach ($node->volumes($ctype) as $stgpool => $vols) {
$spo = ORM::factory('STGPOOL',$stgpool); ?>
<tr class="subhead"><td colspan="10"><?php printf('%s: Reclaim: %s%%, Scratch Usage: %s/%s, Device Type: %s',$spo->STGPOOL_NAME,$spo->RECLAIM,$spo->NUMSCRATCHUSED,$spo->MAXSCRATCH,$spo->DEVCLASSES->DEVTYPE); ?></td></tr>
<?php foreach ($vols as $vol) { ?>
@ -35,13 +35,13 @@
<td class="data-right"><?php printf('%s/%s',$vol->READ_ERRORS,$vol->WRITE_ERRORS); ?></td>
<td class="data-right"><?php echo $vol->display('EST_CAPACITY_MB'); ?></td>
<td class="data-right"><?php echo $vol->display('PCT_RECLAIM'); ?></td>
<td class="data-right"><?php echo $vol->getFSOnVol($dtype); ?></td>
<td class="data-right"><?php echo $vol->getNodesOnVol($dtype); ?></td>
<td class="data-right"><?php echo $vol->getFSOnVol($ctype); ?></td>
<td class="data-right"><?php echo $vol->getNodesOnVol($ctype); ?></td>
</tr>
<?php } ?>
<?php } ?>
<?php } else { ?>
<tr><td><?php echo $dtype=='BACKUP' ? _('There are NO Backup Volumes for this Node.') : _('There are NO Archive Volumes for this Node.'); ?></td></tr>
<tr><td><?php echo $ctype=='BACKUP' ? _('There are NO Backup Volumes for this Node.') : _('There are NO Archive Volumes for this Node.'); ?></td></tr>
<?php } ?>
</table>
</td>

View File

@ -0,0 +1,108 @@
<table width="100%">
<tr>
<td style="width: 100%; vertical-align: top;">
<table class="box-full">
<tr>
<td class="head">Node Information for Nodes in Domain <?php echo $do->DOMAIN_NAME; ?></td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td>Node</td>
<td>Version</td>
<td>Last Access</td>
<td>Last IP Addr</td>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type) { ?>
<td colspan="3" class="right"><?php echo $type; ?>(Vol/Fil/Dat)</td>
<?php } ?>
</tr>
<?php $i=0; foreach ($do->NODE->find_all() as $no) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo HTML::anchor('node/detail/'.$no->NODE_NAME,$no->NODE_NAME); ?></td>
<td class="data"><?php echo $no->tsmclientversion(); ?></td>
<td class="data"><?php echo $no->display('LASTACC_TIME'); ?></td>
<td class="data"><?php echo $no->display('TCP_ADDRESS'); ?></td>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type) { ?>
<td class="data-right"><?php echo count($no->getStorageTypeVols($type)); ?></td>
<td class="data-right"><?php echo $no->getStorageTypeFiles($type); ?></td>
<td class="data-right"><?php echo $no->getStorageTypeData($type); ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
</td>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="head">Storage Pools used by nodes in this domain</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>
<table width="50%" class="box-left">
<tr>
<td colspan="3">Storage Pool</td>
<td class="right">Vols</td>
<td class="right">Files</td>
<td class="right">MB</td>
</tr>
<?php foreach (Kohana::config('config.tsmdatatypes') as $btype => $ctype) { ?>
<tr class="subhead">
<td colspan="6"><?php echo $btype; ?></td>
</tr>
<?php foreach (Kohana::config('config.tsmpooltypes') as $type) { ?>
<tr class="subhead">
<td>&nbsp;</td>
<td colspan="5"><?php echo $type; ?></td>
</tr>
<?php $i=0; foreach ($do->getStoragePoolsType($btype,$type) as $spo) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td colspan="2">&nbsp;</td>
<td class="data"><?php echo $spo->STGPOOL_NAME; ?></td>
<td class="data-right"><?php echo count($do->getStorageModeVols($ctype,$type,$spo)); ?></td>
<td class="data-right"><?php echo $do->getStorageModeFiles($btype,$type,$spo); ?></td>
<td class="data-right"><?php echo $do->getStorageModeData($btype,$type,$spo); ?></td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
</table>
</td>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="head" colspan="2">Sequential Volumes needed to restore Data for Nodes in this domain</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="head" colspan="2">Policy in this domain</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="head" colspan="2">Schedules used in this domain</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>