Fixed generate the list with all the graphs, both those configured in the configuration file and those configured in the mysql database.

This commit is contained in:
Jaiver Pastor 2020-05-05 13:38:44 +02:00
parent c6f80b6f87
commit a3e54f44f8
3 changed files with 18 additions and 10 deletions

View File

@ -432,7 +432,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
// --- Process Sources
$i = 0; // Help counter!
foreach ($content['CHARTS'] as &$myChart )
foreach ($content['CHARTS'] as $chartid => &$myChart )
{
// --- Set Image for Type
// NonNUMERIC are config files Sources, can not be editied
@ -467,8 +467,8 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
}
else
{
// define empty ID to update the template correctly.
$myChart['ID'] = "";
// if not defined ID we use chartid how ID
if (! isset($myChart['ID']) ) { $myChart['ID'] = $chartid; }
// Disallow EDIT
$myChart['ActionsAllowed'] = false;
@ -508,7 +508,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
$myChart['set_enabled'] = 1;
}
// ---
// --- Set Chart default Filterstring

View File

@ -133,10 +133,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, "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 );
$CFG['Charts']['Charts1'] = 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']['Charts2'] = array ( "DisplayName" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 );
$CFG['Charts']['Charts3'] = 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']['Charts4'] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 );
// ---
// --- Configure allowed directories for File base logstream sources

View File

@ -952,8 +952,16 @@ function LoadChartsFromDatabase()
$myrows = DB_GetAllRows($result, true);
if ( isset($myrows ) && count($myrows) > 0 )
{
// Overwrite existing Charts array
unset($CFG['Charts']);
// Overwrite the existing graphics matrix but only the records of
// the database, those of the configuration file we keep.
$not_remove = array();
foreach($CFG['Charts'] as $chartid => $myChart)
{
if (! is_numeric($chartid) ) {
$not_remove[$chartid] = $myChart;
}
}
$CFG['Charts'] = $not_remove;
// Loop through all data rows
foreach ($myrows as &$myChart )