From 0122cd8c0288df0ffcab15121c7068c4366c8775 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 7 Dec 2012 17:06:57 +1100 Subject: [PATCH] Added Node Sessions --- application/classes/Model/ACTSUM.php | 32 ++++++++++++++++ application/classes/Model/NODE.php | 51 ++++++++++++++++++++++++++ application/views/node/detail.php | 1 + application/views/node/sessions.php | 55 ++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 application/classes/Model/ACTSUM.php create mode 100644 application/views/node/sessions.php diff --git a/application/classes/Model/ACTSUM.php b/application/classes/Model/ACTSUM.php new file mode 100644 index 0000000..8fa05c2 --- /dev/null +++ b/application/classes/Model/ACTSUM.php @@ -0,0 +1,32 @@ +'ASC', + ); + + protected $_display_filters = array( + 'START_TIME'=>array( + array('ORM_TSM::date',array(':value','d-M H:i')), + ), + 'END_TIME'=>array( + array('ORM_TSM::date',array(':value','d-M H:i')), + ), + ); + + public function bytes() { + return (real)number_format($this->BYTES/1024/1024,0,'',''); + } +} +?> diff --git a/application/classes/Model/NODE.php b/application/classes/Model/NODE.php index dddf7ba..2532ff1 100644 --- a/application/classes/Model/NODE.php +++ b/application/classes/Model/NODE.php @@ -115,6 +115,32 @@ class Model_NODE extends ORM_TSM { ), ); + /** + * Get all the ACTIVITY SUMMARY for this NODE + */ + private function _actsum() { + 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('ACTSUM')->order_by('SCHEDULE_NAME')->find_all() as $o) + if ($o->ENTITY == $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 FILESPACES for this NODE */ @@ -287,6 +313,31 @@ class Model_NODE extends ORM_TSM { return $result; } + /** + * Return the ACTIVITY of this NODE + * @param $type is Bkup/Arch/SpMg + */ + public function act_bybtype($type) { + Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); + + $k = sprintf('%s-%s-%s',__METHOD__,$this->NODE_NAME,$type); + $c = Kohana::$config->load('config')->cache; + + if (is_null($result = Cache::instance($c)->get($k))) { + $result = array(); + + foreach ($this->_actsum() as $aso) + if ($aso->ACTIVITY == $this->datatypemap($type)) + array_push($result,$aso); + + // @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; + } + /** * Return the BACKUP TYPES used by this NODE * ie: Bkup/Arch/SpMg diff --git a/application/views/node/detail.php b/application/views/node/detail.php index e1da41c..2ad0823 100644 --- a/application/views/node/detail.php +++ b/application/views/node/detail.php @@ -12,6 +12,7 @@ set('o',$o); ?> +set('o',$o); ?> set('o',$o); ?> set('o',$o); ?> set('o',$o); ?> diff --git a/application/views/node/sessions.php b/application/views/node/sessions.php new file mode 100644 index 0000000..0f88d01 --- /dev/null +++ b/application/views/node/sessions.php @@ -0,0 +1,55 @@ + + + btypes() as $btype) { ?> + + + + +
+ + + + + act_bybtype($btype)) { ?> + + + + + + + + + + + + + + + + + + + + act_bybtype($btype) as $ao) { ?> + + + + + + + + + + + + + + + + + + + + +
 
StartEndCommScheduleSessionExaminedBacked UpFailedMBIdleMedia WaitComm WaitProcessSuccess
display('START_TIME'); ?>display('END_TIME'); ?>display('COMMMETH'); ?>display('SCHEDULE_NAME'); ?>display('NUMBER'); ?>display('EXAMINED'); ?>display('AFFECTED'); ?>display('FAILED'); ?>bytes(); ?>display('IDLE'); ?>display('MEDIAW'); ?>display('COMM_WAIT'); ?>display('PROCESSES'); ?>display('SUCCESSFUL'); ?>
+