From 46e80f5b45735beecf89b9480324b7a80868effb Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 13 Dec 2012 13:19:58 +1100 Subject: [PATCH] Added Server activity log --- application/classes/Controller/Server.php | 6 +++ application/classes/Controller/Tree.php | 8 +++ application/classes/Model/ACTLOG.php | 59 ++++++++++++++++++++--- application/classes/Model/STATUS.php | 49 +++++++++++++++++++ application/config/config.php | 1 + application/views/db/detail.php | 1 + application/views/domain/detail.php | 1 + application/views/library/detail.php | 1 + application/views/node/detail.php | 1 + application/views/server/activity.php | 19 ++++++++ application/views/server/detail.php | 9 ++++ application/views/server/info.php | 13 +++++ application/views/stgpool/detail.php | 1 + application/views/volume/detail.php | 1 + 14 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 application/classes/Model/STATUS.php create mode 100644 application/views/server/activity.php create mode 100644 application/views/server/detail.php create mode 100644 application/views/server/info.php diff --git a/application/classes/Controller/Server.php b/application/classes/Controller/Server.php index 439a01a..ebd0e85 100644 --- a/application/classes/Controller/Server.php +++ b/application/classes/Controller/Server.php @@ -15,6 +15,12 @@ class Controller_Server extends Controller_TemplateDefault { * Default Index for Controller */ public function action_index() { + $so = ORM::factory('STATUS',Session::instance()->get('SERVER')->get('SERVER_NAME')); + + Block::add(array( + 'title'=>_('Server Information'), + 'body'=>View::factory(sprintf('%s/detail',strtolower($this->request->controller())))->set('o',$so), + )); } public function action_gantt() { diff --git a/application/classes/Controller/Tree.php b/application/classes/Controller/Tree.php index a892df2..267c489 100644 --- a/application/classes/Controller/Tree.php +++ b/application/classes/Controller/Tree.php @@ -71,6 +71,14 @@ class Controller_Tree extends lnApp_Controller_Tree { 'attr_href'=>URL::Site('stgpool'), )); + array_push($data,array( + 'id'=>'server', + 'name'=>'Server Info', + 'state'=>'none', + 'attr_id'=>'1', + 'attr_href'=>URL::Site('server'), + )); + array_push($data,array( 'id'=>'volume', 'name'=>'Volume Info', diff --git a/application/classes/Model/ACTLOG.php b/application/classes/Model/ACTLOG.php index 8ba9b65..431b708 100644 --- a/application/classes/Model/ACTLOG.php +++ b/application/classes/Model/ACTLOG.php @@ -20,6 +20,9 @@ class Model_ACTLOG extends ORM_TSM { 'DATE_TIME'=>array( array('ORM_TSM::date',array(':value','d-M H:i')), ), + 'MESSAGE'=>array( + array('Model_ACTLOG::strsession',array(':value')), + ), ); private $_msgno_ba_objects = array( @@ -34,11 +37,11 @@ class Model_ACTLOG extends ORM_TSM { 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'=>'ANE4198I Total bytes after deduplication:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_DEDUPE_AFTER'), + 4961=>array('msg'=>'ANE4961I Total number of bytes transferred:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_TRANSFER'), + 4975=>array('msg'=>'ANE4975I Total number of bytes processed:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_PROCESS'), + 4977=>array('msg'=>'ANE4977I Total number of bytes inspected:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_INSPECT'), + 4984=>array('msg'=>'ANE4984I Total bytes before deduplication:\s+([0-9,\.]+) ([KMG]B).*','id'=>'BYTES_DEDUPE_BEFORE'), ); private $_msgno_ba_transfer = array( 4963=>array('msg'=>'ANE4963I Data transfer time:\s+([0-9,\.]+).*','id'=>'TRANSFER_SEC'), @@ -47,15 +50,51 @@ class Model_ACTLOG extends ORM_TSM { 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'), + 4968=>array('msg'=>'ANE4968I Objects compressed by:\s+([0-9,\.\-]+).*','id'=>'COMPRESS'), 4976=>array('msg'=>'ANE4976I Total data reduction ratio:\s+([0-9,\.]+).*','id'=>'REDUCTION'), + 4981=>array('msg'=>'ANE4981I Deduplication reduction:\s+([0-9,\.]+).*','id'=>'DEDUPE'), + ); + + private $_msgno_admin = array( + 405=>array('msg'=>'ANR0405I Session [0-9]+ ended for administrator ([0-9a-zA-Z]+) \(.*\)\..*','id'=>''), + 407=>array('msg'=>'ANR0407I Session [0-9]+ started for administrator ([0-9a-zA-Z]+) \(.*\) \(.*\)\..*','id'=>''), + 1999=>array('msg'=>'ANR1999I QUERY REPLRULE completed successfully','id'=>''), + 2017=>array('msg'=>'ANR2017I Administrator ADMIN issued command: (.*)','id'=>''), + 2034=>array('msg'=>'ANR2034E SELECT: No match found using this criteria.','id'=>''), + 2906=>array('msg'=>'ANR2906E Unexpected SQL literal token - .*.','id'=>''), + 2939=>array('msg'=>'ANR2939E The reference .* contains an unknown SQL table name','id'=>''), + ); + + private $_msgno_expire = array( + 165=>array('msg'=>'ANR0165I Inventory file expiration started processing for node (.*), filespace (.*), copygroup (.*) and object type (.*).','id'=>''), + 166=>array('msg'=>'ANR0166I Inventory file expiration finished processing for node (.*), filespace (.*), copygroup (.*) and object type (.*) with processing statistics: examined ([0-9]+), deleted ([0-9]+), retrying ([0-9]+), and failed ([0-9]+).','id'=>''), + 167=>array('msg'=>'ANR0167I Inventory file expiration process [0-9]+ processed for .* minutes.','id'=>''), + 812=>array('msg'=>'ANR0812I Inventory file expiration process [0-9]+ completed: processed .* nodes, examined .* objects, deleting .* backup objects, .* archive objects, .* DB backup volumes, and .* recovery plan files. .* objects were retried and .* errors were encountered','id'=>''), + 987=>array('msg'=>'ANR0987I Process [0-9]+ for EXPIRE INVENTORY running in the BACKGROUND processed .* items with a completion state of .* at .*','id'=>''), + ); + + private $_msgno_session = array( + 403=>array('msg'=>'ANR0403I Session [0-9]+ ended for node .* \(.*\)','id'=>''), + 406=>array('msg'=>'ANR0406I Session [0-9]+ started for node .* \(.*\) \(.*\)','id'=>''), + 408=>array('msg'=>'ANR0408I Session [0-9]+ started for server .* \(.*\) \(.*\) for configuration management','id'=>''), + 409=>array('msg'=>'ANR0409I Session [0-9]+ ended for server .* \(.*\).','id'=>''), + 482=>array('msg'=>'ANR0482W Session [0-9]+ for node .* \(.*\) terminated - idle for more than .* minutes.','id'=>''), + 511=>array('msg'=>'ANR0511I Session [0-9]+ opened output volume .*','id'=>''), + 514=>array('msg'=>'ANR0514I Session [0-9]+ closed volume .*','id'=>''), + 2507=>array('msg'=>'ANR2507I Schedule .* for domain .* started at .* for node .* completed successfully at .*','id'=>''), + 3157=>array('msg'=>'ANR3157I Configuration refresh started for managed server .*','id'=>''), + 8592=>array('msg'=>'ANR8592I Session [0-9]+ connection is using SSL version TLSV11, cipher specification AES-128 certificate serial number ([0-9:]+)','id'=>''), + 8595=>array('msg'=>'ANR8595I Session to address .* is using SSL version TLSV11, cipher specification AES-128, certificate serial number ([0-9:]+).','id'=>''), ); private function _bamsgs() { return $this->_msgno_ba_objects+$this->_msgno_ba_bytes+$this->_msgno_ba_transfer+$this->_msgno_ba_reduction; } + private function _svrmsgs() { + return $this->_msgno_admin+$this->_msgno_expire+$this->_msgno_session; + } + /** * Return the timestamp of the record in the ACTLOG */ @@ -70,6 +109,10 @@ class Model_ACTLOG extends ORM_TSM { return $this->where('MSGNO','NOT IN',array_keys($this->_bamsgs())); } + public function ExcludeSERVER() { + return $this->where('MSGNO','NOT IN',array_keys($this->_svrmsgs())); + } + /** * Extract data from our BA Client messages */ @@ -112,5 +155,9 @@ class Model_ACTLOG extends ORM_TSM { public function start() { return ORM_TSM::date($this->DATE_TIME,'U'); } + + public static function strsession($value) { + return preg_replace('/\s+\(SESSION: .*\)\s*$/','',$value); + } } ?> diff --git a/application/classes/Model/STATUS.php b/application/classes/Model/STATUS.php new file mode 100644 index 0000000..e6f0631 --- /dev/null +++ b/application/classes/Model/STATUS.php @@ -0,0 +1,49 @@ +'ASC', + ); + + /** + * Get all the ACTIVITIY LOG for this SERVER + */ + private function _actlog() { + Log::instance()->add(LOG::DEBUG,'ENTER :method',array(':method'=>__METHOD__)); + + $k = sprintf('%s-%s',__METHOD__,$this->SERVER_NAME); + $c = Kohana::$config->load('config')->cache; + + if (is_null($result = Cache::instance($c)->get($k))) { + // We cant load all records here, like we do with the others, there is too much data! + // Due to the volume of data that could be retrieved, we'll only get the last tsmserveractlog days + $result = ORM::factory('ACTLOG') + ->ExcludeSERVER() + ->where('ORIGINATOR','IN',array('SERVER')) + ->and_where('DATE_TIME','>=',date('Y-m-d',time()-86400*Kohana::$config->load('config')->tsmserveractlog)) + ->find_all(); + + // @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; + } + + public function activity() { + return $this->_actlog(); + } +} +?> diff --git a/application/config/config.php b/application/config/config.php index 9802528..104234e 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -24,6 +24,7 @@ return array( 'tsmpooltypes' => array('PRIMARY','ACTIVEDATA','COPY'), 'tsmvolstatus' => array('FULL','FILLING','PENDING','EMPTY'), 'tsmtapeage' => 180, // Age of tapes before prompting to rotate + 'tsmserveractlog' => 0, // How many days to retireve from the Server Act Log 'email_admin_only'=> array( 'method'=>array('wurley@users.sf.net'=>'Deon George'), ), diff --git a/application/views/db/detail.php b/application/views/db/detail.php index b8fe9bb..7c6efa1 100644 --- a/application/views/db/detail.php +++ b/application/views/db/detail.php @@ -1,3 +1,4 @@ + diff --git a/application/views/domain/detail.php b/application/views/domain/detail.php index 3d24bf6..c94cad8 100644 --- a/application/views/domain/detail.php +++ b/application/views/domain/detail.php @@ -1,3 +1,4 @@ +
set('o',$o); ?>
diff --git a/application/views/library/detail.php b/application/views/library/detail.php index d2791a1..c8f6bc7 100644 --- a/application/views/library/detail.php +++ b/application/views/library/detail.php @@ -1,3 +1,4 @@ +
set('o',$o); ?>
diff --git a/application/views/node/detail.php b/application/views/node/detail.php index e966ea6..5b72215 100644 --- a/application/views/node/detail.php +++ b/application/views/node/detail.php @@ -1,3 +1,4 @@ +
set('o',$o); ?>
diff --git a/application/views/server/activity.php b/application/views/server/activity.php new file mode 100644 index 0000000..091ec89 --- /dev/null +++ b/application/views/server/activity.php @@ -0,0 +1,19 @@ + +
set('o',$o); ?>
+ + + + + + + + + + + activity() as $ao) { ?> + + + +
Server Activity
 
DateMessage
DISPLAY('DATE_TIME'); ?> + DISPLAY('MESSAGE'); ?> +
diff --git a/application/views/server/detail.php b/application/views/server/detail.php new file mode 100644 index 0000000..c5c1027 --- /dev/null +++ b/application/views/server/detail.php @@ -0,0 +1,9 @@ + + + + + + + + +
set('o',$o); ?>
set('o',$o); ?>
diff --git a/application/views/server/info.php b/application/views/server/info.php new file mode 100644 index 0000000..da51c80 --- /dev/null +++ b/application/views/server/info.php @@ -0,0 +1,13 @@ + + + + + + + + + + + + +
Server Information
 
Server Namedisplay('SERVER_NAME'); ?> (display('SERVER_HLA').':'.$o->display('SERVER_LLA'); ?>)
diff --git a/application/views/stgpool/detail.php b/application/views/stgpool/detail.php index 55334a3..1311787 100644 --- a/application/views/stgpool/detail.php +++ b/application/views/stgpool/detail.php @@ -1,3 +1,4 @@ + diff --git a/application/views/volume/detail.php b/application/views/volume/detail.php index 912f56c..9f8c72d 100644 --- a/application/views/volume/detail.php +++ b/application/views/volume/detail.php @@ -1,3 +1,4 @@ +
set('o',$o); ?>
set('o',$o); ?>