Added Client Session graphing

This commit is contained in:
Deon George 2012-12-12 21:39:00 +11:00
parent 12a2a53ef7
commit d84d7de251
9 changed files with 195 additions and 20 deletions

View File

@ -15,7 +15,10 @@ class Controller_Node extends Controller_TemplateDefault_View {
protected $detail_title = 'Information on Node'; protected $detail_title = 'Information on Node';
protected $orm = 'NODE'; protected $orm = 'NODE';
public function action_ajax_jsonbackup() { /**
* Gather the BA Client Session data for graphing
*/
public function action_ajaxjson_basessions() {
$id = $this->request->param('id'); $id = $this->request->param('id');
$c = (isset($_REQUEST['c'])) ? $_REQUEST['c'] : null; $c = (isset($_REQUEST['c'])) ? $_REQUEST['c'] : null;
$s = (isset($_REQUEST['s'])) ? $_REQUEST['s'] : null; $s = (isset($_REQUEST['s'])) ? $_REQUEST['s'] : null;
@ -26,8 +29,62 @@ class Controller_Node extends Controller_TemplateDefault_View {
if (! $id OR ! $no->loaded() OR ! $t OR ! $c) if (! $id OR ! $no->loaded() OR ! $t OR ! $c)
return ''; return '';
$google = GoogleChart::factory($c)
->logy(TRUE)
->title(sprintf('%s Activity',$t).($s ? sprintf(' for Schedule %s',$s) : ' outside of TSM schedules'));
foreach ($no->act_bybtype($t) as $aso) {
if ($aso->SCHEDULE_NAME != $s)
continue;
$result = array(); $result = array();
foreach ($aso->actlog() as $alo) {
$result = array_merge($result,$alo->msgtrim());
}
if (! $result)
continue;
$google->pdata($aso->display('START_TIME'),array(
'yr'=>array(
'OBJECT_TOTAL'=>$result['OBJECT_TOTAL'],
'OBJECT_BACKUP'=>$result['OBJECT_BACKUP'],
'OBJECT_DELETED'=>$result['OBJECT_DELETED'],
'OBJECT_UDPATE'=>$result['OBJECT_UDPATE'],
'OBJECT_FAILED'=>$result['OBJECT_FAILED'],
'OBJECT_REBOUND'=>$result['OBJECT_REBOUND'],
'OBJECT_EXPIRED'=>$result['OBJECT_EXPIRED'],
'OJBECT_DEDUPED'=>$result['OJBECT_DEDUPED'],
),
'yl'=>array(
'BYTES_INSPECT'=>$result['BYTES_INSPECT'],
'BYTES_PROCESS'=>$result['BYTES_PROCESS'],
'BYTES_TRANSFER'=>$result['BYTES_TRANSFER'],
'BYTES_DEDUPE_BEFORE'=>$result['BYTES_DEDUPE_BEFORE'],
),
));
}
$this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json');
$this->response->body($google->json());
}
/**
* Gather the TSM Server Schedule Activity for Graphing
*/
public function action_ajaxjson_schedules() {
$id = $this->request->param('id');
$c = (isset($_REQUEST['c'])) ? $_REQUEST['c'] : null;
$s = (isset($_REQUEST['s'])) ? $_REQUEST['s'] : null;
$t = (isset($_REQUEST['t'])) ? $_REQUEST['t'] : null;
$no = ORM::factory('NODE',$id);
if (! $id OR ! $no->loaded() OR ! $t OR ! $c)
return '';
$google = GoogleChart::factory($c) $google = GoogleChart::factory($c)
->logy(TRUE) ->logy(TRUE)
->title(sprintf('%s Activity',$t).($s ? sprintf(' for Schedule %s',$s) : ' outside of TSM schedules')); ->title(sprintf('%s Activity',$t).($s ? sprintf(' for Schedule %s',$s) : ' outside of TSM schedules'));

View File

@ -22,10 +22,39 @@ class Model_ACTLOG extends ORM_TSM {
), ),
); );
private $_msgno_ba_objects = array(4952,4953,4954,4958,4960,4957,4970,4959,4982); private $_msgno_ba_objects = array(
private $_msgno_ba_bytes = array(4977,4975,4984,4198,4961); 4952=>array('msg'=>'ANE4952I Total number of objects inspected:\s+([0-9,]+).*','id'=>'OBJECT_TOTAL'),
private $_msgno_ba_transfer = array(4963,4966,4967,4964); 4953=>array('msg'=>'','id'=>''),
private $_msgno_ba_reduction = array(4968,4981,4976); 4954=>array('msg'=>'ANE4954I Total number of objects backed up:\s+([0-9,]+).*','id'=>'OBJECT_BACKUP'),
4957=>array('msg'=>'ANE4957I Total number of objects deleted:\s+([0-9,]+).*','id'=>'OBJECT_DELETED'),
4958=>array('msg'=>'ANE4958I Total number of objects updated:\s+([0-9,]+).*','id'=>'OBJECT_UDPATE'),
4959=>array('msg'=>'ANE4959I Total number of objects failed:\s+([0-9,]+).*','id'=>'OBJECT_FAILED'),
4960=>array('msg'=>'ANE4960I Total number of objects rebound:\s+([0-9,]+).*','id'=>'OBJECT_REBOUND'),
4970=>array('msg'=>'ANE4970I Total number of objects expired:\s+([0-9,]+).*','id'=>'OBJECT_EXPIRED'),
4982=>array('msg'=>'ANE4982I Total objects deduplicated:\s+([0-9,]+).*','id'=>'OJBECT_DEDUPED'),
);
private $_msgno_ba_bytes = array(
4961=>array('msg'=>'ANE4961I Total number of bytes transferred:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_TRANSFER'),
4977=>array('msg'=>'ANE4977I Total number of bytes inspected:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_INSPECT'),
4975=>array('msg'=>'ANE4975I Total number of bytes processed:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_PROCESS'),
4984=>array('msg'=>'ANE4984I Total bytes before deduplication:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_DEDUPE_BEFORE'),
4198=>array('msg'=>'','id'=>''),
);
private $_msgno_ba_transfer = array(
4963=>array('msg'=>'ANE4963I Data transfer time:\s+([0-9,\.]+).*','id'=>'TRANSFER_SEC'),
4966=>array('msg'=>'ANE4966I Network data transfer rate:\s+([0-9,\.]+).*','id'=>'TRANSFER_RATE'),
4967=>array('msg'=>'ANE4967I Aggregate data transfer rate:\s+([0-9,\.]+).*','id'=>'TRANSFER_AGGR'),
4964=>array('msg'=>'ANE4964I Elapsed processing time:\s+([0-9:]+).*','id'=>'PROCESS_TIME'),
);
private $_msgno_ba_reduction = array(
4968=>array('msg'=>'ANE4968I Objects compressed by:\s+([0-9,\.]+).*','id'=>'COMPRESS'),
4981=>array('msg'=>'ANE4981I Deduplication reduction:\s+([0-9,\.]+).*','id'=>'DEDUPE'),
4976=>array('msg'=>'ANE4976I Total data reduction ratio:\s+([0-9,\.]+).*','id'=>'REDUCTION'),
);
private function _bamsgs() {
return $this->_msgno_ba_objects+$this->_msgno_ba_bytes+$this->_msgno_ba_transfer+$this->_msgno_ba_reduction;
}
/** /**
* Return the timestamp of the record in the ACTLOG * Return the timestamp of the record in the ACTLOG
@ -38,7 +67,43 @@ class Model_ACTLOG extends ORM_TSM {
* Where class to exclude NODE backup messages * Where class to exclude NODE backup messages
*/ */
public function ExcludeBA() { 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_keys($this->_bamsgs()));
}
/**
* Extract data from our BA Client messages
*/
public function msgtrim() {
$x = $this->_bamsgs();
if (! array_key_exists($this->MSGNO,$x))
return array();
// @todo Shouldnt need this
if (empty($x[$this->MSGNO]['id']))
throw new Kohana_Exception('Message has no ID :id [:msg]',array(':id'=>$this->MSGNO,':msg'=>$this->MESSAGE));
$y = preg_replace('/'.$x[$this->MSGNO]['msg'].'/',"$1$2",$this->MESSAGE);
$m = array();
// Do we have units we need to convert?
if (preg_match('/^(.*)([KMG]B)$/',$y,$m)) {
// Our number is in m[1]
$y = $m[1];
// Our unit is in m[2], convert to bytes
switch ($m[2]) {
case 'GB': $y *= 1024;
case 'MB': $y *= 1024;
case 'KB': $y *= 1024;
}
}
// Safety check to make sure we extracted what we wanted.
if ($y == $this->MESSAGE)
throw new Kohana_Exception('Unable to extra data from message :id [:msg]',array(':id'=>$this->MSGNO,':msg'=>$this->MESSAGE));
return array($x[$this->MSGNO]['id']=>str_replace(',','',$y));
} }
/** /**

View File

@ -16,6 +16,10 @@ class Model_ACTSUM extends ORM_TSM {
'START_TIME'=>'ASC', 'START_TIME'=>'ASC',
); );
protected $_has_one = array(
'NODE'=>array('foreign_key'=>'NODE_NAME','far_key'=>'ENTITY'),
);
protected $_display_filters = array( protected $_display_filters = array(
'START_TIME'=>array( 'START_TIME'=>array(
array('ORM_TSM::date',array(':value','d-M H:i')), array('ORM_TSM::date',array(':value','d-M H:i')),
@ -32,6 +36,16 @@ class Model_ACTSUM extends ORM_TSM {
return ORM_TSM::date(ORM::factory('ACTLOG')->FirstRec(),'U') <= $this->start(); return ORM_TSM::date(ORM::factory('ACTLOG')->FirstRec(),'U') <= $this->start();
} }
/**
* Get the ACTIVITY LOG data for this SESSION
*/
public function actlog() {
if (! isset($this->ENTITY))
throw new Kohana_Exception('Activity Summary has no NODENAME data');
return $this->NODE->actlog_session($this->NUMBER,$this->start());
}
/** /**
* Return this ACTIVITY SUMMARY in GB * Return this ACTIVITY SUMMARY in GB
*/ */

