mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 03:09:21 +02:00
started templates for monilog report
This commit is contained in:
parent
91a61d8e76
commit
8437f42e2c
@ -196,7 +196,7 @@ abstract class Report {
|
||||
$this->_outputFormat = $newOutputType;
|
||||
|
||||
// Set Filebasename
|
||||
$this->_baseFileName = $this->_reportID . ".template." . $this->_outputFormat;
|
||||
$this->_baseFileName = $this->_reportFileBasicName . ".template." . $this->_outputFormat;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -271,6 +271,33 @@ abstract class Report {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to return the BaseFileName
|
||||
*/
|
||||
public function GetBaseFileName()
|
||||
{
|
||||
// return Filebasename
|
||||
return $this->_baseFileName;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to return the CustomTitle
|
||||
*/
|
||||
public function GetCustomTitle()
|
||||
{
|
||||
// return Filebasename
|
||||
return $this->_customTitle;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to return the CustomComment
|
||||
*/
|
||||
public function GetCustomComment()
|
||||
{
|
||||
// return Filebasename
|
||||
return $this->_customComment;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to trigger initialisation
|
||||
*/
|
||||
@ -284,6 +311,8 @@ abstract class Report {
|
||||
*/
|
||||
public function InitFromSavedReport( $mySavedReport )
|
||||
{
|
||||
global $content;
|
||||
|
||||
// Copy settings from saved report!
|
||||
$this->SetSourceID( $mySavedReport["sourceid"] );
|
||||
$this->SetCustomTitle( $mySavedReport["customTitle"] );
|
||||
|
@ -103,10 +103,10 @@ class Report_monilog extends Report {
|
||||
// Verify Datasource first!
|
||||
if ( $this->verifyDataSource() == SUCCESS )
|
||||
{
|
||||
// Test opening the stream
|
||||
// $res = $this->_streamObj->Open( $this->_arrProperties, true );
|
||||
// if ( $res == SUCCESS )
|
||||
{
|
||||
// Get Settings and set to global content variable
|
||||
$content["report_title"] = $this->GetCustomTitle();
|
||||
$content["report_comment"] = $this->GetCustomComment();
|
||||
|
||||
// --- Report logic starts here
|
||||
|
||||
// Step 1: Gather Summaries
|
||||
@ -116,11 +116,24 @@ class Report_monilog extends Report {
|
||||
// If data is valid, we have an array!
|
||||
if ( is_array($content["report_summary"]) && count($content["report_summary"]) > 0 )
|
||||
{
|
||||
// Count Total Events
|
||||
$iTotalEvents = 0;
|
||||
|
||||
foreach ($content["report_summary"] as &$tmpReportData )
|
||||
{
|
||||
$tmpReportData['DisplayName'] = GetSeverityDisplayName( $tmpReportData[SYSLOG_SEVERITY] );
|
||||
$tmpReportData['bgcolor'] = $severity_colors[ $tmpReportData[SYSLOG_SEVERITY] ];
|
||||
|
||||
$iTotalEvents += $tmpReportData['ItemCount'];
|
||||
}
|
||||
|
||||
// Prepent Item with totalevents count
|
||||
$totalItem['DisplayName'] = "Total Events";
|
||||
$totalItem['bgcolor'] = "999999";
|
||||
$totalItem['ItemCount'] = $iTotalEvents;
|
||||
|
||||
// Prepent to array
|
||||
array_unshift( $content["report_summary"], $totalItem );
|
||||
}
|
||||
|
||||
// Get List of hosts
|
||||
@ -136,8 +149,6 @@ class Report_monilog extends Report {
|
||||
// ---
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return success!
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -210,34 +221,41 @@ class Report_monilog extends Report {
|
||||
// Check if Event from host is in our hosts array
|
||||
if ( in_array($logArray[SYSLOG_HOST], $arrHosts) )
|
||||
{
|
||||
// Set Host Item Basics if not set yet
|
||||
if ( !isset($content["report_consdata"][ $logArray[SYSLOG_HOST] ][SYSLOG_HOST]) )
|
||||
{
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][SYSLOG_HOST] = $logArray[SYSLOG_HOST];
|
||||
}
|
||||
|
||||
// Calc crc32 from message, we use this as index
|
||||
$strChecksum = crc32( $logArray[SYSLOG_MESSAGE] );
|
||||
|
||||
// Check if entry exists in result array
|
||||
if ( isset($content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]) )
|
||||
if ( isset($content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]) )
|
||||
{
|
||||
// Increment counter and set First/Last Event date
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['ItemCount']++;
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['ItemCount']++;
|
||||
|
||||
// Set FirstEvent date if necessary!
|
||||
if ( $logArray[SYSLOG_DATE] < $content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['FirstEvent_Date'] )
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['FirstEvent_Date'] = $logArray[SYSLOG_DATE];
|
||||
if ( $logArray[SYSLOG_DATE] < $content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['FirstEvent_Date'] )
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['FirstEvent_Date'] = $logArray[SYSLOG_DATE];
|
||||
|
||||
// Set LastEvent date if necessary!
|
||||
if ( $logArray[SYSLOG_DATE] > $content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['LastEvent_date'] )
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['LastEvent_date'] = $logArray[SYSLOG_DATE];
|
||||
if ( $logArray[SYSLOG_DATE] > $content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['LastEvent_date'] )
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['LastEvent_date'] = $logArray[SYSLOG_DATE];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set Basic data entries
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ][SYSLOG_SEVERITY] = $logArray[SYSLOG_SEVERITY];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ][SYSLOG_EVENT_ID] = $logArray[SYSLOG_EVENT_ID];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ][SYSLOG_EVENT_SOURCE] = $logArray[SYSLOG_EVENT_SOURCE];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ][SYSLOG_SEVERITY] = $logArray[SYSLOG_SEVERITY];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ][SYSLOG_EVENT_ID] = $logArray[SYSLOG_EVENT_ID];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ][SYSLOG_EVENT_SOURCE] = $logArray[SYSLOG_EVENT_SOURCE];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ][SYSLOG_MESSAGE] = $logArray[SYSLOG_MESSAGE];
|
||||
|
||||
// Set Counter and First/Last Event date
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['ItemCount'] = 1;
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['FirstEvent_Date'] = $logArray[SYSLOG_DATE];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ][ $strChecksum ]['LastEvent_date'] = $logArray[SYSLOG_DATE];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['ItemCount'] = 1;
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['FirstEvent_Date'] = $logArray[SYSLOG_DATE];
|
||||
$content["report_consdata"][ $logArray[SYSLOG_HOST] ]['cons_events'][ $strChecksum ]['LastEvent_date'] = $logArray[SYSLOG_DATE];
|
||||
//GetFormatedDate
|
||||
}
|
||||
|
||||
@ -252,15 +270,15 @@ class Report_monilog extends Report {
|
||||
foreach( $content["report_consdata"] as &$tmpConsolidatedComputer )
|
||||
{
|
||||
// First use callback function to sort array
|
||||
uasort($tmpConsolidatedComputer, "MultiSortArrayByItemCountDesc");
|
||||
uasort($tmpConsolidatedComputer['cons_events'], "MultiSortArrayByItemCountDesc");
|
||||
|
||||
// Remove entries according to _maxEventsPerHost
|
||||
if ( count($tmpConsolidatedComputer) > $this->_maxEventsPerHost )
|
||||
if ( count($tmpConsolidatedComputer['cons_events']) > $this->_maxEventsPerHost )
|
||||
{
|
||||
do
|
||||
{
|
||||
array_pop($tmpConsolidatedComputer);
|
||||
} while ( count($tmpConsolidatedComputer) > $this->_maxEventsPerHost );
|
||||
array_pop($tmpConsolidatedComputer['cons_events']);
|
||||
} while ( count($tmpConsolidatedComputer['cons_events']) > $this->_maxEventsPerHost );
|
||||
}
|
||||
}
|
||||
|
||||
|
109
src/classes/reports/report.eventlog.monilog.template.html
Normal file
109
src/classes/reports/report.eventlog.monilog.template.html
Normal file
@ -0,0 +1,109 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>{report_title}</title>
|
||||
|
||||
<link rel="stylesheet" href="{BASEPATH}css/defaults.css" type="text/css">
|
||||
<link rel="stylesheet" href="{BASEPATH}themes/{user_theme}/main.css" type="text/css">
|
||||
<link rel="stylesheet" href="{BASEPATH}css/menu.css" type="text/css">
|
||||
|
||||
</head>
|
||||
<body TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
|
||||
<tr>
|
||||
<td class="title" width="100%" nowrap><B>{report_title}</B></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="titleSecond" width="100%" align="left">{report_comment}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
|
||||
<tr>
|
||||
<td class="title" width="100%" nowrap><B>{report_summary}</B></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableBackground" width="100%" align="left">
|
||||
|
||||
<table width="200" cellpadding="0" cellspacing="1" border="0" align="left" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" colspan="2" align="center">{report_event_summary}</td>
|
||||
</tr>
|
||||
<!-- BEGIN report_summary -->
|
||||
<tr>
|
||||
<td class="cellmenu2">{DisplayName}</td>
|
||||
<td class="lineColouredWhite" bgcolor="{bgcolor}" align="right"><b>{ItemCount}</b></td>
|
||||
</tr>
|
||||
<!-- END report_summary -->
|
||||
</table>
|
||||
|
||||
<table width="600" cellpadding="0" cellspacing="1" border="0" align="right" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" colspan="2" align="center">{report_computer_summary}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="line1">
|
||||
<!-- BEGIN report_computers -->
|
||||
<a href="#{FROMHOST}">{FROMHOST}</a>({ItemCount}),
|
||||
<!-- END report_computers -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
|
||||
<tr>
|
||||
<td class="title" width="100%" nowrap><B>{report_consolidation}</B></td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- BEGIN report_consdata -->
|
||||
<br/><br/>
|
||||
<h3><a name="{FROMHOST}">{FROMHOST}</a></h3>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="1" border="0" align="center" class="with_border_alternate">
|
||||
<tr>
|
||||
<td class="cellmenu1" align="center" width="50">{report_number}</td>
|
||||
<td class="cellmenu1" align="center" width="100">{report_firstevent}</td>
|
||||
<td class="cellmenu1" align="center" width="100">{report_lastevent}</td>
|
||||
<td class="cellmenu1" align="center" width="150">{report_process}</td>
|
||||
<td class="cellmenu1" align="center" width="100">{report_severity}</td>
|
||||
<td class="cellmenu1" align="center" width="80">{report_eventid}</td>
|
||||
<td class="cellmenu1" align="center" width="100%">{report_description}</td>
|
||||
<td class="cellmenu1" align="center" width="50">{report_count}</td>
|
||||
</tr>
|
||||
<!-- BEGIN cons_events -->
|
||||
<tr>
|
||||
<td class="line1" valign="top">{ZAEHLER}</td>
|
||||
<td class="line1" valign="top">{FirstEvent_Date}</td>
|
||||
<td class="line1" valign="top">{LastEvent_date}</td>
|
||||
<td class="line1" valign="top">{sourceproc}</td>
|
||||
<td class="line1" valign="top">{syslogseverity}</td>
|
||||
<td class="line1" valign="top">{id}</td>
|
||||
<td class="line1" valign="top">{msg}</td>
|
||||
<!-- IF ItemCount > 10 -->
|
||||
<td class="lineColouredWhite" valign="top" align="right" bgcolor="red"><b>{ItemCount}</b></td>
|
||||
<!-- ENDIF ItemCount > 10 -->
|
||||
<!-- IF ItemCount < 10 -->
|
||||
<td class="lineColouredWhite" valign="top" align="right" bgcolor="#AAAAAA"><b>{ItemCount}</b></td>
|
||||
<!-- ENDIF ItemCount < 10 -->
|
||||
|
||||
</tr>
|
||||
|
||||
<!-- END cons_events -->
|
||||
</table>
|
||||
|
||||
<!-- END report_consdata -->
|
||||
|
||||
</body>
|
||||
</html>
|
@ -203,14 +203,19 @@ if ( !$content['error_occured'] )
|
||||
}
|
||||
else
|
||||
{
|
||||
// Perform report output
|
||||
InitTemplateParser();
|
||||
echo $myReportObj->_baseFileName;
|
||||
exit;
|
||||
// --- Perform report output
|
||||
|
||||
$page -> parser($content, "reportgenerator.html");
|
||||
// Init template Parser
|
||||
$page = new Template();
|
||||
$page -> set_path ( $gl_root_path . 'classes/reports/' );
|
||||
|
||||
// Parse template
|
||||
$page -> parser($content, $myReportObj->GetBaseFileName());
|
||||
|
||||
// Output to browser
|
||||
$page -> output();
|
||||
|
||||
// ---
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user