Updates to node display

This commit is contained in:
Deon George 2011-04-08 15:34:04 +10:00
parent d053493eeb
commit 8814447096
10 changed files with 53 additions and 74 deletions

View File

@ -94,7 +94,6 @@ class Database_TSM extends Database {
$result = $this->query(Database::SELECT,'SELECT server_name,platform,version,release,level,sublevel FROM status');
//echo Kohana::debug($result);die();
if ($result)
return TSM::instance()->set($username,$password,$result);
else
@ -163,10 +162,15 @@ class Database_TSM extends Database {
}
}
private function clear() {
$this->_query_msg_codes = array();
}
public function query($type, $sql, $as_object = FALSE, array $params = NULL)
{
// Make sure the database is connected
$this->_connection or $this->connect();
$this->clear();
if ( ! empty($this->_config['profiling']))
{
@ -174,6 +178,10 @@ class Database_TSM extends Database {
$benchmark = Profiler::start("Database ({$this->_instance})", $sql);
}
// We need to escape any back slashes, since the exec will transpose them
// @todo Is there a better way of doing this?
$sql = str_replace('\\','\\\\',$sql);
// Execute the query
$stderr = exec($this->_connection.'"'.$sql.'"',$stdout,$rc);
@ -187,7 +195,7 @@ class Database_TSM extends Database {
// If we got a no data code
if (array_intersect($this->_query_msg_codes,$this->nodata_codes)) {
$result = array(0);
$result = array();
$rc = 0;
}

View File

@ -73,7 +73,7 @@ class Database_TSM_Result extends Database_Result {
// Return an object of given class name
$o = new $this->_as_object;
return $o->_load_values($this->_rows[$this->_current_row]);
return $o->values($this->_rows[$this->_current_row]);
}
else
{

View File

@ -11,6 +11,8 @@
class Model_Auth_UserDefault extends Model_Auth_User {
protected $_table_names_plural = FALSE;
protected $_disable_wild_select = TRUE;
protected $_disable_join_table_name = TRUE;
protected $_disable_limit = TRUE;
// Validation rules
protected $_rules = array(

View File

@ -32,9 +32,9 @@ class Model_FILESPACE extends ORMTSM {
public function storagepools($dtype) {
$pool = array();
foreach ($this->VOLUMEUSAGE
foreach ($this->OCCUPANCY
->select('STGPOOL_NAME')
->where('COPY_TYPE','=',$dtype)
->where('TYPE','=',$dtype)
->group_by('STGPOOL_NAME')
->order_by('STGPOOL_NAME')
->find_all() as $vo) {

View File

@ -52,29 +52,38 @@ class Model_NODE extends ORMTSM {
}
public function lasttransfertime() {
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
if ($this->LASTSESS_DURATION)
return $this->LASTSESS_DURATION*($this->lasttransferpercent()/100);
else
return 0;
}
public function lastsendperformance() {
if ($this->lasttransfertime())
return $this->LASTSESS_SENT/$this->lasttransfertime()/1024/1024;
else
return _('N/A');
return 0;
}
public function lastreceiveperformance() {
if ($this->lasttransfertime())
return $this->LASTSESS_RECVD/$this->lasttransfertime()/1024/1024;
else
return _('N/A');
return 0;
}
public function lastsendaggperformance() {
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_SENT/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
}
public function lastreceiveaggperformance() {
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
if ((real)$this->LASTSESS_DURATION)
return $this->LASTSESS_RECVD/$this->LASTSESS_DURATION/1024/1024;
else
return 0;
}
// @todo This should return the system setting (cloptset), if the node setting is not configured.

View File

@ -1,43 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides the Kohana ORM for some TSM specific calls.
*
* @package PTA
* @subpackage ORM
* @category Overrides
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class ORM extends Kohana_ORM {
/**
* Override Kohana's FIND to remove the LIMIT
*/
public function find($id = NULL) {
// Since TSM doesnt support LIMIT, we'll use find_all() but return the first record
foreach ($this->find_all() as $object) {
// In TSM Primary Keys are in upper case
if (is_null($id) OR $object->{$object->_primary_key} == strtoupper($id))
$this->_load_values($object->_object);
// If we have found our item return
if ($this->_loaded)
return $object;
}
}
/**
* We need to call our own _load_values() to support find() and TSM::result()
*
* (Since _load_values is protected, we need to make it public here,
* so that it can be called in TSM::result().)
*
* @see TSM::result
* @see ORM::find
*/
public function _load_values(array $values) {
return parent::_load_values($values);
}
}
?>

View File

@ -15,6 +15,8 @@ abstract class ORMTSM extends ORM {
protected $_disable_wild_select = TRUE;
// Suppress ORMs inclusion of <table_name>. to column joins
protected $_disable_join_table_name = TRUE;
// Suppress ORMs use of limit
protected $_disable_limit = TRUE;
// Enable the formating of columns
protected $_object_formated = array();
@ -48,7 +50,7 @@ abstract class ORMTSM extends ORM {
$value = $this->__get($column);
// If some of our fields need to be formated for display purposes.
if ($this->_loaded AND ! $this->_formated AND $this->_formats)
if ($value AND ! $this->_formated AND $this->_formats)
$this->_format();
if (isset($this->_object_formated[$column]))

View File

@ -16,6 +16,7 @@ return array(
'stanza' => '',
'client_errorlogname' => '/tmp/pta-tsm-errorlog.log',
'date_format' => 'd-m-Y',
'tsmpooltypes' => array('PRIMARY','ACTIVEDATA','COPY'),
'email_admin_only'=> array(
'method'=>array('wurley@users.sf.net'=>'Deon George'),
),

View File

@ -47,7 +47,7 @@
<td style="width: 50%; vertical-align: top;">
<table width="100%">
<tr>
<td class="head" colspan="2">Last Backup Performance Information</td>
<td class="head" colspan="2">Last Session Performance Information</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>

View File

@ -1,11 +1,11 @@
<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>
<?php if ($node->storagepools('Bkup')) { ?>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
@ -14,65 +14,65 @@
<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)))
if (count($pools = $node->getStoragePools('Bkup',$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>
<?php $i=0;foreach ($node->FILESPACE->find_all() as $fso) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<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)))
if (count($pools = $node->getStoragePools('Bkup',$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>
<td class="head" style="text-align: right; vertical-align: top;"><?php echo number_format($fso->pool_logical_util($pool_name),2); ?> (<?php echo $fso->pool_numvols($pool_name); ?>)</td>
<?php } ?>
</tr>
<?php } ?>
<?php } else { ?>
<tr><td>There is NO Backup Data for this Node.</td></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>
<td class="head" colspan="2">Archive Information</td>
</tr>
<?php if ($node->storagepools('Arch')) { ?>
<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)))
if (count($pools = $node->getStoragePools('Arch',$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>
<?php $i=0;foreach ($node->FILESPACE->find_all() as $fso) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<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)))
if (count($pools = $node->getStoragePools('Arch',$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>
<td class="head" style="text-align: right; vertical-align: top;"><?php echo number_format($fso->pool_logical_util($pool_name),2); ?> (<?php echo $fso->pool_numvols($pool_name); ?>)</td>
<?php } ?>
</tr>
<?php } ?>
<?php } else { ?>
<tr><td>There is NO Archive Data for this Node.</td></tr>
<?php } ?>
</table>
</td>
<?php } ?>
<td style="width: 50%; vertical-align: top;">
&nbsp;
</td>