View File

@ -512,17 +512,31 @@ class Model_NODE extends ORM_TSM {
} }
/** /**
* Return a Graph of the Schedule Backup Activity * Return a Graph of the BA Client Sessions
* @param $type is Bkup/Arch/SpMg * @param $type is Bkup/Arch/SpMg
* @see [node/json_backup] * @see [node/ajaxjson_basessions]
*/ */
public function graph_backup($type='Bkup',$schedule='') { public function graph_basessions($type='Bkup',$schedule='') {
$chart = 'ComboChart'; $chart = 'ComboChart';
$google = GoogleChart::factory($chart) $google = GoogleChart::factory($chart)
->title(sprintf('%s Activity',$type)) ->div(sprintf('bas_%s_%s',$type,$schedule))
->div(sprintf('%s_%s',$type,$schedule)) ->dataurl(URL::site(sprintf('node/ajaxjson_basessions/%s?c=%s&s=%s&t=%s',$this->NODE_NAME,$chart,$schedule,$type)));
->dataurl(URL::site(sprintf('node/ajax_jsonbackup/%s?c=%s&s=%s&t=%s',$this->NODE_NAME,$chart,$schedule,$type)));
return (string)$google;
}
/**
* Return a Graph of the Schedule Backup Activity
* @param $type is Bkup/Arch/SpMg
* @see [node/ajaxjson_schedules]
*/
public function graph_schedules($type='Bkup',$schedule='') {
$chart = 'ComboChart';
$google = GoogleChart::factory($chart)
->div(sprintf('sch_%s_%s',$type,$schedule))
->dataurl(URL::site(sprintf('node/ajaxjson_schedules/%s?c=%s&s=%s&t=%s',$this->NODE_NAME,$chart,$schedule,$type)));
return (string)$google; return (string)$google;
} }

View File

@ -4,15 +4,17 @@
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('node/session')->set('o',$o); ?></td> <td style="width: 50%; vertical-align: top;"><?php echo View::factory('node/session')->set('o',$o); ?></td>
</tr> </tr>
<tr> <tr>
<td style="width: 50%; vertical-align: top;" colspan="2"><?php echo View::factory('node/graph_backup')->set('o',$o); ?></td> <td style="width: 50%; vertical-align: top;"><?php echo View::factory('domain/policy')->set('o',$o->DOMAIN); ?></td>
<td style="width: 50%; vertical-align: top;" rowspan="2"><?php echo View::factory('node/cloptset')->set('o',$o); ?></td>
</tr> </tr>
<tr> <tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('node/settings')->set('o',$o); ?></td> <td style="width: 50%; vertical-align: top;"><?php echo View::factory('node/settings')->set('o',$o); ?></td>
<td style="width: 50%; vertical-align: top;">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('domain/policy')->set('o',$o->DOMAIN); ?></td> <td style="width: 50%; vertical-align: top;" colspan="2"><?php echo View::factory('node/graph_schedules')->set('o',$o); ?></td>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('node/cloptset')->set('o',$o); ?></td> </tr>
<tr>
<td style="width: 50%; vertical-align: top;" colspan="2"><?php echo View::factory('node/graph_sessions')->set('o',$o); ?></td>
</tr> </tr>
</table> </table>
<?php echo View::factory('node/sessions')->set('o',$o); ?> <?php echo View::factory('node/sessions')->set('o',$o); ?>

View File

@ -10,7 +10,7 @@
<?php if ($o->act_bybtype($btype)) { ?> <?php if ($o->act_bybtype($btype)) { ?>
<?php foreach ($o->act_schedules($btype) as $schedule) { ?> <?php foreach ($o->act_schedules($btype) as $schedule) { ?>
<tr> <tr>
<td><?php echo $o->graph_backup($btype,$schedule); ?></td> <td><?php echo $o->graph_schedules($btype,$schedule); ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>

View File

@ -0,0 +1,18 @@
<!-- $o = ORM::factory('NODE') -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Session Results</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<?php foreach ($o->btypes() as $btype) { ?>
<?php if ($o->act_bybtype($btype)) { ?>
<?php foreach ($o->act_schedules($btype) as $schedule) { ?>
<tr>
<td><?php echo $o->graph_basessions($btype,$schedule); ?></td>
</tr>
<?php } ?>
<?php } ?>
<?php } ?>
</table>

View File

@ -53,8 +53,12 @@ abstract class GoogleChart implements Iterator,Countable {
break; break;
case 'div': $this->_divname = array_shift($args); case 'div': $this->_divname = array_shift($args);
break; break;
case 'height': $this->_height = array_shift($args);
break;
case 'title': $this->_title = array_shift($args); case 'title': $this->_title = array_shift($args);
break; break;
case 'width': $this->_width = array_shift($args);
break;
default: default:
throw new Kohana_Exception('Unknown method :name',array(':name'=>$name)); throw new Kohana_Exception('Unknown method :name',array(':name'=>$name));
} }

View File

@ -137,14 +137,15 @@ function drawChart".$this->_divname."() {
private function series() { private function series() {
$return = array(); $return = array();
$c = $this->seriescolors(); $c = $this->seriescolors();
$j = count($c);
$i = 0; $i = 0;
foreach ($this->_axis as $l => $axis) { foreach ($this->_axis as $l => $axis) {
// @todo This shouldnt be hard coded // @todo This shouldnt be hard coded
if ($axis == 'yl') if ($axis == 'yl')
array_push($return,array('type'=>'bar','color'=>$c[$i],'targetAxisIndex'=>0)); array_push($return,array('type'=>'bar','color'=>$c[$i%$j],'targetAxisIndex'=>0));
else else
array_push($return,array('type'=>'line','color'=>$c[$i],'targetAxisIndex'=>1)); array_push($return,array('type'=>'line','color'=>$c[$i%$j],'targetAxisIndex'=>1));
$i++; $i++;
} }