mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Added more default methods into report classes and added verify data source method and multiple other stuff
This commit is contained in:
parent
6688465c0c
commit
0fd1a11072
@ -491,6 +491,37 @@ if ( isset($_POST['op']) )
|
|||||||
}
|
}
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
|
|
||||||
|
// --- Now Verify Report Source!
|
||||||
|
// Create tmpSavedReport!
|
||||||
|
$tmpSavedReport["SavedReportID"] = $content['customFilters'];
|
||||||
|
$tmpSavedReport["sourceid"] = $content['SourceID'];
|
||||||
|
$tmpSavedReport["customTitle"] = $content['customTitle'];
|
||||||
|
$tmpSavedReport["customComment"] = $content['customComment'];
|
||||||
|
$tmpSavedReport["filterString"] = $content['filterString'];
|
||||||
|
$tmpSavedReport["customFilters"] = $content['customFilters'];
|
||||||
|
$tmpSavedReport["outputFormat"] = $content['outputFormat'];
|
||||||
|
$tmpSavedReport["outputTarget"] = $content['outputTarget'];
|
||||||
|
$tmpSavedReport["scheduleSettings"] = $content['scheduleSettings'];
|
||||||
|
|
||||||
|
// Get Objectreference to report
|
||||||
|
$myReportObj = $myReport["ObjRef"];
|
||||||
|
|
||||||
|
// Set SavedReport Settings!
|
||||||
|
$myReportObj->InitFromSavedReport($tmpSavedReport);
|
||||||
|
|
||||||
|
// Perform check
|
||||||
|
$res = $myReportObj->verifyDataSource();
|
||||||
|
if ( $res != SUCCESS )
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_REPORTS_ERROR_ERRORCHECKINGSOURCE'], GetAndReplaceLangStr( GetErrorMessage($res), $content['SourceID']) );
|
||||||
|
if ( isset($extraErrorDescription) )
|
||||||
|
$content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
|
|
||||||
// --- Now ADD/EDIT do the processing!
|
// --- Now ADD/EDIT do the processing!
|
||||||
if ( !isset($content['ISERROR']) )
|
if ( !isset($content['ISERROR']) )
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@ if ( !$content['error_occured'] )
|
|||||||
// Create LogStream Object
|
// Create LogStream Object
|
||||||
$stream = $stream_config->LogStreamFactory($stream_config);
|
$stream = $stream_config->LogStreamFactory($stream_config);
|
||||||
|
|
||||||
// Set Columns we want to open!
|
// Set Columns we want to open!
|
||||||
$content['ChartColumns'][] = SYSLOG_UID;
|
$content['ChartColumns'][] = SYSLOG_UID;
|
||||||
$content['ChartColumns'][] = $content['chart_field'];
|
$content['ChartColumns'][] = $content['chart_field'];
|
||||||
$res = $stream->Open( $content['ChartColumns'], true );
|
$res = $stream->Open( $content['ChartColumns'], true );
|
||||||
|
@ -116,6 +116,7 @@ class LogStreamDisk extends LogStream {
|
|||||||
* @return integer Error state
|
* @return integer Error state
|
||||||
*/
|
*/
|
||||||
public function Verify() {
|
public function Verify() {
|
||||||
|
|
||||||
// Check if file exists!
|
// Check if file exists!
|
||||||
if(!file_exists($this->_logStreamConfigObj->FileName)) {
|
if(!file_exists($this->_logStreamConfigObj->FileName)) {
|
||||||
return ERROR_FILE_NOT_FOUND;
|
return ERROR_FILE_NOT_FOUND;
|
||||||
|
@ -43,6 +43,10 @@ require_once($gl_root_path . 'include/constants_errors.php');
|
|||||||
require_once($gl_root_path . 'include/constants_logstream.php');
|
require_once($gl_root_path . 'include/constants_logstream.php');
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
|
// Include LogStream facility
|
||||||
|
include_once($gl_root_path . 'classes/logstream.class.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
abstract class Report {
|
abstract class Report {
|
||||||
// Common Properties
|
// Common Properties
|
||||||
@ -55,10 +59,15 @@ abstract class Report {
|
|||||||
public $_reportNeedsInit = false; // True means that this report needs additional init stuff
|
public $_reportNeedsInit = false; // True means that this report needs additional init stuff
|
||||||
public $_reportInitialized = false; // True means report is installed
|
public $_reportInitialized = false; // True means report is installed
|
||||||
|
|
||||||
// Configuration Properties
|
// SavedReport Configuration Properties
|
||||||
|
protected $_customTitle = "";
|
||||||
|
protected $_customComment = "";
|
||||||
protected $_filterString = "";
|
protected $_filterString = "";
|
||||||
protected $_advancedOptionsXml = "";
|
protected $_customFilters = "";
|
||||||
protected $_outputType = REPORT_OUTPUT_HTML; // Default HTML Output
|
protected $_outputFormat = REPORT_OUTPUT_HTML; // Default HTML Output
|
||||||
|
protected $_outputTarget = "";
|
||||||
|
protected $_scheduleSettings = "";
|
||||||
|
|
||||||
protected $_mySourceID = "";
|
protected $_mySourceID = "";
|
||||||
protected $_arrProperties = null; // List of properties we need for the main logstream query!
|
protected $_arrProperties = null; // List of properties we need for the main logstream query!
|
||||||
|
|
||||||
@ -150,13 +159,31 @@ abstract class Report {
|
|||||||
/*
|
/*
|
||||||
* Helper function to set the OutputType
|
* Helper function to set the OutputType
|
||||||
*/
|
*/
|
||||||
public function SetOutputType($newOutputType)
|
public function SetOutputFormat($newOutputType)
|
||||||
{
|
{
|
||||||
// Set new Outputtype
|
// Set new Outputtype
|
||||||
$this->_outputType = $newOutputType;
|
$this->_outputFormat = $newOutputType;
|
||||||
|
|
||||||
// Set Filebasename
|
// Set Filebasename
|
||||||
$this->_baseFileName = $this->_reportID . ".template." . $this->_outputType;
|
$this->_baseFileName = $this->_reportID . ".template." . $this->_outputFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to set the OutputTarget
|
||||||
|
*/
|
||||||
|
public function SetOutputTarget($newOutputTarget)
|
||||||
|
{
|
||||||
|
// Set new OutputTarget
|
||||||
|
$this->_outputTarget = $newOutputTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to set the Scheduled Settings
|
||||||
|
*/
|
||||||
|
public function SetScheduleSettings($newScheduleSettings)
|
||||||
|
{
|
||||||
|
// Set new ScheduleSettings
|
||||||
|
$this->_scheduleSettings = $newScheduleSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -171,12 +198,31 @@ abstract class Report {
|
|||||||
/*
|
/*
|
||||||
* Helper function to set the FilterString
|
* Helper function to set the FilterString
|
||||||
*/
|
*/
|
||||||
public function SetAdvancedOptions($newAdvancedOptions)
|
public function SetCustomFilters($newAdvancedOptions)
|
||||||
{
|
{
|
||||||
// Set new Outputtype
|
// Set new Outputtype
|
||||||
$this->_advancedOptionsXml = $newAdvancedOptions;
|
$this->_customFilters = $newAdvancedOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to set the FilterString
|
||||||
|
*/
|
||||||
|
public function SetCustomTitle($newCustomTitle)
|
||||||
|
{
|
||||||
|
// Set new Custom Title
|
||||||
|
$this->_customTitle = $newCustomTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to set the FilterString
|
||||||
|
*/
|
||||||
|
public function SetCustomComment($newCustomComment)
|
||||||
|
{
|
||||||
|
// Set new Custom Comment
|
||||||
|
$this->_customComment = $newCustomComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to set the FilterString
|
* Helper function to set the FilterString
|
||||||
*/
|
*/
|
||||||
@ -194,7 +240,6 @@ abstract class Report {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to trigger initialisation
|
* Helper function to trigger initialisation
|
||||||
*/
|
*/
|
||||||
@ -203,6 +248,22 @@ abstract class Report {
|
|||||||
$this->SetOutputType( REPORT_OUTPUT_HTML );
|
$this->SetOutputType( REPORT_OUTPUT_HTML );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to set settings from savedreport!
|
||||||
|
*/
|
||||||
|
public function InitFromSavedReport( $mySavedReport )
|
||||||
|
{
|
||||||
|
// Copy settings from saved report!
|
||||||
|
$this->SetSourceID( $mySavedReport["sourceid"] );
|
||||||
|
$this->SetCustomTitle( $mySavedReport["customTitle"] );
|
||||||
|
$this->SetCustomComment( $mySavedReport["customComment"] );
|
||||||
|
$this->SetFilterString( $mySavedReport["filterString"] );
|
||||||
|
$this->SetCustomFilters( $mySavedReport["customFilters"] );
|
||||||
|
$this->SetOutputFormat( $mySavedReport["outputFormat"] );
|
||||||
|
$this->SetOutputTarget( $mySavedReport["outputTarget"] );
|
||||||
|
$this->SetScheduleSettings( $mySavedReport["scheduleSettings"] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -121,10 +121,21 @@ class Report_monilog extends Report {
|
|||||||
*/
|
*/
|
||||||
public function verifyDataSource()
|
public function verifyDataSource()
|
||||||
{
|
{
|
||||||
|
global $content;
|
||||||
|
|
||||||
if ( $this->_streamCfgObj == null )
|
if ( $this->_streamCfgObj == null )
|
||||||
{
|
{
|
||||||
// Obtain and get the Config Object
|
if ( isset($content['Sources'][$this->_mySourceID]['ObjRef']) )
|
||||||
$this->_streamCfgObj = $content['Sources'][$this->_mySourceID]['ObjRef'];
|
{
|
||||||
|
// Obtain and get the Config Object
|
||||||
|
$this->_streamCfgObj = $content['Sources'][$this->_mySourceID]['ObjRef'];
|
||||||
|
|
||||||
|
// Fix Filename manually for FILE LOGSTREAM!
|
||||||
|
if ( $content['Sources'][$this->_mySourceID]['SourceType'] == SOURCE_DISK )
|
||||||
|
$this->_streamCfgObj->FileName = CheckAndPrependRootPath(DB_StripSlahes($content['Sources'][$this->_mySourceID]['DiskFile']));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return ERROR_SOURCENOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->_streamObj == null )
|
if ( $this->_streamObj == null )
|
||||||
@ -133,8 +144,9 @@ class Report_monilog extends Report {
|
|||||||
$this->_streamObj = $this->_streamCfgObj ->LogStreamFactory($this->_streamCfgObj);
|
$this->_streamObj = $this->_streamCfgObj ->LogStreamFactory($this->_streamCfgObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success!
|
// Check datasource and return result
|
||||||
return SUCCESS;
|
$res = $this->_streamObj->Verify();
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1672,8 +1672,14 @@ function CheckAndPrependRootPath( $szFileName)
|
|||||||
// Nothing really todo
|
// Nothing really todo
|
||||||
true;
|
true;
|
||||||
}
|
}
|
||||||
else // prepend basepath!
|
else
|
||||||
$szNewFileName = $gl_root_path . $szFileName;
|
{
|
||||||
|
// replace ./ with gl_root_path in this case
|
||||||
|
if ( ($pos = strpos($szFileName, "./")) !== FALSE )
|
||||||
|
$szNewFileName = str_replace( "./", $gl_root_path, $szFileName );
|
||||||
|
else // prepend basepath!
|
||||||
|
$szNewFileName = $gl_root_path . $szFileName;
|
||||||
|
}
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
return $szNewFileName;
|
return $szNewFileName;
|
||||||
|
@ -421,6 +421,7 @@ $content['LN_REPORTS_RUNNOW'] = "Run saved report now!";
|
|||||||
$content['LN_REPORTS_WARNDELETESAVEDREPORT'] = "Are you sure that you want to delete the savedreport '%1'?";
|
$content['LN_REPORTS_WARNDELETESAVEDREPORT'] = "Are you sure that you want to delete the savedreport '%1'?";
|
||||||
$content['LN_REPORTS_ERROR_DELSAVEDREPORT'] = "Deleting of the savedreport with id '%1' failed!";
|
$content['LN_REPORTS_ERROR_DELSAVEDREPORT'] = "Deleting of the savedreport with id '%1' failed!";
|
||||||
$content['LN_REPORTS_ERROR_HASBEENDEL'] = "The savedreport '%1' has been successfully deleted!";
|
$content['LN_REPORTS_ERROR_HASBEENDEL'] = "The savedreport '%1' has been successfully deleted!";
|
||||||
|
$content['LN_REPORTS_ERROR_ERRORCHECKINGSOURCE'] = "Error while checking Savedreport Source: %1";
|
||||||
$content['LN_REPORTS_'] = "";
|
$content['LN_REPORTS_'] = "";
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user