From 27880c6450a39220e071d86c3e651edb4a76521d Mon Sep 17 00:00:00 2001 From: javilanz Date: Mon, 21 Mar 2011 17:20:18 +0000 Subject: [PATCH] 2011-03-21 Javier Lanz * include/functions_events.php: Truncated agent and module name * include/functions_reporting.php: Added functionality to store info of General, Top n and Exception reports * include/pchart_graph.php: Added function graph_sla_horizontal to print sla horizontal graph bar. (Not working properly yet) * include/pandora_graph.php: Added prototipe for function graph_sla_horizontal * include/fgraph.php: Added function graph_sla_pie to print sla pie graph * include/functions.php: Added options top n, exception and general for the combo box to select report type. * pandoradb.sql: added fome fields to treport_content table * extras/pandoradb_migrate_v3.2_to_v4.0.sql: added some fields to treport_content table * godmode/reporting/reporting_builder.list_items.php: Truncated agent and module name * godmode/reporting/reporting_builder.preview.php: Added a bottom scroll bar to the report table * godmode/reporting/reporting_builder.php: Added variables for the new kinds of reports, top n, exception and general * godmode/reporting/reporting_builder.item_editor.php: Added html elements for the new kind of reports git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4111 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 24 + .../extras/pandoradb_migrate_v3.2_to_v4.0.sql | 12 +- .../reporting_builder.item_editor.php | 394 ++++++++++- .../reporting_builder.list_items.php | 8 +- .../godmode/reporting/reporting_builder.php | 16 + .../reporting/reporting_builder.preview.php | 3 +- pandora_console/include/fgraph.php | 37 +- pandora_console/include/functions.php | 3 + pandora_console/include/functions_events.php | 2 +- .../include/functions_reporting.php | 646 +++++++++++++++++- pandora_console/include/pandora_graph.php | 1 + pandora_console/include/pchart_graph.php | 59 ++ pandora_console/pandoradb.sql | 8 + 13 files changed, 1145 insertions(+), 68 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ebb148721e..868d94242c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,27 @@ +2011-03-21 Javier Lanz + + * include/functions_events.php: Truncated agent and module name + * include/functions_reporting.php: Added functionality to store info of + General, Top n and Exception reports + * include/pchart_graph.php: Added function graph_sla_horizontal to print + sla horizontal graph bar. (Not working properly yet) + * include/pandora_graph.php: Added prototipe for + function graph_sla_horizontal + * include/fgraph.php: Added function graph_sla_pie to print sla pie graph + * include/functions.php: Added options top n, exception and general for + the combo box to select report type. + * pandoradb.sql: added fome fields to treport_content table + * extras/pandoradb_migrate_v3.2_to_v4.0.sql: added some fields to + treport_content table + * godmode/reporting/reporting_builder.list_items.php: Truncated agent + and module name + * godmode/reporting/reporting_builder.preview.php: Added a bottom scroll + bar to the report table + * godmode/reporting/reporting_builder.php: Added variables for the new + kinds of reports, top n, exception and general + * godmode/reporting/reporting_builder.item_editor.php: Added html + elements for the new kind of reports + 2011-03-21 Juan Manuel Ramon * pandoradb.oracle.sql diff --git a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql index f024cb355a..1bd3f2f0f2 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.2_to_v4.0.sql @@ -26,12 +26,20 @@ ALTER TABLE `tgrupo` MODIFY `nombre` text; -- ----------------------------------------------------- -- Table `tnetwork_component` -- ----------------------------------------------------- -ALTER TABLE `tnetwork_component` ADD COLUMN `post_process` double(18,13) default 0; +ALTER TABLE `tnetwork_component` ADD COLUMN `post_process` double(18,13) DEFAULT 0; -- ----------------------------------------------------- -- Table `treport_content` -- ----------------------------------------------------- -ALTER TABLE treport_content ADD only_display_wrong tinyint(1) unsigned DEFAULT 0 NOT NULL; +ALTER TABLE `treport_content` ADD COLUMN `only_display_wrong` tinyint(1) unsigned NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `top_n` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `top_n_value` INT NOT NULL DEFAULT 10; +ALTER TABLE `treport_content` ADD COLUMN `exception_condition` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `exception_condition_value` DOUBLE (18,6) NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `show_resume` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `order_uptodown` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `show_graph` INT NOT NULL DEFAULT 0; +ALTER TABLE `treport_content` ADD COLUMN `group_by_agent` INT NOT NULL DEFAULT 0 -- ----------------------------------------------------- -- Table `tusuario` diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index e0c721e26c..868e894697 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -49,6 +49,14 @@ switch ($action) { $sunday = true; $time_from = '00:00'; $time_to = '23:59'; + $group_by_agent = 0; + $order_uptodown = 0; + $show_resume = 0; + $top_n = 0; + $top_n_value = 10; + $exception_condition = 0; + $exception_condition_value = 10; + $show_graph = 0; break; default: $actionParameter = 'update'; @@ -87,6 +95,7 @@ switch ($action) { $sunday = $item['sunday']; $time_from = $item['time_from']; $time_to = $item['time_to']; + $show_graph = $item['show_graph']; break; case 'monitor_report': $description = $item['description']; @@ -212,6 +221,31 @@ switch ($action) { $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); $period = $item['period']; break; + case 'general': + $description = $item['description']; + $group_by_agent = $item['group_by_agent']; + $period = $item['period']; + $order_uptodown = $item['order_uptodown']; + $show_resume = $item['show_resume']; + $show_graph = $item['show_graph']; + break; + case 'top_n': + $description = $item['description']; + $period = $item['period']; + $top_n = $item ['top_n']; + $top_n_value = $item ['top_n_value']; + $show_resume = $item['show_resume']; + $show_graph = $item['show_graph']; + $order_uptodown = $item['order_uptodown']; + break; + case 'exception': + $description = $item['description']; + $period = $item['period']; + $exception_condition = $item['exception_condition']; + $exception_condition_value = $item['exception_condition_value']; + $show_resume = $item['show_resume']; + $show_graph = $item['show_graph']; + $order_uptodown = $item['order_uptodown']; } break; @@ -230,7 +264,7 @@ $urlForm = 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&ta echo '
'; print_input_hidden('id_item', $idItem); ?> - +
@@ -284,7 +318,9 @@ print_input_hidden('id_item', $idItem); - + @@ -363,11 +399,69 @@ print_input_hidden('id_item', $idItem); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
='); + print_radio_button ('radiobutton_exception_condition', 1, '', $exception_condition); + echo __('<'); + print_radio_button ('radiobutton_exception_condition', 2, '', $exception_condition); + echo __('OK'); + print_radio_button ('radiobutton_exception_condition', 3, '', $exception_condition); + echo __('Not OK'); + print_radio_button ('radiobutton_exception_condition', 4, '', $exception_condition); + ?>
'; +print_SLA_list('95%', $action, $idItem); +print_General_list('95%', $action, $idItem); +echo '
'; if ($action == 'new') { print_submit_button(__('Create item'), 'create_item', false, 'class="sub wand"'); } @@ -386,7 +480,7 @@ if ($enterpriseEnable) { function print_SLA_list($width, $action, $idItem = null) { ?> - +
@@ -420,11 +514,11 @@ function print_SLA_list($width, $action, $idItem = null) { $nameModule = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); echo ' - - - - - + + + + + @@ -447,7 +541,7 @@ function print_SLA_list($width, $action, $idItem = null) { - + @@ -464,11 +558,82 @@ function print_SLA_list($width, $action, $idItem = null) { +
' . $nameAgent . '' . $nameModule . '' . $item['sla_min'] . '' . $item['sla_max'] . '' . $item['sla_limit'] . '' . printTruncateText($nameAgent, 20) . '' . printTruncateText($nameModule, 20) . '' . print_input_text('input_min', $item['sla_min'], '', 15, 255, true) . '' . print_input_text('input_max', $item['sla_max'], '', 15, 255, true) . '' . print_input_text('input_limit', $item['sla_limit'], '', 10, 255, true) . ' ' . print_image("images/cross.png", true) . '  Type at least two characters to search
+ + + + + + + + + + + + '; + $itemsGeneral = get_db_all_rows_filter('treport_content_item', array('id_report_content' => $idItem)); + if ($itemsGeneral === false) { + $itemsGeneral = array(); + } + foreach ($itemsGeneral as $item) { + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + $nameAgent = get_agent_name ($idAgent); + $nameModule = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + + echo ' + + + + '; + } + echo ''; + ?> + + + + + + + + + + + + + + + +
' . printTruncateText($nameAgent, 35) . '' . printTruncateText($nameModule, 35) . ' + ' . print_image("images/cross.png", true) . ' +
+ +  Type at least two characters to search
+ + diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index a1c99ff892..33f68b72da 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -214,18 +214,18 @@ foreach ($items as $item) { $row[3] = '-'; } else { - $row[2] = get_agent_name(get_agent_module_id($item['id_agent_module'])); - $row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + $row[2] = printTruncateText(get_agent_name(get_agent_module_id($item['id_agent_module'])), 20); + $row[3] = printTruncateText(get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])), 20); } } else { - $row[2] = get_agent_name($item['id_agent']); + $row[2] = printTruncateText(get_agent_name($item['id_agent']), 20); if ($item['id_agent_module'] == '') { $row [3] = '-'; } else { - $row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + $row[3] = printTruncateText(get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])),20); } } diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 9dcc3b4783..a3e8c281bf 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -187,6 +187,14 @@ switch ($action) { $values['sunday'] = get_parameter('sunday', 0); $values['time_from'] = get_parameter('time_from'); $values['time_to'] = get_parameter('time_to'); + $values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent'); + $values['show_resume'] = get_parameter ('checkbox_show_resume'); + $values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown'); + $values['top_n'] = get_parameter('radiobutton_max_min_avg'); + $values['top_n_value'] = get_parameter('quantity'); + $values['exception_condition'] = get_parameter('radiobutton_exception_condition'); + $values['exception_condition_value'] = get_parameter('exception_condition_value'); + $values['show_graph'] = get_parameter('checkbox_show_graph'); if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar')OR ($values['type'] == 'sql_graph_vbar') OR ($values['type'] == 'sql_graph_pie')) { $values['treport_custom_sql_id'] = get_parameter('id_custom'); @@ -227,6 +235,14 @@ switch ($action) { $values['sunday'] = get_parameter('sunday', 0); $values['time_from'] = get_parameter('time_from'); $values['time_to'] = get_parameter('time_to'); + $values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent'); + $values['show_resume'] = get_parameter ('checkbox_show_resume'); + $values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown'); + $values['top_n'] = get_parameter('radiobutton_max_min_avg'); + $values['top_n_value'] = get_parameter('quantity'); + $values['exception_condition'] = get_parameter('radiobutton_exception_condition'); + $values['exception_condition_value'] = get_parameter('exception_condition_value'); + $values['show_graph'] = get_parameter('checkbox_show_graph'); if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar')OR ($values['type'] == 'sql_graph_vbar') OR ($values['type'] == 'sql_graph_pie')) { diff --git a/pandora_console/godmode/reporting/reporting_builder.preview.php b/pandora_console/godmode/reporting/reporting_builder.preview.php index 9cae4a4f2e..ae8614f29e 100644 --- a/pandora_console/godmode/reporting/reporting_builder.preview.php +++ b/pandora_console/godmode/reporting/reporting_builder.preview.php @@ -144,8 +144,9 @@ foreach ($contents as $content) { $table->rowstyle = array (); render_report_html_item ($content, $table, $report); - + echo '
'; print_table ($table); + echo "
"; flush (); } ?> \ No newline at end of file diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index f237472a5a..c0f12ffc9e 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -42,7 +42,7 @@ else { } -enterprise_include ('include/functions_reporting.php'); +enterprise_include_once ('include/functions_reporting.php'); set_time_limit (0); //error_reporting (0); @@ -2321,6 +2321,33 @@ function graph_custom_sql_graph ($id, $width, $height, $type = 1) { } +function graph_sla_pie ($value1, $value2, $value3, $value4, $width, $height) { + $data_graph = array (); + $data_graph[__('Inside limits')] = $value1; + $data_graph[__('Out of limits')] = $value2; + $data_graph[__('On the edge')] = $value3; + $data_graph[__('Unknown')] = $value4; + + generic_pie_graph ($width, $height, $data_graph, array ('show_legend' => true)); +} + +function graph_sla_horizontal ($progress, $width, $height, $id) { + global $config; + + $engine = get_graph_engine (); + + $engine->width = $width; + $engine->height = $height; + $engine->fontpath = $config['fontpath']; + + $engine->background_color = '#FFFFFF'; + $engine->show_title = true; + $engine->title = format_numeric ($progress).' %'; + $color = '#2C5196'; + + $engine->graph_sla_horizontal ($progress, $color); +} + function myErrorHandler($errno, $errstr, $errfile, $errline) { @@ -2382,6 +2409,7 @@ $draw_alerts = (int) get_parameter ('draw_alerts'); $value1 = get_parameter ('value1'); $value2 = get_parameter ('value2'); $value3 = get_parameter("value3", 0); +$value4 = get_parameter ('value4'); $stacked = get_parameter ("stacked", 0); $date = get_parameter ("date"); $graphic_type = (string) get_parameter ('tipo'); @@ -2514,6 +2542,13 @@ if ($graphic_type) { case 'sql_graph_pie': graph_custom_sql_graph ($report_id, $width, $height, 3); break; + + case 'sla_pie_graph': + graph_sla_pie ($value1, $value2, $value3, $value4, $width, $height); + break; + case 'sla_horizontal_graph': + graph_sla_horizontal (20, $width, $height, $id); + break; case 'graphic_error': default: diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index bdd69cd0bb..0fd443041f 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -656,6 +656,9 @@ function get_report_types () { $types['event_report_agent'] = __('Event report agent'); $types['event_report_module'] = __('Event report module'); $types['event_report_group'] = __('Event report group'); + $types['general'] = __('General'); + $types['top_n'] = __('Top n'); + $types['exception'] = __('Exception'); // $types['agent_detailed_event'] = __('Agent detailed event'); // $types['list_events_module'] = __('List events of module'); // $types['list_events_agent'] = __('List events of agent'); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index b83cbc5b55..f4fbaceab1 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -405,7 +405,7 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = if ($event["id_agente"] > 0) { // Agent name - $data[4] = print_agent_name ($event["id_agente"], true); + $data[4] = print_agent_name ($event["id_agente"], true, 25, '', true); // for System or SNMP generated alerts } elseif ($event["event_type"] == "system") { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3aa19a0560..fd23aa9cb2 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -25,6 +25,7 @@ require_once ($config["homedir"]."/include/functions.php"); require_once ($config["homedir"]."/include/functions_db.php"); require_once ($config["homedir"]."/include/functions_agents.php"); +include_once ("include/fgraph.php"); /** @@ -1742,6 +1743,7 @@ function get_agent_module_info ($id_agent, $filter = false) { function render_report_html_item ($content, $table, $report, $mini = false) { global $config; + global $graphic_type; if($mini){ $sizh = ''; @@ -1779,8 +1781,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[2][0] = 4; if ($content["description"] != ""){ - $table->colspan[2][0] = 4; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -1802,8 +1804,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[2][0] = 4; if ($content["description"] != "") { - $table->colspan[2][0] = 4; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -1826,8 +1828,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[2][0] = 3; if ($content["description"] != ""){ - $table->colspan[2][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -1855,16 +1857,17 @@ function render_report_html_item ($content, $table, $report, $mini = false) { break; case 3: case 'SLA': + $show_graph = $content['show_graph']; //RUNNING $table->style[1] = 'text-align: right'; $data = array (); $data[0] = $sizh . __('S.L.A.').$sizhfin; - $data[1] = $sizh . human_time_description_raw($content['period']) . $sizhfin;; + $data[1] = $sizh . human_time_description_raw($content['period']) . $sizhfin; $n = array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -1880,21 +1883,40 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $slas = array (); } + $data_graph = array (); + $data_graph[__('Inside limits')] = 0; + $data_graph[__('Out of limits')] = 0; + $data_graph[__('On the edge')] = 0; + $data_graph[__('Unknown')] = 0; + $sla_failed = false; foreach ($slas as $sla) { //Get the sla_value in % and store it on $sla_value $sla_value = get_agentmodule_sla ($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'], $content['time_to']); + if ($sla_value === false) { + $data_graph[__('Unknown')]++; + } + else if ($sla_value <= ($sla['sla_limit']+10) && $sla_value >= ($sla['sla_limit']-10)) { + $data_graph[__('On the edge')]++; + } + else if ($sla_value > ($sla['sla_limit']+10)) { + $data_graph[__('Inside limits')]++; + } + else if ($sla_value < ($sla['sla_limit']-10)) { + $data_graph[__('Out of limits')]++; + } + //Do not show right modules if 'only_display_wrong' is active if ($content['only_display_wrong'] == 1 && $sla_value >= $sla['sla_limit']) continue; $data = array (); $data[0] = ''.__('Agent')." : "; - $data[0] .= get_agentmodule_agent_name ($sla['id_agent_module'])."
"; + $data[0] .= printTruncateText(get_agentmodule_agent_name ($sla['id_agent_module']))."
"; $data[0] .= ''.__('Module')." : "; - $data[0] .= get_agentmodule_name ($sla['id_agent_module'])."
"; + $data[0] .= printTruncateText(get_agentmodule_name ($sla['id_agent_module']))."
"; $data[0] .= ''.__('SLA Max. (value)')." : "; $data[0] .= $sla['sla_max']."
"; $data[0] .= ''.__('SLA Min. (value)')." : "; @@ -1928,6 +1950,25 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $table->colspan[$n - 1][0] = 3; $table->rowstyle[$n - 1] = 'text-align: right'; } + if ($show_graph && !empty($slas)) { + if($config['flash_charts']) { + echo fs_3d_pie_chart ($data_graph, 370, 180); + } + else { + //Display pie graph + echo ''; + } + //Display horizontal bar graphs +/* + foreach ($slas as $sla) { + echo ''; + } +*/ + } break; case 6: @@ -1940,8 +1981,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -1969,13 +2010,13 @@ function render_report_html_item ($content, $table, $report, $mini = false) { //RUNNING $data = array (); $data[0] = $sizh.__('Avg. Value').$sizhfin; - $data[1] = $sizh.$agent_name.' - '.$module_name.$sizhfin; + $data[1] = $sizh.printTruncateText($agent_name).' - '.printTruncateText($module_name).$sizhfin; $data[2] = $sizh.human_time_description_raw ($content['period']).$sizhfin; array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2003,8 +2044,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2027,8 +2068,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[0][0] = 2; if ($content["description"] != ""){ - $table->colspan[0][0] = 2; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2056,8 +2097,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[0][0] = 2; if ($content["description"] != ""){ - $table->colspan[0][0] = 2; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2085,8 +2126,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2104,8 +2145,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $table->colspan[0][0] = 2; // Put description at the end of the module (if exists) + $table->colspan[0][0] = 2; if ($content["description"] != ""){ - $table->colspan[0][0] = 2; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2121,8 +2162,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $table->colspan[0][0] = 2; // Put description at the end of the module (if exists) + $table->colspan[0][0] = 2; if ($content["description"] != ""){ - $table->colspan[0][0] = 2; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2191,8 +2232,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $table->colspan[0][0] = 2; // Put description at the end of the module (if exists) + $table->colspan[0][0] = 2; if ($content["description"] != ""){ - $table->colspan[0][0] = 2; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2220,8 +2261,9 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data[1] = $sizh . get_group_name($content['id_agent']) . $sizhfin; array_push ($table->data, $data); + // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2240,8 +2282,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2259,8 +2301,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2278,8 +2320,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2297,8 +2339,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2321,8 +2363,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2372,8 +2414,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2400,8 +2442,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2428,8 +2470,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2456,8 +2498,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data); // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; if ($content["description"] != ""){ - $table->colspan[1][0] = 3; $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); @@ -2477,6 +2519,556 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data[0] = '

'.$mttr.'

'; array_push ($table->data, $data); break; + case 'general': + $group_by_agent = $content['group_by_agent']; + $order_uptodown = $content['order_uptodown']; + + $table->style[1] = 'text-align: right'; + $data = array (); + $data[0] = $sizh.__('General').$sizhfin; + $data[1] = $sizh.human_time_description ($content['period']).$sizhfin; + array_push ($table->data, $data); + + // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; + if ($content["description"] != ""){ + $data_desc = array(); + $data_desc[0] = $content["description"]; + array_push ($table->data, $data_desc); + } + + switch ($group_by_agent) { + //0 means not group by agent + case 0: + $sql = sprintf("select a.id_agent_module, b.nombre as agent_name, + c.nombre as module_name from treport_content_item as a, tagente as b, + tagente_modulo as c where a.id_agent_module = c.id_agente_modulo and + c.id_agente = b.id_agente and id_report_content = %d", $content['id_rc']); + + $generals = process_sql ($sql); + if ($generals === false) { + $data = array (); + $table->colspan[2][0] = 3; + $data[0] = __('There are no Agent/Modules defined'); + array_push ($table->data, $data); + break; + } + + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('Value'); + $table1->style[0] = 'text-align: center'; + $table1->style[1] = 'text-align: center'; + $table1->style[2] = 'text-align: center'; + + $data_avg = array(); + foreach ($generals as $key => $row) { + $data_avg[$key] = get_agentmodule_data_average ($row['id_agent_module'], $content['period']); + $id_agent_module[$key] = $row['id_agent_module']; + $agent_name[$key] = $row['agent_name']; + $module_name[$key] = $row['module_name']; + } + + if ($order_uptodown == 0 || $order_uptodown == 1 || $order_uptodown == 2) { + switch ($order_uptodown) { + //Descending + case 1: + array_multisort($data_avg, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //Ascending + case 2: + array_multisort($data_avg, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + } + $i=0; + foreach ($data_avg as $d) { + $data = array(); + $data[0] = printTruncateText($agent_name[$i], 30); + $data[1] = printTruncateText($module_name[$i], 30); + $d === false ? $data[2] = '--':$data[2] = $d; + array_push ($table1->data, $data); + $i++; + } + } + elseif ($order_uptodown == 3) { + array_multisort($agent_name, SORT_ASC, $data_avg, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + $i=0; + foreach ($agent_name as $a) { + $data = array(); + $data[0] = printTruncateText($agent_name[$i], 30); + $data[1] = printTruncateText($module_name[$i], 30); + $data_avg[$i] === false ? $data[2] = '--':$data[2] = $data_avg[$i]; + array_push ($table1->data, $data); + $i++; + } + } + + $table->colspan[2][0] = 3; + $data = array(); + $data[0] = print_table($table1, true); + array_push ($table->data, $data); + break; + //1 means group by agent + case 1: + //Get the list of agents + $sql_agents = sprintf ("select distinct ta.nombre from tagente as ta, + tagente_modulo as tam, treport_content_item as trci + where ta.id_agente = tam.id_agente and tam.id_agente_modulo = trci.id_agent_module + and trci.id_report_content = %d", $content['id_rc']); + $agent_list = process_sql ($sql_agents); + + //Get the list of modules + $sql_modules = sprintf ("select distinct tam.nombre from tagente_modulo as tam, + treport_content_item as trci where tam.id_agente_modulo = trci.id_agent_module + and trci.id_report_content = %d", $content['id_rc']); + $modules_list = process_sql ($sql_modules); + + //Get the data + $sql_data = sprintf("select trci.id_agent_module, ta.nombre as agent_name, + tam.nombre as module_name from treport_content_item as trci, tagente as ta, + tagente_modulo as tam where ta.id_agente = tam.id_agente and + tam.id_agente_modulo = trci.id_agent_module + and id_report_content = %d", $content['id_rc']); + $generals = process_sql ($sql_data); + + if ($generals === false) { + $data = array (); + $table->colspan[2][0] = 3; + $data[0] = __('There are no Agent/Modules defined'); + array_push ($table->data, $data); + break; + } + + $table2->width = '99%'; + $table2->data = array (); + $table2->head = array (); + $table2->head[0] = __('Agent'); + $table2->style[0] = 'text-align: center'; + $i = 1; + foreach ($modules_list as $m) { + $table2->head[$i] = printTruncateText($m['nombre'], 20); + $table2->style[$i] = 'text-align: center'; + $i++; + } + + foreach ($agent_list as $a) { + $data = array(); + $data[0] = printTruncateText($a['nombre'], 20); + $i = 1; + foreach ($modules_list as $m) { + foreach ($generals as $g) { + $agent_name = $g['agent_name']; + $module_name = $g['module_name']; + $found = false; + if (strcmp($a['nombre'], $agent_name) == 0 && strcmp($m['nombre'], $module_name) == 0) { + if (get_agentmodule_data_average($g['id_agent_module'], $content['period']) === false) + $data[$i] = '--'; + else { + $data[$i] = get_agentmodule_data_average($g['id_agent_module'], $content['period']); + } + $found = true; + } + else { + $data[$i] = '--'; + } + if ($found == true) break; + } + $i++; + } + array_push($table2->data, $data); + } + + $table->colspan[2][0] = 3; + $data = array(); + $data[0] = print_table($table2, true); + array_push ($table->data, $data); + break; + } + if ($content['show_resume'] && count($generals) > 0) { + + //Get the first valid value and assign it to $min & $max + $min = false; + $i=0; + do { + $min = get_agentmodule_data_average($generals[$i]['id_agent_module'], $content['period']); + $i++; + } while ($min === false && $i < count($generals)); + $max = $min; + $avg = 0; + $length = 0; + foreach ($generals as $g) { + $value = get_agentmodule_data_average ($g['id_agent_module'], $content['period']); + if ($value !== false) { + if ($value > $max) { + $max = $value; + } + if ($value < $min ) { + $min = $value; + } + $avg += $value; + $length++; + } + } + $avg = $avg / $length; + + $data_resume = array(); + $data_resume[0] = "Max Value: ".$max; + array_push ($table->data, $data_resume); + $data_resume[0] = "Min Value: ".$min; + array_push ($table->data, $data_resume); + $data_resume[0] = "Average Value: ".$avg; + array_push ($table->data, $data_resume); + } + break; + case 'top_n': + $order_uptodown = $content['order_uptodown']; + $top_n = $content['top_n']; + $top_n_value = $content['top_n_value']; + + $table->style[1] = 'text-align: right'; + $data = array (); + $data[0] = $sizh.__('Top').' '.$content['top_n_value'].$sizhfin; + $data[1] = $sizh.human_time_description ($content['period']).$sizhfin; + array_push ($table->data, $data); + + // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; + if ($content["description"] != ""){ + $data_desc = array(); + $data_desc[0] = $content["description"]; + array_push ($table->data, $data_desc); + } + //Get all the related data + $sql = sprintf("select a.id_agent_module, b.nombre as agent_name, + c.nombre as module_name from treport_content_item as a, tagente as b, + tagente_modulo as c where a.id_agent_module = c.id_agente_modulo and + c.id_agente = b.id_agente and id_report_content = %d", $content['id_rc']); + + $tops = process_sql ($sql); + if ($tops === false) { + $data = array (); + $table->colspan[2][0] = 3; + $data[0] = __('There are no Agent/Modules defined'); + array_push ($table->data, $data); + break; + } + + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('Value'); + $table1->style[0] = 'text-align: center'; + $table1->style[1] = 'text-align: center'; + $table1->style[2] = 'text-align: center'; + + $data_top = array(); + foreach ($tops as $key => $row) { + switch ($top_n) { + //Max + case 1: + $value = get_agentmodule_data_max ($row['id_agent_module'], $content['period']); + break; + //Min + case 2: + $value = get_agentmodule_data_min ($row['id_agent_module'], $content['period']); + break; + //Nothing or Average + case 0: //If nothing is selected then it will be shown the average data + case 3: + $value = get_agentmodule_data_average ($row['id_agent_module'], $content['period']); + break; + } + //If the returned value from get_agentmodule_data... is false it won't be stored. + if ($value !== false) { + $data_top[$key] = $value; + $id_agent_module[$key] = $row['id_agent_module']; + $agent_name[$key] = $row['agent_name']; + $module_name[$key] = $row['module_name']; + } + } + + switch ($top_n) { + //Max + case 1: + array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //Min + case 2: + array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //By agent name or without selection + case 0: + case 3: + array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + } + + $data_top_values = array (); + $data_top_values['data_top'] = $data_top; + $data_top_values['agent_name'] = $agent_name; + $data_top_values['module_name'] = $module_name; + $data_top_values['id_agent_module'] = $id_agent_module; + + array_splice ($data_top, $top_n_value); + array_splice ($agent_name, $top_n_value); + array_splice ($module_name, $top_n_value); + array_splice ($id_agent_module, $top_n_value); + + switch ($order_uptodown) { + //Descending + case 1: + array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //Ascending + case 2: + array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //By agent name or without selection + case 0: + case 3: + array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + } + + if ($order_uptodown == 1 || $order_uptodown == 2) { + $i = 0; + foreach ($data_top as $dt) { + $data = array(); + $data[0] = printTruncateText($agent_name[$i], 30); + $data[1] = printTruncateText($module_name[$i], 30); + $data[2] = $dt; + array_push ($table1->data, $data); + $i++; + if ($i >= $top_n_value) break; + } + } + else if ($order_uptodown == 0 || $order_uptodown == 3) { + $i = 0; + foreach ($agent_name as $an) { + $data = array(); + $data[0] = printTruncateText($an, 30); + $data[1] = printTruncateText($module_name[$i], 30); + $data[2] = $data_top[$i]; + array_push ($table1->data, $data); + $i++; + if ($i >= $top_n_value) break; + } + } + + $table->colspan[2][0] = 3; + $data = array(); + $data[0] = print_table($table1, true); + array_push ($table->data, $data); + + if ($content['show_resume'] && count($data_top_values) > 0) { + //Get the very first not null value + $i=0; + do { + $min = $data_top_values['data_top'][$i]; + $i++; + } while ($min === false && $i < count($data_top_values)); + $max = $min; + $avg = 0; + + $i=0; + foreach ($data_top_values['data_top'] as $key => $dtv) { + if ($dtv < $min) $min = $dtv; + if ($dtv > $max) $max = $dtv; + $avg += $dtv; + $i++; + } + $avg = $avg / $i; + + $data_resume = array(); + $data_resume[0] = __('Max Value').': '.$max; + array_push ($table->data, $data_resume); + $data_resume[0] = __('Min Value').': '.$min; + array_push ($table->data, $data_resume); + $data_resume[0] = __('Average Value').': '.$avg; + array_push ($table->data, $data_resume); + } + break; + case 'exception': + $order_uptodown = $content['order_uptodown']; + $exception_condition = $content['exception_condition']; + $exception_condition_value = $content['exception_condition_value']; + + $table->style[1] = 'text-align: right'; + $data = array (); + $data[0] = $sizh.__('Exception'); + switch ($exception_condition) { + case 0: + $data[0] .= ' - '.__('Everything'); + break; + case 1: + $data[0] .= ' - '.__('Modules over or equal to').' '.$exception_condition_value; + break; + case 2: + $data[0] .= ' - '.__('Modules under').' '.$exception_condition_value; + break; + case 3: + $data[0] .= ' - '.__('Modules at normal status'); + break; + case 4: + $data[0] .= ' - '.__('Modules at critial or warning status'); + break; + } + $data[0].=$sizhfin; + $data[1] = $sizh.human_time_description ($content['period']).$sizhfin; + array_push ($table->data, $data); + + // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; + if ($content["description"] != ""){ + $data_desc = array(); + $data_desc[0] = $content["description"]; + array_push ($table->data, $data_desc); + } + //Get all the related data + $sql = sprintf("select a.id_agent_module, b.nombre as agent_name, + c.nombre as module_name from treport_content_item as a, tagente as b, + tagente_modulo as c where a.id_agent_module = c.id_agente_modulo and + c.id_agente = b.id_agente and id_report_content = %d", $content['id_rc']); + + $exceptions = process_sql ($sql); + if ($exceptions === false) { + $data = array (); + $table->colspan[2][0] = 3; + $data[0] = __('There are no Agent/Modules defined'); + array_push ($table->data, $data); + break; + } + + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('Value'); + $table1->style[0] = 'text-align: center'; + $table1->style[1] = 'text-align: center'; + $table1->style[2] = 'text-align: center'; + + //Get the very first not null value + $i=0; + do { + $min = get_agentmodule_data_average ($exceptions[$i]['id_agent_module'], $content['period']); + $i++; + } while ($min === false && $i < count($exceptions)); + $max = $min; + $avg = 0; + + $i=0; + foreach ($exceptions as $exc) { + $value = get_agentmodule_data_average ($exc['id_agent_module'], $content['period']); + if ($value !== false) { + if ($value > $max) $max = $value; + if ($value < $min) $min = $value; + $avg += $value; + $i++; + switch ($exception_condition) { + //Display everything + case 0: + break; + //Display modules over or equal to certain value + case 1: + //Skip modules under 'value' + if ($value < $exception_condition_value) { + continue 2; + } + break; + //Display modules under a certain value + case 2: + //Skip modules over or equal to 'value' + if ($value >= $exception_condition_value) { + continue 2; + } + break; + //Display modules at Normal status + case 3: + //Skip modules without normal status + if (get_agentmodule_status($exc['id_agent_module']) != 0) { + continue 2; + } + break; + //Display modules at critical, warning or unknown status + case 4: + //Skip modules at normal status + if (get_agentmodule_status($exc['id_agent_module']) == 0) { + continue 2; + } + break; + } + $data_exceptions[] = $value; + $id_agent_module[] = $exc['id_agent_module']; + $agent_name[] = $exc['agent_name']; + $module_name[] = $exc['module_name']; + } + } + //$i > 0 means that there is at least one row on the table + if ($i > 0) { + $avg = $avg / $i; + + switch ($order_uptodown) { + //Descending + case 1: + array_multisort($data_exceptions, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //Ascending + case 2: + array_multisort($data_exceptions, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + //By agent name or without selection + case 0: + case 3: + array_multisort($agent_name, SORT_ASC, $data_exceptions, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC); + break; + } + + if ($order_uptodown == 1 || $order_uptodown == 2) { + $j=0; + foreach ($data_exceptions as $dex) { + $data = array(); + $data[0] = printTruncateText($agent_name[$j], 30); + $data[1] = printTruncateText($module_name[$j], 30); + $data[2] = $dex; + array_push ($table1->data, $data); + $j++; + } + } + else if ($order_uptodown == 0 || $order_uptodown == 3) { + $j=0; + foreach ($agent_name as $an) { + $data = array(); + $data[0] = printTruncateText($an, 30); + $data[1] = printTruncateText($module_name[$j], 30); + $data[2] = $data_exceptions[$j]; + array_push ($table1->data, $data); + $j++; + } + } + } + + $table->colspan[2][0] = 3; + $data = array(); + $data[0] = print_table($table1, true); + array_push ($table->data, $data); + + if ($content['show_resume'] && $i>0) { + $data_resume = array(); + $data_resume[0] = __('Max Value').': '.$max; + array_push ($table->data, $data_resume); + $data_resume[0] = __('Min Value').': '.$min; + array_push ($table->data, $data_resume); + $data_resume[0] = __('Average Value').': '.$avg; + array_push ($table->data, $data_resume); + } + break; } } diff --git a/pandora_console/include/pandora_graph.php b/pandora_console/include/pandora_graph.php index 39a2afc031..a3969600a7 100644 --- a/pandora_console/include/pandora_graph.php +++ b/pandora_console/include/pandora_graph.php @@ -60,6 +60,7 @@ abstract class PandoraGraphAbstract { abstract protected function single_graph (); abstract protected function combined_graph ($values, $events, $alerts, $unit_name, $max_value, $stacked); abstract protected function progress_bar ($value, $color); + abstract protected function graph_sla_horizontal ($value, $color); } function get_graph_engine ($period = 3600) { diff --git a/pandora_console/include/pchart_graph.php b/pandora_console/include/pchart_graph.php index c771c2824d..f8b2a689b0 100644 --- a/pandora_console/include/pchart_graph.php +++ b/pandora_console/include/pchart_graph.php @@ -651,5 +651,64 @@ class PchartGraph extends PandoraGraphAbstract { $this->graph->setColorPalette ($a, $color['r'], $color['g'], $color['b']); } } + + public function graph_sla_horizontal ($value, $color) { + set_time_limit (0); + $date = (string) get_parameter ('date', date ('Y-m-j')); + $time = (string) get_parameter ('time', date ('h:iA')); + $datetime = strtotime ($date.' '.$time); + // Dataset definition + $this->graph = new pChart ($this->width, $this->height); + $this->graph->setFontProperties ($this->fontpath, 8); + + // Round corners defined in global setup + global $config; + if ($config["round_corner"] != 0) + $radius = ($this->height > 18) ? 8 : 0; + else + $radius = 0; + $ratio = 200; + //$ratio = (int) $value / 100 * $this->width; + + /* Color stuff */ + $bgcolor = $this->get_rgb_values ($this->background_color); + $r = hexdec (substr ($this->background_color, 1, 2)); + $g = hexdec (substr ($this->background_color, 3, 2)); + $b = hexdec (substr ($this->background_color, 5, 2)); + + /* Actual percentage */ + if (! $this->show_title || $value > 0) { + debugPrint("entra en el if show title or value > 0", "/tmp/prueba.txt"); + $color = $this->get_rgb_values ($color); + $this->graph->drawFilledRoundedRectangle (50, 0, $ratio+50, + $this->height, $radius, $color['r'], $color['g'], $color['b']); + $this->graph->drawFilledRoundedRectangle (300, 0, $ratio+300, + $this->height, $radius, $color['r'], $color['g'], $color['b']); + } + + if ($config["round_corner"]) { + debugPrint("entra en el if de round_corner", "/tmp/prueba.txt"); + /* Under this value, the rounded rectangle is painted great */ + if ($ratio <= 16) { + /* Clean a bit of pixels */ + for ($i = 0; $i < 7; $i++) { + $this->graph->drawLine (0, $i, 6 - $i, $i, 255, 255, 255); + } + $end = $this->height - 1; + for ($i = 0; $i < 7; $i++) { + $this->graph->drawLine (0, $end - $i, 5 - $i, $end - $i, 255, 255, 255); + } + } + } + + if ($this->border) { + debugPrint("entra en el Ășltimo if, el de border", "/tmp/prueba.txt"); + $this->graph->drawRoundedRectangle (0, 0, $this->width + 50, + $this->height - 1, + $radius, 157, 157, 157); + } + + $this->graph->Stroke (); + } } ?> diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 117be07ed6..49ae3fa82f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -815,6 +815,14 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `saturday` tinyint(1) default 1, `sunday` tinyint(1) default 1, `only_display_wrong` tinyint (1) unsigned default 0 not null, + `top_n` INT NOT NULL default 0, + `top_n_value` INT NOT NULL default 10, + `exception_condition` INT NOT NULL default 0, + `exception_condition_value` DOUBLE (18,6) NOT NULL default 0, + `show_resume` INT NOT NULL default 0, + `order_uptodown` INT NOT NULL default 0, + `show_graph` INT NOT NULL default 0, + `group_by_agent` INT NOT NULL default 0, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE