mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 03:09:21 +02:00
Added sample charts into db upgrade script, and added option to disable charts
This commit is contained in:
parent
e3e640aba9
commit
fb242ca286
@ -99,10 +99,10 @@ $CFG['Search'][] = array ( "DisplayName" => "All messages from last 31 days", "S
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Predefined Charts!
|
// --- Predefined Charts!
|
||||||
$CFG['Charts'][] = array ( "DisplayName" => "Top Hosts", "chart_type" => CHART_BARS_HORIZONTAL, "chart_width" => 400, "chart_field" => SYSLOG_HOST, "maxrecords" => 10, "showpercent" => 0 );
|
$CFG['Charts'][] = array ( "DisplayName" => "Top Hosts", "chart_type" => CHART_BARS_HORIZONTAL, "chart_width" => 400, "chart_field" => SYSLOG_HOST, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 );
|
||||||
$CFG['Charts'][] = array ( "DisplayName" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0 );
|
$CFG['Charts'][] = array ( "DisplayName" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 );
|
||||||
$CFG['Charts'][] = array ( "DisplayName" => "Severity Occurences", "chart_type" => CHART_BARS_VERTICAL, "chart_width" => 400, "chart_field" => SYSLOG_SEVERITY, "maxrecords" => 10, "showpercent" => 1 );
|
$CFG['Charts'][] = array ( "DisplayName" => "Severity Occurences", "chart_type" => CHART_BARS_VERTICAL, "chart_width" => 400, "chart_field" => SYSLOG_SEVERITY, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 );
|
||||||
$CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1 );
|
$CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 );
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Source Options
|
// --- Source Options
|
||||||
|
@ -114,10 +114,10 @@ CREATE TABLE IF NOT EXISTS `logcon_views` (
|
|||||||
-- Table structure for table `logcon_charts`
|
-- Table structure for table `logcon_charts`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `logcon_charts`;
|
|
||||||
CREATE TABLE IF NOT EXISTS `logcon_charts` (
|
CREATE TABLE IF NOT EXISTS `logcon_charts` (
|
||||||
`ID` int(11) NOT NULL auto_increment,
|
`ID` int(11) NOT NULL auto_increment,
|
||||||
`DisplayName` varchar(255) NOT NULL,
|
`DisplayName` varchar(255) NOT NULL,
|
||||||
|
`chart_enabled` tinyint(1) NOT NULL default '1',
|
||||||
`chart_type` int(11) NOT NULL,
|
`chart_type` int(11) NOT NULL,
|
||||||
`chart_width` int(11) NOT NULL,
|
`chart_width` int(11) NOT NULL,
|
||||||
`chart_field` varchar(255) NOT NULL,
|
`chart_field` varchar(255) NOT NULL,
|
||||||
@ -127,3 +127,4 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` (
|
|||||||
`groupid` int(11) default NULL,
|
`groupid` int(11) default NULL,
|
||||||
PRIMARY KEY (`ID`)
|
PRIMARY KEY (`ID`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
CREATE TABLE IF NOT EXISTS `logcon_charts` (
|
CREATE TABLE IF NOT EXISTS `logcon_charts` (
|
||||||
`ID` int(11) NOT NULL auto_increment,
|
`ID` int(11) NOT NULL auto_increment,
|
||||||
`DisplayName` varchar(255) NOT NULL,
|
`DisplayName` varchar(255) NOT NULL,
|
||||||
|
`chart_enabled` tinyint(1) NOT NULL default '1',
|
||||||
`chart_type` int(11) NOT NULL,
|
`chart_type` int(11) NOT NULL,
|
||||||
`chart_width` int(11) NOT NULL,
|
`chart_width` int(11) NOT NULL,
|
||||||
`chart_field` varchar(255) NOT NULL,
|
`chart_field` varchar(255) NOT NULL,
|
||||||
@ -13,5 +14,9 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
-- Insert data
|
-- Insert data
|
||||||
|
INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (1, 'Top Hosts', 1, 3, 400, 'FROMHOST', 10, 0, NULL, NULL);
|
||||||
|
INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (2, 'SyslogTags', 1, 1, 400, 'syslogtag', 10, 0, NULL, NULL);
|
||||||
|
INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (3, 'Severity Occurences', 1, 2, 400, 'syslogseverity', 10, 1, NULL, NULL);
|
||||||
|
INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (4, 'Usage by Day', 1, 1, 400, 'timereported', 10, 1, NULL, NULL);
|
||||||
|
|
||||||
-- Updated Data
|
-- Updated Data
|
||||||
|
@ -417,6 +417,7 @@ function LoadChartsFromDatabase()
|
|||||||
$sqlquery = " SELECT " .
|
$sqlquery = " SELECT " .
|
||||||
DB_CHARTS . ".ID, " .
|
DB_CHARTS . ".ID, " .
|
||||||
DB_CHARTS . ".DisplayName, " .
|
DB_CHARTS . ".DisplayName, " .
|
||||||
|
DB_CHARTS . ".chart_enabled, " .
|
||||||
DB_CHARTS . ".chart_type, " .
|
DB_CHARTS . ".chart_type, " .
|
||||||
DB_CHARTS . ".chart_width, " .
|
DB_CHARTS . ".chart_width, " .
|
||||||
DB_CHARTS . ".chart_field, " .
|
DB_CHARTS . ".chart_field, " .
|
||||||
|
@ -116,14 +116,15 @@ function ConvertCustomCharts()
|
|||||||
foreach($CFG['Charts'] as $chartid => &$myChart)
|
foreach($CFG['Charts'] as $chartid => &$myChart)
|
||||||
{
|
{
|
||||||
// New Entry
|
// New Entry
|
||||||
$result = DB_Query("INSERT INTO " . DB_CHARTS . " (DisplayName, chart_type, chart_width, chart_field, maxrecords, showpercent)
|
$result = DB_Query("INSERT INTO " . DB_CHARTS . " (DisplayName, chart_enabled, chart_type, chart_width, chart_field, maxrecords, showpercent)
|
||||||
VALUES (
|
VALUES (
|
||||||
'" . PrepareValueForDB($myChart['DisplayName']) . "',
|
'" . PrepareValueForDB($myChart['DisplayName']) . "',
|
||||||
" . intval($mySearch['chart_type']) . ",
|
" . intval($myChart['chart_enabled']) . ",
|
||||||
" . intval($mySearch['chart_width']) . ",
|
" . intval($myChart['chart_type']) . ",
|
||||||
'" . PrepareValueForDB($mySearch['chart_field']) . "',
|
" . intval($myChart['chart_width']) . ",
|
||||||
" . intval($mySearch['maxrecords']) . ",
|
'" . PrepareValueForDB($myChart['chart_field']) . "',
|
||||||
" . intval($mySearch['showpercent']) . "
|
" . intval($myChart['maxrecords']) . ",
|
||||||
|
" . intval($myChart['showpercent']) . "
|
||||||
)");
|
)");
|
||||||
$myChart['DBID'] = DB_ReturnLastInsertID($result);
|
$myChart['DBID'] = DB_ReturnLastInsertID($result);
|
||||||
DB_FreeQuery($result);
|
DB_FreeQuery($result);
|
||||||
|
@ -63,53 +63,57 @@ if ( isset($content['Charts']) )
|
|||||||
$i = 0; // Help counter!
|
$i = 0; // Help counter!
|
||||||
foreach ($content['Charts'] as &$myChart )
|
foreach ($content['Charts'] as &$myChart )
|
||||||
{
|
{
|
||||||
// --- Set display name for chart type
|
// Only process if chart is enabled
|
||||||
switch($myChart['chart_type'])
|
if ( isset($myChart['chart_enabled']) && $myChart['chart_enabled'] == 1 )
|
||||||
{
|
{
|
||||||
case CHART_CAKE:
|
// --- Set display name for chart type
|
||||||
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_CAKE'];
|
switch($myChart['chart_type'])
|
||||||
break;
|
{
|
||||||
case CHART_BARS_VERTICAL:
|
case CHART_CAKE:
|
||||||
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_VERTICAL'];
|
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_CAKE'];
|
||||||
break;
|
break;
|
||||||
case CHART_BARS_HORIZONTAL:
|
case CHART_BARS_VERTICAL:
|
||||||
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_HORIZONTAL'];
|
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_VERTICAL'];
|
||||||
break;
|
break;
|
||||||
default:
|
case CHART_BARS_HORIZONTAL:
|
||||||
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_GEN_ERROR_INVALIDTYPE'];
|
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_HORIZONTAL'];
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
// ---
|
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_GEN_ERROR_INVALIDTYPE'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
// --- Set display name for chart field
|
// --- Set display name for chart field
|
||||||
if ( isset($myChart['chart_field']) && isset($content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]) )
|
if ( isset($myChart['chart_field']) && isset($content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]) )
|
||||||
$myChart['CHART_FIELD_DISPLAYNAME'] = $content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ];
|
$myChart['CHART_FIELD_DISPLAYNAME'] = $content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ];
|
||||||
else
|
else
|
||||||
$myChart['CHART_FIELD_DISPLAYNAME'] = $myChart['chart_field'];
|
$myChart['CHART_FIELD_DISPLAYNAME'] = $myChart['chart_field'];
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Set showpercent display
|
// --- Set showpercent display
|
||||||
if ( $myChart['showpercent'] == 1 )
|
if ( $myChart['showpercent'] == 1 )
|
||||||
$myChart['showpercent_display'] = "Yes";
|
$myChart['showpercent_display'] = "Yes";
|
||||||
else
|
else
|
||||||
$myChart['showpercent_display'] = "No";
|
$myChart['showpercent_display'] = "No";
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Set CSS Class
|
// --- Set CSS Class
|
||||||
if ( $i % 2 == 0 )
|
if ( $i % 2 == 0 )
|
||||||
{
|
{
|
||||||
$myChart['cssclass'] = "line1";
|
$myChart['cssclass'] = "line1";
|
||||||
$myChart['rowbegin'] = '<tr><td width="50%" valign="top">';
|
$myChart['rowbegin'] = '<tr><td width="50%" valign="top">';
|
||||||
$myChart['rowend'] = '</td>';
|
$myChart['rowend'] = '</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$myChart['cssclass'] = "line2";
|
||||||
|
$myChart['rowbegin'] = '<td width="50%" valign="top">';
|
||||||
|
$myChart['rowend'] = '</td></tr>';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
// ---
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$myChart['cssclass'] = "line2";
|
|
||||||
$myChart['rowbegin'] = '<td width="50%" valign="top">';
|
|
||||||
$myChart['rowend'] = '</td></tr>';
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
// ---
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -137,5 +141,7 @@ $page -> parser($content, "statistics.html");
|
|||||||
$page -> output();
|
$page -> output();
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
|
//include($gl_root_path . 'include/functions_installhelpers.php');
|
||||||
|
//ConvertCustomCharts();
|
||||||
|
|
||||||
?>
|
?>
|
@ -24,6 +24,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- BEGIN Charts -->
|
<!-- BEGIN Charts -->
|
||||||
|
<!-- IF chart_enabled="1" -->
|
||||||
{rowbegin}
|
{rowbegin}
|
||||||
<br><br>
|
<br><br>
|
||||||
<table cellpadding="0" cellspacing="0" border="0" align="center" valign="top" width="{chart_width}" class="table_with_border_light">
|
<table cellpadding="0" cellspacing="0" border="0" align="center" valign="top" width="{chart_width}" class="table_with_border_light">
|
||||||
@ -54,6 +55,7 @@
|
|||||||
</table>
|
</table>
|
||||||
<br><br>
|
<br><br>
|
||||||
{rowend}
|
{rowend}
|
||||||
|
<!-- ENDIF chart_enabled="1" -->
|
||||||
<!-- END Charts -->
|
<!-- END Charts -->
|
||||||
</table>
|
</table>
|
||||||
<!-- ENDIF statsenabled="true" -->
|
<!-- ENDIF statsenabled="true" -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user