2013-07-16 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/flot/pandora.flot.js, include/functions_networkmap.php, include/constants.php, include/ajax/agent.php, include/ajax/events.php: improve the source code and remove the magic number and they changed for constants. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8527 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c025c94965
commit
3eed1ff8be
|
@ -1,3 +1,11 @@
|
|||
2013-07-16 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/graphs/flot/pandora.flot.js,
|
||||
include/functions_networkmap.php, include/constants.php,
|
||||
include/ajax/agent.php, include/ajax/events.php: improve the
|
||||
source code and remove the magic number and they changed for
|
||||
constants.
|
||||
|
||||
2013-07-15 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php: Fixed javascript
|
||||
|
|
|
@ -94,7 +94,7 @@ if ($search_agents && ((!defined('METACONSOLE')) || $force_local)) {
|
|||
$filter = array ();
|
||||
|
||||
if ($id_group != -1) {
|
||||
if($id_group == 0) {
|
||||
if ($id_group == 0) {
|
||||
$user_groups = users_get_groups ($config['id_user'], "AR", true);
|
||||
|
||||
$filter['id_grupo'] = array_keys ($user_groups);
|
||||
|
|
|
@ -40,14 +40,14 @@ $history = get_parameter ('history', 0);
|
|||
if ($get_event_name) {
|
||||
$event_id = get_parameter ('event_id');
|
||||
|
||||
if($meta) {
|
||||
if ($meta) {
|
||||
$name = events_meta_get_event_name($event_id, $history);
|
||||
}
|
||||
else {
|
||||
$name = db_get_value('evento','tevento','id_evento',$event_id);
|
||||
}
|
||||
|
||||
if($name === false) {
|
||||
if ($name === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ if ($get_response_params) {
|
|||
|
||||
$params = db_get_value('params','tevent_response','id',$response_id);
|
||||
|
||||
if($params === false) {
|
||||
if ($params === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ if ($get_response_target) {
|
|||
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
if(empty($event_response)) {
|
||||
if (empty($event_response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ if ($get_response) {
|
|||
|
||||
$event_response = db_get_row('tevent_response','id',$response_id);
|
||||
|
||||
if(empty($event_response)) {
|
||||
if (empty($event_response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ if ($get_response) {
|
|||
return;
|
||||
}
|
||||
|
||||
if($perform_event_response) {
|
||||
if ($perform_event_response) {
|
||||
global $config;
|
||||
|
||||
$command = get_parameter('target','');
|
||||
|
@ -191,7 +191,7 @@ if ($change_owner) {
|
|||
$event_id = get_parameter ('event_id');
|
||||
$similars = true;
|
||||
|
||||
if($new_owner == -1) {
|
||||
if ($new_owner == -1) {
|
||||
$new_owner = '';
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ if ($get_extended_event) {
|
|||
}
|
||||
|
||||
$readonly = false;
|
||||
if(!$meta &&
|
||||
if (!$meta &&
|
||||
isset($config['event_replication']) &&
|
||||
$config['event_replication'] == 1 &&
|
||||
$config['show_events_in_local'] == 1) {
|
||||
|
@ -444,8 +444,8 @@ if ($get_events_details) {
|
|||
$out .= '</td>';
|
||||
$out .= '<td class="'.get_priority_class ($event['criticity']).'" style="font-size:7pt">';
|
||||
$out .= $title;
|
||||
if($event["estado"] == 1) {
|
||||
if(empty($event['id_usuario'])) {
|
||||
if ($event["estado"] == 1) {
|
||||
if (empty($event['id_usuario'])) {
|
||||
$ack_user = '<i>' . __('Auto') . '</i>';
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -156,6 +156,7 @@ define('AGENT_STATUS_NORMAL', 0);
|
|||
define('AGENT_STATUS_NOT_INIT', 5);
|
||||
define('AGENT_STATUS_NOT_NORMAL', 6);
|
||||
define('AGENT_STATUS_UNKNOW', 3);
|
||||
define('AGENT_STATUS_ALERT_FIRED', 4);
|
||||
define('AGENT_STATUS_WARNING', 2);
|
||||
|
||||
/* Visual maps contants */
|
||||
|
|
|
@ -247,7 +247,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
|
|||
}
|
||||
else {
|
||||
$groups = db_get_all_rows_in_table ('tgrupo');
|
||||
if($groups === false) {
|
||||
if ($groups === false) {
|
||||
$groups = array();
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||
$server_data = db_get_row('tmetaconsole_setup', 'id', $agent['id_server']);
|
||||
}
|
||||
|
||||
if(empty($server_data)) {
|
||||
if (empty($server_data)) {
|
||||
$server_name = '';
|
||||
$server_id = '';
|
||||
$url_hash = '';
|
||||
|
@ -560,20 +560,21 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||
|
||||
// Set node status
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$status_color = '#8DFF1D'; // Normal monitor
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$status_color = '#8DFF1D';
|
||||
break;
|
||||
case 1:
|
||||
$status_color = '#FF1D1D'; // Critical monitor
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$status_color = '#FF1D1D';
|
||||
break;
|
||||
case 2:
|
||||
$status_color = '#FFE308'; // Warning monitor
|
||||
case AGENT_STATUS_WARNING:
|
||||
$status_color = '#FFE308';
|
||||
break;
|
||||
case 4:
|
||||
$status_color = '#FFA300'; // Alert fired
|
||||
case AGENT_STATUS_ALERT_FIRED:
|
||||
$status_color = '#FFA300';
|
||||
break;
|
||||
default:
|
||||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
//Unknown monitor
|
||||
$status_color = '#BBBBBB';
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator, legend_position, height, colors) {
|
||||
var labels = labels.split(separator);
|
||||
var data = values.split(separator);
|
||||
if(colors != '') {
|
||||
if (colors != '') {
|
||||
colors = colors.split(separator);
|
||||
}
|
||||
|
||||
var color = null;
|
||||
for (var i = 0; i < nseries; i++) {
|
||||
if(colors != '') {
|
||||
if (colors != '') {
|
||||
color = colors[i];
|
||||
}
|
||||
|
||||
|
@ -250,13 +250,13 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
$('.values_'+graph_id).css('font-weight', '');
|
||||
if(item != null) {
|
||||
if (item != null) {
|
||||
index = item.dataIndex;
|
||||
$('#value_'+index+'_'+graph_id).css('font-weight', 'bold');
|
||||
}
|
||||
});
|
||||
|
||||
if(water_mark) {
|
||||
if (water_mark) {
|
||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||
}
|
||||
}
|
||||
|
@ -270,11 +270,11 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
var datas = new Array();
|
||||
|
||||
for(i=0;i<values.length;i++) {
|
||||
for (i=0;i<values.length;i++) {
|
||||
var serie = values[i].split(separator);
|
||||
|
||||
var serie_color;
|
||||
if(colors[i] != '') {
|
||||
if (colors[i] != '') {
|
||||
serie_color = colors[i];
|
||||
}
|
||||
else {
|
||||
|
@ -368,7 +368,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
// Format functions
|
||||
function xFormatter(v, axis) {
|
||||
if(labels[v] != undefined) {
|
||||
if (labels[v] != undefined) {
|
||||
return labels[v];
|
||||
}
|
||||
else {
|
||||
|
@ -457,11 +457,11 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
if(item) {
|
||||
if (item) {
|
||||
var from = legend[item.seriesIndex];
|
||||
var to = legend[item.seriesIndex+1];
|
||||
|
||||
if(to == undefined) {
|
||||
if (to == undefined) {
|
||||
to = '>';
|
||||
}
|
||||
|
||||
|
@ -483,8 +483,8 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||
|
||||
// Format functions
|
||||
function xFormatter(v, axis) {
|
||||
for(i = 0; i < acumulate_data.length; i++) {
|
||||
if(acumulate_data[i] == v) {
|
||||
for (i = 0; i < acumulate_data.length; i++) {
|
||||
if (acumulate_data[i] == v) {
|
||||
return '<span style=\'font-size: 6pt\'>' + legend[i] + '</span>';
|
||||
}
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
var warning_min = new Array();
|
||||
$.each(serie,function(i,v) {
|
||||
aux.push([i, v]);
|
||||
if(threshold) {
|
||||
if (threshold) {
|
||||
critical_min.push([i,red_threshold]);
|
||||
warning_min.push([i,yellow_threshold]);
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
}
|
||||
|
||||
var serie_color;
|
||||
if(colors[i] != '') {
|
||||
if (colors[i] != '') {
|
||||
serie_color = colors[i];
|
||||
}
|
||||
else {
|
||||
|
@ -616,7 +616,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
var threshold_data = new Array();
|
||||
|
||||
if(threshold) {
|
||||
if (threshold) {
|
||||
// Warning and critical treshold
|
||||
threshold_data.push({
|
||||
id: 'critical_min',
|
||||
|
@ -775,7 +775,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
// i is the series counter without thresholds
|
||||
var series = dataset[k];
|
||||
|
||||
if(series.label == null) {
|
||||
if (series.label == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -787,10 +787,10 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
var y = series.data[j][1];
|
||||
|
||||
if(currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) {
|
||||
if (currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) {
|
||||
$('#timestamp_'+graph_id).show();
|
||||
// If no legend, the timestamp labels are short and with value
|
||||
if(legends.length == 0) {
|
||||
if (legends.length == 0) {
|
||||
$('#timestamp_'+graph_id).text(labels[j] + ' (' + parseFloat(y).toFixed(2) + ')');
|
||||
}
|
||||
else {
|
||||
|
@ -801,7 +801,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
var timesize = $('#timestamp_'+graph_id).width();
|
||||
|
||||
if(currentRanges != null) {
|
||||
if (currentRanges != null) {
|
||||
dataset = plot.getData();
|
||||
}
|
||||
|
||||
|
@ -809,7 +809,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
var canvaslimit = plot.offset().left + plot.width();
|
||||
|
||||
if(timesize+timenewpos > canvaslimit) {
|
||||
if (timesize+timenewpos > canvaslimit) {
|
||||
$('#timestamp_'+graph_id).css('left', timenewpos - timesize);
|
||||
}
|
||||
else {
|
||||
|
@ -855,7 +855,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
var extrasize = parseInt($('#extra_'+graph_id).css('width').split('px')[0]);
|
||||
|
||||
var left_pos;
|
||||
if(extrasize+timenewpos > canvaslimit) {
|
||||
if (extrasize+timenewpos > canvaslimit) {
|
||||
left_pos = timenewpos - extrasize - 20;
|
||||
}
|
||||
else {
|
||||
|
@ -872,7 +872,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
case legend_alerts+series_suffix_str:
|
||||
case legend_alerts:
|
||||
extra_info = '<b>'+legend_alerts+':<br><span style="font-size:xx-small; font-weight: normal;">From: '+labels_long[item.dataIndex];
|
||||
if(labels_long[item.dataIndex+1] != undefined) {
|
||||
if (labels_long[item.dataIndex+1] != undefined) {
|
||||
extra_info += '<br>To: '+labels_long[item.dataIndex+1];
|
||||
}
|
||||
extra_info += '</span></b>'+get_event_details(alertsz[item.dataIndex]);
|
||||
|
@ -881,7 +881,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
case legend_events+series_suffix_str:
|
||||
case legend_events:
|
||||
extra_info = '<b>'+legend_events+':<br><span style="font-size:xx-small; font-weight: normal;">From: '+labels_long[item.dataIndex];
|
||||
if(labels_long[item.dataIndex+1] != undefined) {
|
||||
if (labels_long[item.dataIndex+1] != undefined) {
|
||||
extra_info += '<br>To: '+labels_long[item.dataIndex+1];
|
||||
}
|
||||
extra_info += '</span></b>'+get_event_details(eventsz[item.dataIndex]);
|
||||
|
@ -892,7 +892,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
break;
|
||||
}
|
||||
|
||||
if(extra_show) {
|
||||
if (extra_show) {
|
||||
$('#extra_'+graph_id).html(extra_info);
|
||||
$('#extra_'+graph_id).css('display','');
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
// Format functions
|
||||
function xFormatter(v, axis) {
|
||||
if(labels[v] == undefined) {
|
||||
if (labels[v] == undefined) {
|
||||
return '';
|
||||
}
|
||||
return '<div style=font-size:'+font_size+'pt>'+labels[v]+'</div>';
|
||||
|
@ -955,7 +955,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
//~ showed[id_clicked] = this.checked;
|
||||
//~ });
|
||||
|
||||
if(menu) {
|
||||
if (menu) {
|
||||
var parent_height;
|
||||
$('#menu_overview_'+graph_id).click(function() {
|
||||
$('#overview_'+graph_id).toggle();
|
||||
|
@ -965,7 +965,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
$('#menu_threshold_'+graph_id).click(function() {
|
||||
datas = new Array();
|
||||
|
||||
if(thresholded) {
|
||||
if (thresholded) {
|
||||
thresholded = false;
|
||||
}
|
||||
else {
|
||||
|
@ -1054,7 +1054,7 @@ function set_watermark(graph_id, plot, watermark_src) {
|
|||
//~ // Now resize the image: x, y, w, h.
|
||||
|
||||
var down_ticks_height = 0;
|
||||
if($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
|
||||
if ($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
|
||||
down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0];
|
||||
}
|
||||
var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width;
|
||||
|
@ -1106,7 +1106,7 @@ function check_adaptions(graph_id) {
|
|||
|
||||
$.each(classes, function(i,v) {
|
||||
// If has a class starting with adapted, we adapt it
|
||||
if(v.split('_')[0] == 'adapted') {
|
||||
if (v.split('_')[0] == 'adapted') {
|
||||
var adapter_id = $('.adapter_'+v.split('_')[1]).attr('id');
|
||||
adjust_left_width_canvas(adapter_id, graph_id);
|
||||
}
|
||||
|
@ -1115,7 +1115,7 @@ function check_adaptions(graph_id) {
|
|||
|
||||
function number_format(number, force_integer, unit) {
|
||||
if (force_integer) {
|
||||
if(Math.round(number) != number) {
|
||||
if (Math.round(number) != number) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue