Merge branch '3137-Pete_jquery_en_tree_view_metaconsola' into 'develop'

fixed error events graphs

See merge request artica/pandorafms!2013
This commit is contained in:
vgilc 2018-11-23 10:51:06 +01:00
commit 9fef25c9a4
3 changed files with 13 additions and 20 deletions

View File

@ -3188,16 +3188,14 @@ function graph_custom_sql_graph ($id, $width, $height,
* @param string homeurl * @param string homeurl
* @param bool return or echo the result * @param bool return or echo the result
*/ */
function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $from_agent_view = false) { function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $from_agent_view = false, $widgets=false) {
global $config; global $config;
global $graphic_type; global $graphic_type;
$data = array (); $data = array ();
//$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph //TODO interval
$resolution = 5 * ($period * 2 / $width); // Number of "slices" we want in graph $interval = 24;
$interval = (int) ($period / $resolution);
$date = get_system_time (); $date = get_system_time ();
$datelimit = $date - $period; $datelimit = $date - $period;
$periodtime = floor ($period / $interval); $periodtime = floor ($period / $interval);
@ -3206,7 +3204,7 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
$legend = array(); $legend = array();
$full_legend = array(); $full_legend = array();
$full_legend_date = array(); $full_legend_date = array();
$cont = 0; $cont = 0;
for ($i = 0; $i < $interval; $i++) { for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i); $bottom = $datelimit + ($periodtime * $i);
@ -3216,24 +3214,24 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
else { else {
$name = $bottom; $name = $bottom;
} }
// Show less values in legend // Show less values in legend
if ($cont == 0 or $cont % 2) if ($cont == 0 or $cont % 2)
$legend[$cont] = $name; $legend[$cont] = $name;
if ($from_agent_view) { if ($from_agent_view) {
$full_date = date('Y/m/d', $bottom); $full_date = date('Y/m/d', $bottom);
$full_legend_date[$cont] = $full_date; $full_legend_date[$cont] = $full_date;
} }
$full_legend[$cont] = $name; $full_legend[$cont] = $name;
$top = $datelimit + ($periodtime * ($i + 1)); $top = $datelimit + ($periodtime * ($i + 1));
$event = db_get_row_filter ('tevento', $event = db_get_row_filter ('tevento',
array ('id_agente' => $id_agent, array ('id_agente' => $id_agent,
'utimestamp > '.$bottom, 'utimestamp > '.$bottom,
'utimestamp < '.$top), 'criticity, utimestamp'); 'utimestamp < '.$top), 'criticity, utimestamp');
if (!empty($event['utimestamp'])) { if (!empty($event['utimestamp'])) {
$data[$cont]['utimestamp'] = $periodtime; $data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) { switch ($event['criticity']) {
@ -3258,7 +3256,7 @@ function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $ho
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN); $colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN);
// Draw slicebar graph // Draw slicebar graph
$out = flot_slicesbar_graph($data, $period, 100, 40, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date); $out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date, 0, 1, $widgets);
if ($return) { if ($return) {
return $out; return $out;

View File

@ -714,20 +714,15 @@ function treeview_printTable($id_agente, $server_data = array(), $no_head = fals
ui_toggle($table_advanced, __('Advanced information')); ui_toggle($table_advanced, __('Advanced information'));
// Blank space below title, DONT remove this, this
// Breaks the layout when Flash charts are enabled :-o
//echo '<div id="id_div" style="height: 10px">&nbsp;</div>';
if ($config["agentaccess"]) { if ($config["agentaccess"]) {
$access_graph = '<div style="width:100%; height:130px;">'; $access_graph = '<div style="width:100%; height:130px;">';
$access_graph .= graphic_agentaccess($id_agente, 380, 120, SECONDS_1DAY, true, true); $access_graph .= graphic_agentaccess ($id_agente, 380, 120, SECONDS_1DAY, true, true);
$access_graph .= '</div>'; $access_graph .= '</div>';
ui_toggle($access_graph, __('Agent access rate (24h)')); ui_toggle($access_graph, __('Agent access rate (24h)'));
} }
$events_graph = '<div style="margin-left: 10px;">'; $events_graph = '<div style="margin-left:10px; width:100%;">';
$events_graph .= graph_graphic_agentevents ($id_agente, 290, 15, $events_graph .= graph_graphic_agentevents ($id_agente, 375, 45, SECONDS_1DAY, '', true, false, true);
SECONDS_1DAY, '', true);
$events_graph .= '</div><br>'; $events_graph .= '</div><br>';
ui_toggle($events_graph, __('Events (24h)')); ui_toggle($events_graph, __('Events (24h)'));

View File

@ -645,7 +645,7 @@ $data[0][0] .=
__('Events (24h)') . __('Events (24h)') .
'</th></tr>' . '</th></tr>' .
'<tr><td style="text-align:center;padding-left:20px;padding-right:20px;"><br />' . '<tr><td style="text-align:center;padding-left:20px;padding-right:20px;"><br />' .
graph_graphic_agentevents ($id_agente, 450, 40, SECONDS_1DAY, '', true, true) . graph_graphic_agentevents ($id_agente, 100, 45, SECONDS_1DAY, '', true, true) .
'<br /></td></tr>' . '<br /></td></tr>' .
'</table>'; '</table>';