Killing some unicorns and magic numbers.

This commit is contained in:
mdtrooper 2016-01-08 10:24:30 +01:00
parent 35eeedf996
commit 4772b25f5d
2 changed files with 99 additions and 52 deletions

View File

@ -331,20 +331,20 @@ define('PASSSWORD_POLICIES_FIRST_CHANGE', 1);
define('PASSSWORD_POLICIES_EXPIRED', 2);
/* SERVER TYPES */
define('SERVER_TYPE_DATA', 0);
define('SERVER_TYPE_NETWORK', 1);
define('SERVER_TYPE_SNMP', 2);
define('SERVER_TYPE_RECON', 3);
define('SERVER_TYPE_PLUGIN', 4);
define('SERVER_TYPE_PREDICTION', 5);
define('SERVER_TYPE_WMI', 6);
define('SERVER_TYPE_EXPORT', 7);
define('SERVER_TYPE_INVENTORY', 8);
define('SERVER_TYPE_WEB', 9);
define('SERVER_TYPE_EVENT', 10);
define('SERVER_TYPE_ENTERPRISE_ICMP', 11);
define('SERVER_TYPE_ENTERPRISE_SNMP', 12);
define('SERVER_TYPE_ENTERPRISE_SATELLITE', 13);
define('SERVER_TYPE_DATA', 0);
define('SERVER_TYPE_NETWORK', 1);
define('SERVER_TYPE_SNMP', 2);
define('SERVER_TYPE_RECON', 3);
define('SERVER_TYPE_PLUGIN', 4);
define('SERVER_TYPE_PREDICTION', 5);
define('SERVER_TYPE_WMI', 6);
define('SERVER_TYPE_EXPORT', 7);
define('SERVER_TYPE_INVENTORY', 8);
define('SERVER_TYPE_WEB', 9);
define('SERVER_TYPE_EVENT', 10);
define('SERVER_TYPE_ENTERPRISE_ICMP', 11);
define('SERVER_TYPE_ENTERPRISE_SNMP', 12);
define('SERVER_TYPE_ENTERPRISE_SATELLITE', 13);
/* REPORTS */
define('REPORT_TOP_N_MAX', 1);
@ -424,10 +424,10 @@ define("CUSTOM_GRAPH_STACKED_AREA", 1);
define("CUSTOM_GRAPH_LINE", 2);
define("CUSTOM_GRAPH_STACKED_LINE", 3);
define("CUSTOM_GRAPH_BULLET_CHART", 4);
define("CUSTOM_GRAPH_GAUGE", 5);
define("CUSTOM_GRAPH_HBARS", 6);
define("CUSTOM_GRAPH_VBARS", 7);
define("CUSTOM_GRAPH_PIE", 8);
define("CUSTOM_GRAPH_GAUGE", 5);
define("CUSTOM_GRAPH_HBARS", 6);
define("CUSTOM_GRAPH_VBARS", 7);
define("CUSTOM_GRAPH_PIE", 8);
/* COLLECTIONS */
define("COLLECTION_PENDING_APPLY", 0);
@ -442,6 +442,8 @@ define("PAGINATION_BLOCKS_LIMIT", 15);
define("CHART_DEFAULT_WIDTH", 150);
define("CHART_DEFAULT_HEIGHT", 110);
define("CHART_DEFAULT_ALPHA", 50);
/* Statwin */
define("STATWIN_DEFAULT_CHART_WIDTH", 555);
define("STATWIN_DEFAULT_CHART_HEIGHT", 245);

View File

