Added Node Session

This commit is contained in:
Deon George 2012-12-12 15:00:03 +11:00
parent b415296c62
commit cf7f5256ae
7 changed files with 149 additions and 19 deletions

View File

@ -146,7 +146,7 @@ Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
* Set the routes. Each route must have a minimum of a name, a URI and a set of * Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI. * defaults for the URI.
*/ */
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.\-=]+')) Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.\-=,]+'))
->defaults(array( ->defaults(array(
'controller' => 'welcome', 'controller' => 'welcome',
'action' => 'index', 'action' => 'index',

View File

@ -52,5 +52,41 @@ class Controller_Node extends Controller_TemplateDefault_View {
$this->response->headers('Content-Type','application/json'); $this->response->headers('Content-Type','application/json');
$this->response->body($google->json()); $this->response->body($google->json());
} }
/**
* Return details of a specific node SESSION in the ACTIVITY LOG
* @param $id NODE,SESSION_ID,SESSION_START_DATE
*/
public function action_session() {
$id = $this->request->param('id');
if (substr_count($id,',') != 2) {
SystemMessage::add(array(
'title'=>_('Invalid ID'),
'body'=>sprintf(_('The session ID %s is invalid'),$id),
'type'=>'error',
));
return;
}
list($nid,$sid,$start) = explode(',',$id,3);
$no = ORM::factory('NODE',$nid);
if (! $no->loaded()) {
SystemMessage::add(array(
'title'=>_('Invalid Node'),
'body'=>sprintf(_('The Node ID %s is invalid'),$nid),
'type'=>'error',
));
return;
}
Block::add(array(
'title'=>sprintf(_('Session %s Detail for Node %s'),$sid,$no->display('NODE_NAME')),
'body'=>View::factory(sprintf('%s/clientsession',strtolower($this->request->controller())))->set('o',$no->actlog_session($sid,$start)),
));
}
} }
?> ?>

View File

@ -27,8 +27,25 @@ class Model_ACTLOG extends ORM_TSM {
private $_msgno_ba_transfer = array(4963,4966,4967,4964); private $_msgno_ba_transfer = array(4963,4966,4967,4964);
private $_msgno_ba_reduction = array(4968,4981,4976); private $_msgno_ba_reduction = array(4968,4981,4976);
public function exclude_ba() { /**
* Return the timestamp of the record in the ACTLOG
*/
public function FirstRec() {
return DB::query(Database::SELECT,'SELECT min(DATE_TIME) as DATE_TIME from ACTLOG')->cached(86400)->execute()->get('DATE_TIME');
}
/**
* Where class to exclude NODE backup messages
*/
public function ExcludeBA() {
return $this->where('MSGNO','NOT IN',array_merge($this->_msgno_ba_objects,$this->_msgno_ba_bytes,$this->_msgno_ba_transfer,$this->_msgno_ba_reduction)); return $this->where('MSGNO','NOT IN',array_merge($this->_msgno_ba_objects,$this->_msgno_ba_bytes,$this->_msgno_ba_transfer,$this->_msgno_ba_reduction));
} }
/**
* Return this ACTIVITY LOG start time in seconds since epoch
*/
public function start() {
return ORM_TSM::date($this->DATE_TIME,'U');
}
} }
?> ?>

View File

@ -25,8 +25,25 @@ class Model_ACTSUM extends ORM_TSM {
), ),
); );
/**
* Return if this ACTIVITY SUMMARY would be still in the ACTIVITY LOG
*/
public function inActLog() {
return ORM_TSM::date(ORM::factory('ACTLOG')->FirstRec(),'U') <= $this->start();
}
/**
* Return this ACTIVITY SUMMARY in GB
*/
public function bytes() { public function bytes() {
return (real)number_format($this->BYTES/1024/1024,0,'',''); return (real)number_format($this->BYTES/1024/1024,0,'','');
} }
/**
* Return this ACTIVITY SUMMARY start time in seconds since epoch
*/
public function start() {
return ORM_TSM::date($this->START_TIME,'U');
}
} }
?> ?>

View File

