Merge branch '1129-new-events-bar-in-metaconsole-dev' into 'develop'

1129 new events bar in metaconsole dev

See merge request !690
This commit is contained in:
vgilc 2017-07-25 10:45:10 +02:00
commit a2d15f9f34
3 changed files with 164 additions and 5 deletions

View File

@ -3780,6 +3780,7 @@ function reporting_get_event_histogram ($events, $text_header_event = false) {
);
}
}
$table = new stdClass();
if (!$text_header_event) {
$table->width = '100%';
@ -3839,6 +3840,157 @@ function reporting_get_event_histogram ($events, $text_header_event = false) {
return $event_graph;
}
function reporting_get_event_histogram_meta ($width) {
global $config;
if (!defined("METACONSOLE")) {
include_once ($config['homedir'] .'/include/graphs/functions_gd.php');
}
else {
include_once ('../../include/graphs/functions_gd.php');
}
$period = SECONDS_1HOUR;
if (!$text_header_event) {
$text_header_event = __('Events info (1hr.)');
}
$ttl = 1;
$urlImage = ui_get_full_url(false, true, false, false);
$data = array ();
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
$interval = (int) ($period / $resolution);
$date = get_system_time ();
$datelimit = $date - $period;
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
$legend = array();
$full_legend = array();
$full_legend_date = array();
$colors = array(
EVENT_CRIT_MAINTENANCE => COL_MAINTENANCE,
EVENT_CRIT_INFORMATIONAL => COL_INFORMATIONAL,
EVENT_CRIT_NORMAL => COL_NORMAL,
EVENT_CRIT_MINOR => COL_MINOR,
EVENT_CRIT_WARNING => COL_WARNING,
EVENT_CRIT_MAJOR => COL_MAJOR,
EVENT_CRIT_CRITICAL => COL_CRITICAL
);
$cont = 0;
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
if ($config['flash_charts']) {
$name = date('H:i:s', $bottom);
}
else {
$name = date('H\h', $bottom);
}
}
else {
$name = $bottom;
}
// Show less values in legend
if ($cont == 0 or $cont % 2)
$legend[$cont] = $name;
if ($from_agent_view) {
$full_date = date('Y/m/d', $bottom);
$full_legend_date[$cont] = $full_date;
}
$full_legend[$cont] = $name;
$top = $datelimit + ($periodtime * ($i + 1));
$event = db_get_row_filter ('tmetaconsole_event',
array (
'utimestamp > '.$bottom,
'utimestamp < '.$top),
'criticity, utimestamp');
if (!empty($event['utimestamp'])) {
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case 0:
$data[$cont]['data'] = EVENT_CRIT_MAINTENANCE;
break;
case 1:
$data[$cont]['data'] = EVENT_CRIT_INFORMATIONAL;
break;
case 2:
$data[$cont]['data'] = EVENT_CRIT_NORMAL;
break;
case 3:
$data[$cont]['data'] = EVENT_CRIT_WARNING;
break;
case 4:
$data[$cont]['data'] = EVENT_CRIT_CRITICAL;
break;
case 5:
$data[$cont]['data'] = EVENT_CRIT_MINOR;
break;
case 6:
$data[$cont]['data'] = EVENT_CRIT_MAJOR;
break;
case 20:
$data[$cont]['data'] = EVENT_CRIT_NOT_NORMAL;
break;
case 34:
$data[$cont]['data'] = EVENT_CRIT_WARNING_OR_CRITICAL;
break;
default:
$data[$cont]['data'] = 1;
break;
}
}
else {
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
}
$cont++;
}
$table = new stdClass();
$table->width = '100%';
$table->data = array ();
$table->size = array ();
$table->head = array ();
$table->title = '<span>' . $text_header_event . '</span>';
$table->data[0][0] = "" ;
if (!empty($data)) {
$slicebar = flot_slicesbar_graph($data, $period, "100%", 30, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $url, '', '', false, 0, $full_legend_date);
$table->data[0][0] = $slicebar;
}
else {
$table->data[0][0] = __('No events');
}
if (!$text_header_event) {
$event_graph = '<fieldset class="databox tactical_set">
<legend>' .
$text_header_event .
'</legend>' .
html_print_table($table, true) . '</fieldset>';
}
else {
$table->class = 'noclass';
$event_graph = html_print_table($table, true);
}
return $event_graph;
}
function reporting_html_planned_downtimes_table ($planned_downtimes) {
global $config;

View File

@ -614,10 +614,10 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
legend = legend.split(separator);
acumulate_data = acumulate_data.split(separator);
datacolor = datacolor.split(separator);
if (full_legend != "") {
if (full_legend != false) {
full_legend = full_legend.split(separator);
}
console.log(full_legend);
// Check possible adapt_keys on classes
check_adaptions(graph_id);
@ -706,13 +706,18 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
var year = dateObj.getUTCFullYear();
newdate = year + "/" + month + "/" + day;
}
if(!to){
to= '23:59';
}
if (full_legend != "") {
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&date_to='+newdate2+'&time_to='+to+'&status=-1';
if (newdate2 == undefined) {
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&status=-1';
}
else {
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&date_to='+newdate2+'&time_to='+to+'&status=-1';
}
}
else {
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&date_to='+newdate+'&time_to='+to+'&status=-1';

View File

@ -932,7 +932,6 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $
$acumulate += $value;
$c++;
//$return .= "<div id='value_".$i."_$graph_id' class='values_$graph_id' style='color: #000; position:absolute;'>$value</div>";
if ($value > $max) {
$max = $value;
}
@ -946,6 +945,9 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $
if (!empty($full_legend_date)) {
$full_legend_date = io_safe_output(implode($separator,$full_legend_date));
}
else {
$full_legend_date = false;
}
$acumulate_data = io_safe_output(implode($separator,$acumulate_data));
// Store data series in javascript format