Added Server activity log

This commit is contained in:
Deon George 2012-12-13 13:19:58 +11:00
parent 31609b2121
commit 46e80f5b45
14 changed files with 164 additions and 6 deletions

View File

@ -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() {

View File

@ -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',

View File

@ -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);
}
}
?>

View File

@ -0,0 +1,49 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Server Status
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_STATUS extends ORM_TSM {
protected $_table_name = 'STATUS';
protected $_primary_key = 'SERVER_NAME';
protected $_sorting = array(
'SERVER_NAME'=>'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();
}
}
?>

View File

@ -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'),
),

View File

@ -1,3 +1,4 @@
<!-- $o = ORM::factory('DB') -->
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('db/info')->set('o',$o); ?></td>

View File

@ -1,3 +1,4 @@
<!-- $o = ORM::factory('DOMAIN') -->
<table width="100%">
<tr>
<td style="width: 100%; vertical-align: top;" colspan="2"><?php echo View::factory('domain/nodes')->set('o',$o); ?></td>

View File

@ -1,3 +1,4 @@
<!-- $o = ORM::factory('LIBRARY') -->
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('library/info')->set('o',$o); ?></td>

View File

@ -1,3 +1,4 @@
<!-- $o = ORM::factory('DOMAIN') -->
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('node/info')->set('o',$o); ?></td>

View File

@ -0,0 +1,19 @@
<!-- $o = ORM::factory('STATUS') -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Server Activity</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td>Date</td>
<td>Message</td>
</tr>
<?php $i=0; foreach ($o->activity() as $ao) { ?>
<tr>
<td class="data"><?php echo $ao->DISPLAY('DATE_TIME'); ?>
<td class="data"><?php echo $ao->DISPLAY('MESSAGE'); ?>
</tr>
<?php } ?>
</table>

View File

@ -0,0 +1,9 @@
<!-- $o = ORM::factory('STATUS') -->
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('server/info')->set('o',$o); ?></td>
</tr>
<tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('server/activity')->set('o',$o); ?></td>
</tr>
</table>

View File

@ -0,0 +1,13 @@
<!-- $o = ORM::factory('NODE') -->
<table class="box-full">
<tr>
<td class="head" colspan="2">Server Information</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td style="width: 40%;">Server Name</td>
<td style="width: 60%;" class="data"><?php echo $o->display('SERVER_NAME'); ?> (<?php echo $o->display('SERVER_HLA').':'.$o->display('SERVER_LLA'); ?>)</td>
</tr>
</table>

View File

@ -1,3 +1,4 @@
<!-- $o = ORM::factory('STGPOOL') -->
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;" rowspan="2"><?php echo View::factory('stgpool/info')->set('o',$o); ?></td>

View File

@ -1,3 +1,4 @@
<!-- $o = ORM::factory('VOLUME') -->
<table width="100%">
<tr>
<td style="width: 50%; vertical-align: top;"><?php echo View::factory('volume/info')->set('o',$o); ?></td>