@ -115,6 +115,32 @@ class Model_NODE extends ORM_TSM {
), ),
); );
/**
* Get all the ACTIVITIY LOG for this NODE
*/
private function _actlog() {
Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__));
$k = sprintf('%s-%s',__METHOD__,$this->NODE_NAME);
$c = Kohana::$config->load('config')->cache;
if (is_null($result = Cache::instance($c)->get($k))) {
$result = array();
// In the interest of performance, we load all the records and get PHP to process it.
// Our ORM caching we reduce the hit on TSM.
foreach (ORM::factory('ACTLOG')->find_all() as $o)
if ($o->NODENAME == $this->NODE_NAME)
array_push($result,$o);
// @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300);
}
Log::instance()->add(LOG::DEBUG,'EXIT :method',array(':method'=>__METHOD__));
return $result;
}
/** /**
* Get all the ACTIVITY SUMMARY for this NODE * Get all the ACTIVITY SUMMARY for this NODE
*/ */
@ -303,7 +329,7 @@ class Model_NODE extends ORM_TSM {
if (is_null($result = Cache::instance($c)->get($k))) { if (is_null($result = Cache::instance($c)->get($k))) {
$result = array(); $result = array();
$result = $this->ACTLOG->exclude_ba()->find_all(); $result = $this->ACTLOG->ExcludeBA()->find_all();
// @todo Cache time should be configurble // @todo Cache time should be configurble
Cache::instance($c)->set($k,$result,300); Cache::instance($c)->set($k,$result,300);
@ -313,6 +339,21 @@ class Model_NODE extends ORM_TSM {
return $result; return $result;
} }
/**
* Get all the ACTIVITY LOG information for a SESSION
* @param $sid Session ID
* @param $start Session Start Time (to illiminate any duplication session data)
*/
public function actlog_session($sid,$start) {
$result = array();
foreach ($this->_actlog() as $alo)
if ($alo->SESSION == $sid AND $alo->start() >= $start)
array_push($result,$alo);
return $result;
}
/** /**
* Return the ACTIVITY of this NODE * Return the ACTIVITY of this NODE
* @param $type is Bkup/Arch/SpMg * @param $type is Bkup/Arch/SpMg
@ -340,7 +381,7 @@ class Model_NODE extends ORM_TSM {
} }
/** /**
* Return the Schedules for all activites of type * Return the Schedules used for all activites of type
* @param $type is Bkup/Arch/SpMg * @param $type is Bkup/Arch/SpMg
*/ */
public function act_schedules($type) { public function act_schedules($type) {

View File

@ -0,0 +1,19 @@
<!-- $o = ORM::factory('NODE')->actlog_session() -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Client Session Detail</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>Start</td>
<td>Message</td>
</tr>
<?php $i=0; foreach ($o as $alo) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo $alo->display('DATE_TIME'); ?></td>
<td class="data"><?php echo $alo->display('MESSAGE'); ?></td>
</tr>
<?php } ?>
</table>

View File

@ -27,22 +27,22 @@
<td class="right">Process</td> <td class="right">Process</td>
<td class="right">Success</td> <td class="right">Success</td>
</tr> </tr>
<?php $i=0; foreach ($o->act_bybtype($btype) as $ao) { ?> <?php $i=0; foreach ($o->act_bybtype($btype) as $aso) { ?>
<tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>"> <tr class="<?php echo $i++%2 ? 'odd' : 'even'; ?>">
<td class="data"><?php echo $ao->display('START_TIME'); ?></td> <td class="data"><?php echo $aso->display('START_TIME'); ?></td>
<td class="data"><?php echo $ao->display('END_TIME'); ?></td> <td class="data"><?php echo $aso->display('END_TIME'); ?></td>
<td class="data"><?php echo $ao->display('COMMMETH'); ?></td> <td class="data"><?php echo $aso->display('COMMMETH'); ?></td>
<td class="data"><?php echo $ao->display('SCHEDULE_NAME'); ?></td> <td class="data"><?php echo $aso->display('SCHEDULE_NAME'); ?></td>
<td class="data-right"><?php echo $ao->display('NUMBER'); ?></td> <td class="data-right"><?php echo $aso->inActLog() ? HTML::anchor(sprintf('node/session/%s,%s,%s',$o->NODE_NAME,$aso->NUMBER,$aso->start()),$aso->display('NUMBER')) : $aso->display('NUMBER'); ?></td>
<td class="data-right"><?php echo $ao->display('EXAMINED'); ?></td> <td class="data-right"><?php echo $aso->display('EXAMINED'); ?></td>
<td class="data-right"><?php echo $ao->display('AFFECTED'); ?></td> <td class="data-right"><?php echo $aso->display('AFFECTED'); ?></td>
<td class="data-right"><?php echo $ao->display('FAILED'); ?></td> <td class="data-right"><?php echo $aso->display('FAILED'); ?></td>
<td class="data-right"><?php echo $ao->bytes(); ?></td> <td class="data-right"><?php echo $aso->bytes(); ?></td>
<td class="data-right"><?php echo $ao->display('IDLE'); ?></td> <td class="data-right"><?php echo $aso->display('IDLE'); ?></td>
<td class="data-right"><?php echo $ao->display('MEDIAW'); ?></td> <td class="data-right"><?php echo $aso->display('MEDIAW'); ?></td>
<td class="data-right"><?php echo $ao->display('COMM_WAIT'); ?></td> <td class="data-right"><?php echo $aso->display('COMM_WAIT'); ?></td>
<td class="data-right"><?php echo $ao->display('PROCESSES'); ?></td> <td class="data-right"><?php echo $aso->display('PROCESSES'); ?></td>
<td class="data-right"><?php echo $ao->display('SUCCESSFUL'); ?></td> <td class="data-right"><?php echo $aso->display('SUCCESSFUL'); ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php } else { ?> <?php } else { ?>