From d29b29fa072abc41af6ecd05fa930e562762107c Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 30 May 2011 19:27:08 +1000 Subject: [PATCH] Added Node Summary --- application/bootstrap.php | 20 ++-- .../classes/controller/lnapp/default.php | 7 ++ application/classes/controller/node.php | 30 +++-- application/classes/controller/tree.php | 8 ++ application/classes/database/tsm.php | 2 +- application/classes/http/exception/404.php | 2 +- application/classes/model/domain.php | 87 ++++++++++++++ application/classes/model/filespace.php | 4 +- application/classes/model/node.php | 77 +++++++++---- application/config/config.php | 4 +- application/views/nodes/detail_filesystem.php | 4 +- application/views/nodes/detail_volumes.php | 14 +-- application/views/nodes/summary.php | 108 ++++++++++++++++++ 13 files changed, 305 insertions(+), 62 deletions(-) create mode 100644 application/classes/model/domain.php create mode 100644 application/views/nodes/summary.php diff --git a/application/bootstrap.php b/application/bootstrap.php index e88b82f..64a7cb9 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -118,16 +118,6 @@ Route::set('sections', '/(/(/(/)))', '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', '((/(/)))') - ->defaults(array( - 'controller' => 'welcome', - 'action' => 'index', - )); - // Static file serving (CSS, JS, images) Route::set('default/media', 'media(/)', array('file' => '.+')) ->defaults(array( @@ -135,4 +125,14 @@ Route::set('default/media', 'media(/)', 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', '((/(/)))', array('id' => '[a-zA-Z0-9_.]+')) + ->defaults(array( + 'controller' => 'welcome', + 'action' => 'index', + )); ?> diff --git a/application/classes/controller/lnapp/default.php b/application/classes/controller/lnapp/default.php index 59563de..b004078 100644 --- a/application/classes/controller/lnapp/default.php +++ b/application/classes/controller/lnapp/default.php @@ -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); + } } ?> diff --git a/application/classes/controller/node.php b/application/classes/controller/node.php index 8057ec1..18a258a 100644 --- a/application/classes/controller/node.php +++ b/application/classes/controller/node.php @@ -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) + )); + } } ?> diff --git a/application/classes/controller/tree.php b/application/classes/controller/tree.php index 8eac2bc..d661c3d 100644 --- a/application/classes/controller/tree.php +++ b/application/classes/controller/tree.php @@ -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', diff --git a/application/classes/database/tsm.php b/application/classes/database/tsm.php index 63f2c9d..569cc64 100644 --- a/application/classes/database/tsm.php +++ b/application/classes/database/tsm.php @@ -173,7 +173,7 @@ class Database_TSM extends Database { } SystemMessage::TSM_Error($stdout,$sql); - return FALSE; + Request::current()->redirect('welcome'); } if (isset($benchmark)) diff --git a/application/classes/http/exception/404.php b/application/classes/http/exception/404.php index 1410764..a72b75d 100644 --- a/application/classes/http/exception/404.php +++ b/application/classes/http/exception/404.php @@ -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'); } } diff --git a/application/classes/model/domain.php b/application/classes/model/domain.php new file mode 100644 index 0000000..37356bd --- /dev/null +++ b/application/classes/model/domain.php @@ -0,0 +1,87 @@ +'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; + } +} +?> diff --git a/application/classes/model/filespace.php b/application/classes/model/filespace.php index c2ba9dc..0584214 100644 --- a/application/classes/model/filespace.php +++ b/application/classes/model/filespace.php @@ -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; } diff --git a/application/classes/model/node.php b/application/classes/model/node.php index d543222..2bd0b1c 100644 --- a/application/classes/model/node.php +++ b/application/classes/model/node.php @@ -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) { diff --git a/application/config/config.php b/application/config/config.php index 06cdb94..1d76aa6 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -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, ) ); ?> diff --git a/application/views/nodes/detail_filesystem.php b/application/views/nodes/detail_filesystem.php index 4eaba4d..2dbb0a2 100644 --- a/application/views/nodes/detail_filesystem.php +++ b/application/views/nodes/detail_filesystem.php @@ -53,7 +53,7 @@ - getStorageTypeVols($type); ?> + getStorageTypeVols($type)); ?> getStorageTypeFiles($type); ?> getStorageTypeData($type); ?> @@ -61,7 +61,7 @@   - getStorageTypeVols($type,$spo); ?> + getStorageTypeVols($type,$spo)); ?> getStorageTypeFiles($type,$spo); ?> getStorageTypeData($type,$spo); ?> diff --git a/application/views/nodes/detail_volumes.php b/application/views/nodes/detail_volumes.php index ae82741..a800ad2 100644 --- a/application/views/nodes/detail_volumes.php +++ b/application/views/nodes/detail_volumes.php @@ -1,12 +1,12 @@ - + $ctype) { ?> diff --git a/application/views/nodes/summary.php b/application/views/nodes/summary.php new file mode 100644 index 0000000..fedd817 --- /dev/null +++ b/application/views/nodes/summary.php @@ -0,0 +1,108 @@ +
- + - volumes($dtype)) { ?> + volumes($ctype)) { ?> @@ -22,7 +22,7 @@ - volumes($dtype) as $stgpool => $vols) { + volumes($ctype) as $stgpool => $vols) { $spo = ORM::factory('STGPOOL',$stgpool); ?> @@ -35,13 +35,13 @@ - - + + - +
 
Other FS Other Node
STGPOOL_NAME,$spo->RECLAIM,$spo->NUMSCRATCHUSED,$spo->MAXSCRATCH,$spo->DEVCLASSES->DEVTYPE); ?>
READ_ERRORS,$vol->WRITE_ERRORS); ?> display('EST_CAPACITY_MB'); ?> display('PCT_RECLAIM'); ?>getFSOnVol($dtype); ?>getNodesOnVol($dtype); ?>getFSOnVol($ctype); ?>getNodesOnVol($ctype); ?>
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Node Information for Nodes in Domain DOMAIN_NAME; ?>
 
+ + + + + + + + + + + NODE->find_all() as $no) { ?> + + + + + + + + + + + + +
NodeVersionLast AccessLast IP Addr(Vol/Fil/Dat)
NODE_NAME,$no->NODE_NAME); ?>tsmclientversion(); ?>display('LASTACC_TIME'); ?>display('TCP_ADDRESS'); ?>getStorageTypeVols($type)); ?>getStorageTypeFiles($type); ?>getStorageTypeData($type); ?>
+
 
Storage Pools used by nodes in this domain
 
+ + + + + + + + $ctype) { ?> + + + + + + + + + getStoragePoolsType($btype,$type) as $spo) { ?> + + + + + + + + + + +
Storage PoolVolsFilesMB
 
 STGPOOL_NAME; ?>getStorageModeVols($ctype,$type,$spo)); ?>getStorageModeFiles($btype,$type,$spo); ?>getStorageModeData($btype,$type,$spo); ?>
+
 
Sequential Volumes needed to restore Data for Nodes in this domain
 
 
Policy in this domain
 
 
Schedules used in this domain
 
+