@ -698,19 +698,28 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
// Color commented not to restrict serie colors
if ($show_events) {
$color['event' . $series_suffix] =
array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
array('border' => '#ff0000', 'color' => '#ff0000',
'alpha' => CHART_DEFAULT_ALPHA);
}
if ($show_alerts) {
$color['alert' . $series_suffix] =
array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
array('border' => '#ff7f00', 'color' => '#ff7f00',
'alpha' => CHART_DEFAULT_ALPHA);
}
if ($show_unknown) {
$color['unknown' . $series_suffix] =
array('border' => '#999999', 'color' => '#999999', 'alpha' => 50);
array('border' => '#999999', 'color' => '#999999',
'alpha' => CHART_DEFAULT_ALPHA);
}
$color['max'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['sum'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
$color['min'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$color['max'.$series_suffix] = array(
'border' => '#000000', 'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
$color['sum'.$series_suffix] = array(
'border' => '#000000', 'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
$color['min'.$series_suffix] = array(
'border' => '#000000', 'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
//Baseline was replaced by compare graph feature
//$color['baseline'.$series_suffix] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
$color['unit'.$series_suffix] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10);
@ -1437,7 +1446,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else
$label = $data_module['nombre'];
$label = io_safe_output($label);
$label = io_safe_output($label);
$temp[$label] = array('value'=>$value,
'unit'=>$data_module['unit']);
}
@ -1510,7 +1519,8 @@ function graphic_combined_module ($module_list, $weight_list, $period,
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
@ -1522,35 +1532,50 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$color = array();
$color[0] = array('border' => '#000000',
'color' => $config['graph_color1'], 'alpha' => 50);
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[1] = array('border' => '#000000',
'color' => $config['graph_color2'], 'alpha' => 50);
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[2] = array('border' => '#000000',
'color' => $config['graph_color3'], 'alpha' => 50);
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[3] = array('border' => '#000000',
'color' => $config['graph_color4'], 'alpha' => 50);
'color' => $config['graph_color4'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[4] = array('border' => '#000000',
'color' => $config['graph_color5'], 'alpha' => 50);
'color' => $config['graph_color5'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[5] = array('border' => '#000000',
'color' => $config['graph_color6'], 'alpha' => 50);
'color' => $config['graph_color6'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[6] = array('border' => '#000000',
'color' => $config['graph_color7'], 'alpha' => 50);
'color' => $config['graph_color7'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[7] = array('border' => '#000000',
'color' => $config['graph_color8'], 'alpha' => 50);
'color' => $config['graph_color8'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[8] = array('border' => '#000000',
'color' => $config['graph_color9'], 'alpha' => 50);
'color' => $config['graph_color9'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[9] = array('border' => '#000000',
'color' => $config['graph_color10'], 'alpha' => 50);
'color' => $config['graph_color10'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[11] = array('border' => '#000000',
'color' => COL_GRAPH9, 'alpha' => 50);
'color' => COL_GRAPH9,
'alpha' => CHART_DEFAULT_ALPHA);
$color[12] = array('border' => '#000000',
'color' => COL_GRAPH10, 'alpha' => 50);
'color' => COL_GRAPH10,
'alpha' => CHART_DEFAULT_ALPHA);
$color[13] = array('border' => '#000000',
'color' => COL_GRAPH11, 'alpha' => 50);
'color' => COL_GRAPH11,
'alpha' => CHART_DEFAULT_ALPHA);
$color[14] = array('border' => '#000000',
'color' => COL_GRAPH12, 'alpha' => 50);
'color' => COL_GRAPH12,
'alpha' => CHART_DEFAULT_ALPHA);
$color[15] = array('border' => '#000000',
'color' => COL_GRAPH13, 'alpha' => 50);
'color' => COL_GRAPH13,
'alpha' => CHART_DEFAULT_ALPHA);
switch ($stacked) {
@ -3521,16 +3546,28 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
//$legend['baseline'.$series_suffix] = __('Baseline').$series_suffix_str;
/////////////////////////////////////////////////////////////////////////////////////////
if ($show_events) {
$color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
$color['event'.$series_suffix] =
array('border' => '#ff0000', 'color' => '#ff0000',
'alpha' => CHART_DEFAULT_ALPHA);
}
if ($show_alerts) {
$color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
$color['alert'.$series_suffix] =
array('border' => '#ff7f00', 'color' => '#ff7f00',
'alpha' => CHART_DEFAULT_ALPHA);
}
$color['max'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['sum'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
$color['min'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$color['max'.$series_suffix] =
array('border' => '#000000', 'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
$color['sum'.$series_suffix] =
array('border' => '#000000', 'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
$color['min'.$series_suffix] =
array('border' => '#000000', 'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
if ($show_unknown) {
$color['unknown'.$series_suffix] = array('border' => '#999999', 'color' => '#999999', 'alpha' => 50);
$color['unknown'.$series_suffix] =
array('border' => '#999999', 'color' => '#999999',
'alpha' => CHART_DEFAULT_ALPHA);
}
//$color['baseline'.$series_suffix] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
}
@ -4117,19 +4154,27 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$color = array();
if ($show_events) {
$color['event'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
$color['event'] = array('border' => '#ff0000',
'color' => '#ff0000', 'alpha' => CHART_DEFAULT_ALPHA);
}
if ($show_alerts) {
$color['alert'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
$color['alert'] = array('border' => '#ff7f00',
'color' => '#ff7f00', 'alpha' => CHART_DEFAULT_ALPHA);
}
if (!$avg_only) {
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['max'] = array('border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
}
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
$color['sum'] = array('border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
if (!$avg_only) {
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$color['min'] = array('border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
}
//$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);