mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 03:09:21 +02:00
Continued writing report generator and started implementing report logic for monilog report
This commit is contained in:
parent
8910347d04
commit
7ee719ee8e
@ -100,14 +100,15 @@ class Report_monilog extends Report {
|
||||
// Verify Datasource first!
|
||||
if ( $this->verifyDataSource() == SUCCESS )
|
||||
{
|
||||
$res = $stream->Open( $this->_arrProperties, true );
|
||||
$res = $this->_streamObj->Open( $this->_arrProperties, true );
|
||||
if ( $res == SUCCESS )
|
||||
{
|
||||
// --- Report logic starts here
|
||||
|
||||
// Step 1: Gather Summaries
|
||||
// Obtain data from the logstream!
|
||||
$reportData = $stream->GetCountSortedByField( SYSLOG_SEVERITY, FILTER_TYPE_INT, 10 );
|
||||
$reportData = $this->_streamObj->GetCountSortedByField( SYSLOG_SEVERITY, FILTER_TYPE_NUMBER, 10 );
|
||||
echo "wtf";
|
||||
|
||||
print_r ( $reportData );
|
||||
exit;
|
||||
@ -158,7 +159,7 @@ exit;
|
||||
if ( $this->_streamObj == null )
|
||||
{
|
||||
// Create LogStream Object
|
||||
$this->_streamObj = $this->_streamCfgObj ->LogStreamFactory($this->_streamCfgObj);
|
||||
$this->_streamObj = $this->_streamCfgObj->LogStreamFactory($this->_streamCfgObj);
|
||||
}
|
||||
|
||||
// Check datasource and return result
|
||||
|
@ -337,7 +337,7 @@ $content['LN_ORACLE_WHOIS'] = "WHOIS Lookup for '%1' value '%2'";
|
||||
$content['LN_GEN_ERROR_INVALIDOP'] = "Invalid or missing operation type";
|
||||
$content['LN_GEN_ERROR_INVALIDREPORTID'] = "Invalid or missing report id";
|
||||
$content['LN_GEN_ERROR_MISSINGSAVEDREPORTID'] = "Invalid or missing savedreport id";
|
||||
|
||||
|
||||
$content['LN_GEN_ERROR_REPORTGENFAILED'] = "Failed generating report '%1' with the following error reason: %2";
|
||||
$content['LN_GEN_ERROR_WHILEREPORTGEN'] = "Error occured while generating report";
|
||||
|
||||
?>
|
@ -48,6 +48,9 @@ InitPhpLogCon();
|
||||
InitSourceConfigs();
|
||||
InitFrontEndDefaults(); // Only in WebFrontEnd
|
||||
InitFilterHelpers(); // Helpers for frontend filtering!
|
||||
|
||||
// Firts of all init List of Reports!
|
||||
InitReportModules();
|
||||
// ---
|
||||
|
||||
// --- READ CONTENT Vars
|
||||
@ -61,8 +64,8 @@ else
|
||||
$content['error_details'] = $content['LN_GEN_ERROR_INVALIDOP'];
|
||||
}
|
||||
|
||||
if ( isset($_GET['reportid']) )
|
||||
$content['reportid'] = DB_RemoveBadChars($_GET['reportid']);
|
||||
if ( isset($_GET['id']) )
|
||||
$content['reportid'] = DB_RemoveBadChars($_GET['id']);
|
||||
else
|
||||
{
|
||||
$content['error_occured'] = "error";
|
||||
@ -142,6 +145,7 @@ else
|
||||
$content['TITLE'] = InitPageTitle();
|
||||
// --- END CREATE TITLE
|
||||
|
||||
|
||||
// --- BEGIN Custom Code
|
||||
|
||||
// Get data and print on the image!
|
||||
@ -191,8 +195,23 @@ if ( !$content['error_occured'] )
|
||||
else
|
||||
{
|
||||
// Call processing part now!
|
||||
$res = $myReportObj->startDataProcessing();
|
||||
if ( $res != SUCCESS )
|
||||
{
|
||||
$content['error_occured'] = true;
|
||||
$content['error_details'] = GetAndReplaceLangStr( $content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Perform report output
|
||||
InitTemplateParser();
|
||||
echo $myReportObj->_baseFileName;
|
||||
exit;
|
||||
|
||||
$page -> parser($content, "reportgenerator.html");
|
||||
$page -> output();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -208,348 +227,17 @@ if ( !$content['error_occured'] )
|
||||
$content['error_occured'] = true;
|
||||
$content['error_details'] = $content['LN_GEN_ERROR_MISSINGSAVEDREPORTID'];
|
||||
}
|
||||
|
||||
|
||||
if ( isset($content['Sources'][$currentSourceID]) )
|
||||
{
|
||||
// Obtain and get the Config Object
|
||||
$stream_config = $content['Sources'][$currentSourceID]['ObjRef'];
|
||||
|
||||
// Create LogStream Object
|
||||
$stream = $stream_config->LogStreamFactory($stream_config);
|
||||
|
||||
// Set Columns we want to open!
|
||||
$content['ChartColumns'][] = SYSLOG_UID;
|
||||
$content['ChartColumns'][] = $content['chart_field'];
|
||||
$res = $stream->Open( $content['ChartColumns'], true );
|
||||
if ( $res == SUCCESS )
|
||||
{
|
||||
// Obtain data from the logstream!
|
||||
$chartData = $stream->GetCountSortedByField($content['chart_field'], $content['chart_fieldtype'], $content['maxrecords']);
|
||||
|
||||
// If data is valid, we have an array!
|
||||
if ( is_array($chartData) && count($chartData) > 0 )
|
||||
{
|
||||
// Create Y array!
|
||||
foreach( $chartData as $myKey => $myData)
|
||||
{
|
||||
// Convert into filter format for submenus
|
||||
$szEncodedKeyStr = str_replace(' ', '+', $myKey);
|
||||
|
||||
// echo $myKey . "<br>";
|
||||
$YchartData[] = intval($myData);
|
||||
$XchartData[] = strlen($myKey) > 0 ? $myKey : "Unknown";
|
||||
if ( isset($fields[$content['chart_field']]['SearchField']) && strlen($myKey) > 0 )
|
||||
$chartImageMapLinks[] = $content['BASEPATH'] . "index.php?filter=" . $fields[$content['chart_field']]['SearchField'] . "%3A%3D" . urlencode($szEncodedKeyStr) . "&search=Search";
|
||||
else
|
||||
$chartImageMapLinks[] = "";
|
||||
|
||||
$chartImageMapAlts[] = $fields[$content['chart_field']]['FieldCaption'] . ": " . $myKey;
|
||||
$chartImageMapTargets[] ="_top";
|
||||
}
|
||||
|
||||
if ( $content['chart_type'] == CHART_CAKE )
|
||||
{
|
||||
// Include additional code filers for this chart!
|
||||
include_once ($gl_root_path . "classes/jpgraph/jpgraph_pie.php");
|
||||
include_once ($gl_root_path . "classes/jpgraph/jpgraph_pie3d.php");
|
||||
|
||||
// Create Basic Image, and set basic properties!
|
||||
$graph = new PieGraph($content['chart_width'], $content['chart_width'], 'auto');
|
||||
$graph->SetMargin(30,20,30,30); // Adjust margin area
|
||||
$graph->SetScale("textlin");
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetBox(); // Box around plotarea
|
||||
|
||||
// Set up the title for the graph
|
||||
// $graph->title->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaption'] ] . '"');
|
||||
// $graph->title->SetFont(FF_VERDANA,FS_NORMAL,12);
|
||||
// $graph->title->SetColor("darkred");
|
||||
|
||||
// Setup the tab title
|
||||
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $fields[$content['chart_field']]['FieldCaption']) );
|
||||
$graph->tabtitle->SetFont(FF_VERA,FS_BOLD,9);
|
||||
$graph->tabtitle->SetPos('left');
|
||||
|
||||
// Set Graph footer
|
||||
$graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
$graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 7);
|
||||
// $graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
// $graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
|
||||
// $graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
// $graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 8);
|
||||
// $graph->footer->right->SetColor("darkred");
|
||||
|
||||
// Show 0 label on Y-axis (default is not to show)
|
||||
$graph->yscale->ticks->SupressZeroLabel(false);
|
||||
|
||||
// Set Fonts for graph!
|
||||
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,8);
|
||||
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,8);
|
||||
$graph->legend->SetFont(FF_VERA,FS_NORMAL,8);
|
||||
|
||||
// Create
|
||||
$p1 = new PiePlot3D($YchartData);
|
||||
$p1->SetLegends($XchartData);
|
||||
$p1->SetEdge('#333333', 1);
|
||||
$p1->SetTheme('earth'); /* "earth" * "pastel" * "sand" * "water" */
|
||||
$p1->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets);
|
||||
|
||||
// Set label format
|
||||
if ( $content['showpercent'] == 1 )
|
||||
{
|
||||
$p1->SetLabelType(0);
|
||||
$p1->value->SetFormat("%d%%");
|
||||
}
|
||||
else
|
||||
{
|
||||
$p1->SetLabelType(1);
|
||||
$p1->value->SetFormat("%d");
|
||||
}
|
||||
|
||||
// Set label properties
|
||||
$p1->SetLabelPos(1.0);
|
||||
$p1->SetSliceColors(array('#FFF584','#CBFF84','#FF6B9E','#FF9584','#EAFF84','#7BFF51','#51FFA6','#51FF52','#6BCFFF','#5170FF','#519CFF','#EAE3AD','#FFF184','#8584FF','#E698FF','#C384FF','#FF84EC','#FF98A3','#E5C285','#FFDA98' ));
|
||||
$p1->value->SetFont(FF_VERA, FS_NORMAL, 8);
|
||||
$p1->value->SetColor("black");
|
||||
|
||||
// Adjust other Pie Properties
|
||||
$p1->SetLabelMargin(5);
|
||||
$p1->SetCenter(0.4,0.65);
|
||||
$p1->SetSize(0.3);
|
||||
$p1->SetAngle(60);
|
||||
|
||||
$graph->Add($p1);
|
||||
}
|
||||
else if ( $content['chart_type'] == CHART_BARS_VERTICAL )
|
||||
{
|
||||
// Include additional code filers for this chart!
|
||||
include_once ($gl_root_path . "classes/jpgraph/jpgraph_bar.php");
|
||||
include_once ($gl_root_path . "classes/jpgraph/jpgraph_line.php");
|
||||
|
||||
// Create Basic Image, and set basic properties!
|
||||
$graph = new Graph($content['chart_width'], $content['chart_width'], 'auto');
|
||||
$graph->SetMargin(60,20,30,50); // Adjust margin area
|
||||
$graph->SetScale("textlin");
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetBox(); // Box around plotarea
|
||||
|
||||
// Setup X-AXIS
|
||||
// $graph->xaxis->SetFont(FF_VERA,FS_NORMAL,10);
|
||||
$graph->xaxis->SetTickLabels($XchartData);
|
||||
|
||||
if ( count($XchartData) > 5 )
|
||||
{
|
||||
$graph->SetMargin(60,20,30,80); // Adjust margin area
|
||||
$graph->xaxis->SetLabelAngle(45);
|
||||
$graph->xaxis->SetLabelMargin(2);
|
||||
}
|
||||
else
|
||||
$graph->xaxis->SetLabelAngle(0);
|
||||
|
||||
// $graph->xaxis->scale->SetGrace(30); // So the value is readable
|
||||
|
||||
// Setup Y-AXIS
|
||||
$graph->yaxis->scale->SetGrace(10); // So the value is readable
|
||||
// $graph->yaxis->SetLabelFormat('%d %%');
|
||||
|
||||
// Show 0 label on Y-axis (default is not to show)
|
||||
$graph->yscale->ticks->SupressZeroLabel(false);
|
||||
|
||||
// Set Fonts for graph!
|
||||
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,7);
|
||||
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,8);
|
||||
|
||||
// Setup the tab title
|
||||
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $fields[$content['chart_field']]['FieldCaption']) );
|
||||
$graph->tabtitle->SetFont(FF_VERA,FS_BOLD,9);
|
||||
$graph->tabtitle->SetPos('left');
|
||||
|
||||
// Set Graph footer
|
||||
$graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
$graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 7);
|
||||
// $graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
// $graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
|
||||
|
||||
// Setup the X and Y grid
|
||||
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
|
||||
$graph->ygrid->SetLineStyle('dashed');
|
||||
$graph->ygrid->SetColor('gray');
|
||||
$graph->xgrid->Show();
|
||||
$graph->xgrid->SetLineStyle('dashed');
|
||||
$graph->xgrid->SetColor('gray');
|
||||
|
||||
// Create and Add bar pot
|
||||
$bplot = new BarPlot($YchartData);
|
||||
$bplot->SetWidth(0.6);
|
||||
$fcol='#440000';
|
||||
$tcol='#FF9090';
|
||||
$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION);
|
||||
$graph->Add($bplot);
|
||||
|
||||
// Display value in bars
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFont(FF_VERA,FS_NORMAL,8);
|
||||
// $bplot->value->SetAlign('left','center');
|
||||
// $bplot->value->SetColor("black","darkred");
|
||||
$bplot->value->SetFormat('%d');
|
||||
|
||||
// Add links
|
||||
$bplot->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets);
|
||||
|
||||
|
||||
// TODO: Make Optional!
|
||||
// Create and Add filled line plot
|
||||
$lplot = new LinePlot($YchartData);
|
||||
$lplot->SetFillColor('skyblue@0.7');
|
||||
$lplot->SetColor('navy@0.7');
|
||||
$lplot->SetBarCenter();
|
||||
$lplot->mark->SetType(MARK_SQUARE);
|
||||
$lplot->mark->SetColor('blue@0.7');
|
||||
$lplot->mark->SetFillColor('lightblue');
|
||||
$lplot->mark->SetSize(6);
|
||||
$graph->Add($lplot);
|
||||
}
|
||||
else if ( $content['chart_type'] == CHART_BARS_HORIZONTAL )
|
||||
{
|
||||
// Include additional code filers for this chart!
|
||||
include_once ($gl_root_path . "classes/jpgraph/jpgraph_bar.php");
|
||||
include_once ($gl_root_path . "classes/jpgraph/jpgraph_line.php");
|
||||
|
||||
// Create Basic Image, and set basic properties!
|
||||
$graph = new Graph($content['chart_width'], $content['chart_width'], 'auto');
|
||||
// $graph->SetMargin(60,20,30,50);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->Set90AndMargin(80,30,30,50); // Adjust margin area
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetBox(); // Box around plotarea
|
||||
|
||||
// Setup X-AXIS
|
||||
$graph->xaxis->SetTickLabels($XchartData);
|
||||
$graph->xaxis->SetLabelAngle(0);
|
||||
// $graph->xaxis->SetLabelAlign('center','top');
|
||||
$graph->xaxis->SetPos('min');
|
||||
$graph->xaxis->SetLabelMargin(5);
|
||||
$graph->xaxis->SetLabelAlign('right','center');
|
||||
|
||||
// Setup Y-AXIS
|
||||
$graph->yaxis->scale->SetGrace(20); // So the value is readable
|
||||
$graph->yaxis->SetLabelAlign('center','top');
|
||||
$graph->yaxis->SetLabelFormat('%d');
|
||||
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
|
||||
$graph->yaxis->SetTickSide(SIDE_LEFT);
|
||||
// $graph->yaxis->SetTitleSide(SIDE_RIGHT);
|
||||
// $graph->yaxis->SetTitleMargin(35);
|
||||
$graph->yaxis->SetPos('max');
|
||||
$graph->yaxis->SetTextLabelInterval(2);
|
||||
|
||||
// Show 0 label on Y-axis (default is not to show)
|
||||
$graph->yscale->ticks->SupressZeroLabel(false);
|
||||
|
||||
// Set Fonts for graph!
|
||||
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,7);
|
||||
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,8);
|
||||
|
||||
// Setup the tab title
|
||||
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $fields[$content['chart_field']]['FieldCaption']) );
|
||||
$graph->tabtitle->SetFont(FF_VERA,FS_BOLD,9);
|
||||
$graph->tabtitle->SetPos('right');
|
||||
$graph->tabtitle->SetTabAlign('right');
|
||||
|
||||
// Set Graph footer
|
||||
$graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
$graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 7);
|
||||
// $graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
|
||||
// $graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
|
||||
|
||||
// Setup the X and Y grid
|
||||
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
|
||||
$graph->ygrid->SetLineStyle('dashed');
|
||||
$graph->ygrid->SetColor('gray');
|
||||
$graph->xgrid->Show();
|
||||
$graph->xgrid->SetLineStyle('dashed');
|
||||
$graph->xgrid->SetColor('gray');
|
||||
|
||||
// Create and Add bar pot
|
||||
$bplot = new BarPlot($YchartData);
|
||||
$bplot->SetWidth(0.6);
|
||||
$fcol='#440000';
|
||||
$tcol='#FF9090';
|
||||
$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION);
|
||||
$graph->Add($bplot);
|
||||
|
||||
// Display value in bars
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFont(FF_VERA,FS_NORMAL, 8);
|
||||
// $bplot->value->SetAlign('left','center');
|
||||
// $bplot->value->SetColor("black","darkred");
|
||||
$bplot->value->SetFormat('%d');
|
||||
|
||||
// Add links
|
||||
$bplot->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets);
|
||||
|
||||
// TODO: Make Optional!
|
||||
// Create and Add filled line plot
|
||||
$lplot = new LinePlot($YchartData);
|
||||
$lplot->SetFillColor('skyblue@0.7');
|
||||
$lplot->SetColor('navy@0.7');
|
||||
$lplot->SetBarCenter();
|
||||
$lplot->mark->SetType(MARK_SQUARE);
|
||||
$lplot->mark->SetColor('blue@0.7');
|
||||
$lplot->mark->SetFillColor('lightblue');
|
||||
$lplot->mark->SetSize(6);
|
||||
$graph->Add($lplot);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['error_occured'] = true;
|
||||
$content['error_details'] = $content['LN_GEN_ERROR_INVALIDTYPE'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['error_occured'] = true;
|
||||
$content['error_details'] = GetErrorMessage($chartData);
|
||||
if ( isset($extraErrorDescription) )
|
||||
$content['error_details'] .= "\n\n" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
|
||||
}
|
||||
|
||||
|
||||
//$fields[SYSLOG_UID]['FieldID']
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will disable to Main SyslogView and show an error message
|
||||
$content['error_occured'] = true;
|
||||
$content['error_details'] = GetErrorMessage($res);
|
||||
if ( isset($extraErrorDescription) )
|
||||
$content['error_details'] .= "\n\n" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
|
||||
}
|
||||
|
||||
// Close file!
|
||||
$stream->Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['error_occured'] = true;
|
||||
$content['error_details'] = GetAndReplaceLangStr( $content['LN_GEN_ERROR_SOURCENOTFOUND'], $currentSourceID);
|
||||
}
|
||||
}
|
||||
|
||||
// Output error if occured
|
||||
// Output error if necessary
|
||||
if ( $content['error_occured'] )
|
||||
{
|
||||
// $content['TITLE'] = InitPageTitle();
|
||||
$content['TITLE'] .= " :: " . $content['LN_GEN_ERROR_WHILEREPORTGEN'];
|
||||
|
||||
InitTemplateParser();
|
||||
$page -> parser($content, "reportgenerator.html");
|
||||
$page -> output();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
// ---
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user