Added sample charts into db upgrade script, and added option to disable charts

This commit is contained in:
unknown 2008-09-12 10:50:38 +02:00
parent e3e640aba9
commit fb242ca286
7 changed files with 69 additions and 53 deletions

View File

@ -99,10 +99,10 @@ $CFG['Search'][] = array ( "DisplayName" => "All messages from last 31 days", "S
// ---
// --- 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" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0 );
$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" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1 );
$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, "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, "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, "chart_enabled" => 1 );
// ---
// --- Source Options

View File

@ -114,10 +114,10 @@ CREATE TABLE IF NOT EXISTS `logcon_views` (
-- Table structure for table `logcon_charts`
--
DROP TABLE IF EXISTS `logcon_charts`;
CREATE TABLE IF NOT EXISTS `logcon_charts` (
`ID` int(11) NOT NULL auto_increment,
`DisplayName` varchar(255) NOT NULL,
`chart_enabled` tinyint(1) NOT NULL default '1',
`chart_type` int(11) NOT NULL,
`chart_width` int(11) NOT NULL,
`chart_field` varchar(255) NOT NULL,
@ -127,3 +127,4 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` (
`groupid` int(11) default NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ;

View File

@ -2,6 +2,7 @@
CREATE TABLE IF NOT EXISTS `logcon_charts` (
`ID` int(11) NOT NULL auto_increment,
`DisplayName` varchar(255) NOT NULL,
`chart_enabled` tinyint(1) NOT NULL default '1',
`chart_type` int(11) NOT NULL,
`chart_width` int(11) 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 ;
-- 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

View File

@ -417,6 +417,7 @@ function LoadChartsFromDatabase()
$sqlquery = " SELECT " .
DB_CHARTS . ".ID, " .
DB_CHARTS . ".DisplayName, " .
DB_CHARTS . ".chart_enabled, " .
DB_CHARTS . ".chart_type, " .
DB_CHARTS . ".chart_width, " .
DB_CHARTS . ".chart_field, " .

View File

@ -116,14 +116,15 @@ function ConvertCustomCharts()
foreach($CFG['Charts'] as $chartid => &$myChart)
{
// 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 (
'" . PrepareValueForDB($myChart['DisplayName']) . "',
" . intval($mySearch['chart_type']) . ",
" . intval($mySearch['chart_width']) . ",
'" . PrepareValueForDB($mySearch['chart_field']) . "',
" . intval($mySearch['maxrecords']) . ",
" . intval($mySearch['showpercent']) . "
" . intval($myChart['chart_enabled']) . ",
" . intval($myChart['chart_type']) . ",
" . intval($myChart['chart_width']) . ",
'" . PrepareValueForDB($myChart['chart_field']) . "',
" . intval($myChart['maxrecords']) . ",
" . intval($myChart['showpercent']) . "
)");
$myChart['DBID'] = DB_ReturnLastInsertID($result);
DB_FreeQuery($result);

View File

@ -63,53 +63,57 @@ if ( isset($content['Charts']) )
$i = 0; // Help counter!
foreach ($content['Charts'] as &$myChart )
{
// --- Set display name for chart type
switch($myChart['chart_type'])
// Only process if chart is enabled
if ( isset($myChart['chart_enabled']) && $myChart['chart_enabled'] == 1 )
{
case CHART_CAKE:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_CAKE'];
break;
case CHART_BARS_VERTICAL:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_VERTICAL'];
break;
case CHART_BARS_HORIZONTAL:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_HORIZONTAL'];
break;
default:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_GEN_ERROR_INVALIDTYPE'];
break;
}
// ---
// --- Set display name for chart type
switch($myChart['chart_type'])
{
case CHART_CAKE:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_CAKE'];
break;
case CHART_BARS_VERTICAL:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_VERTICAL'];
break;
case CHART_BARS_HORIZONTAL:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_HORIZONTAL'];
break;
default:
$myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_GEN_ERROR_INVALIDTYPE'];
break;
}
// ---
// --- Set display name for chart field
if ( isset($myChart['chart_field']) && isset($content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]) )
$myChart['CHART_FIELD_DISPLAYNAME'] = $content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ];
else
$myChart['CHART_FIELD_DISPLAYNAME'] = $myChart['chart_field'];
// ---
// --- Set display name for chart field
if ( isset($myChart['chart_field']) && isset($content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]) )
$myChart['CHART_FIELD_DISPLAYNAME'] = $content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ];
else
$myChart['CHART_FIELD_DISPLAYNAME'] = $myChart['chart_field'];
// ---
// --- Set showpercent display
if ( $myChart['showpercent'] == 1 )
$myChart['showpercent_display'] = "Yes";
else
$myChart['showpercent_display'] = "No";
// ---
// --- Set showpercent display
if ( $myChart['showpercent'] == 1 )
$myChart['showpercent_display'] = "Yes";
else
$myChart['showpercent_display'] = "No";
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
{
$myChart['cssclass'] = "line1";
$myChart['rowbegin'] = '<tr><td width="50%" valign="top">';
$myChart['rowend'] = '</td>';
// --- Set CSS Class
if ( $i % 2 == 0 )
{
$myChart['cssclass'] = "line1";
$myChart['rowbegin'] = '<tr><td width="50%" valign="top">';
$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();
// ---
//include($gl_root_path . 'include/functions_installhelpers.php');
//ConvertCustomCharts();
?>

View File

@ -24,6 +24,7 @@
</tr>
<!-- BEGIN Charts -->
<!-- IF chart_enabled="1" -->
{rowbegin}
<br><br>
<table cellpadding="0" cellspacing="0" border="0" align="center" valign="top" width="{chart_width}" class="table_with_border_light">
@ -54,6 +55,7 @@
</table>
<br><br>
{rowend}
<!-- ENDIF chart_enabled="1" -->
<!-- END Charts -->
</table>
<!-- ENDIF statsenabled="true" -->