diff --git a/pandora_console/godmode/admin_access_logs.php b/pandora_console/godmode/admin_access_logs.php index 82f0af0f7e..4af38ec669 100644 --- a/pandora_console/godmode/admin_access_logs.php +++ b/pandora_console/godmode/admin_access_logs.php @@ -106,8 +106,6 @@ $form .= html_print_table($table, true); $form .= ''; ui_toggle($form, __("Filter"), "", false); -// ui_toggle(graphic_user_activity(400, 150), __("Chart")); - $filter = "1=1"; if (!empty($filter_type)) { diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index f23107f39c..329dd6ded8 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -126,6 +126,22 @@ if (file_exists ('languages/'.$user_language.'.mo')) { echo grafico_modulo_sparse($params); echo ''; } + elseif($type_graph_pdf == 'pie_chart'){ + echo '
'; + echo flot_pie_chart( + $params['values'], + $params['keys'], + $params['width'], + $params['height'], + $params['water_mark_url'], + $params['font'], + $params['font_size'], + $params['legend_position'], + $params['colors'], + $params['hide_labels'] + ); + echo '
'; + } $config['font_size'] = $aux_font_size; ?> diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index ff15c53525..330e926054 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2366,8 +2366,8 @@ function graph_alert_status ($defined_alerts, $fired_alerts, $width = 300, $heig 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - $out = pie2d_graph($config['flash_charts'], $data, $width, $height, __("other"), - '', '', $config['fontpath'], $config['font_size'], 1, "hidden", $colors); + $out = pie_graph($data, $width, $height, __("other"), + '', '', $config['fontpath'], $config['font_size'], 1, "hidden", $colors, false); if ($return) { return $out; @@ -2444,11 +2444,22 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re if (array_sum($data) == 0) { $data = array(); } - - $out = pie2d_graph($config['flash_charts'], $data, $width, $height, - __("other"), ui_get_full_url(false, false, false, false), '', - $config['fontpath'], $config['font_size'], 1, "hidden", $colors); - + + $out = pie_graph( + $data, + $width, + $height, + __("other"), + ui_get_full_url(false, false, false, false), + '', + $config['fontpath'], + $config['font_size'], + 1, + "hidden", + $colors, + 0 + ); + if ($return) { return $out; } @@ -2519,8 +2530,19 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) { $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"), - '', $water_mark, $config['fontpath'], $config['font_size'], 1, "bottom"); + + return pie_graph( + $data, + $width, + $height, + __("other"), + '', + $water_mark, + $config['fontpath'], + $config['font_size'], + 1, + "bottom" + ); } function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value_text = false, $color = false, $options = false) { @@ -2623,227 +2645,6 @@ function graph_sla_slicebar ($id, $period, $sla_min, $sla_max, $date, $daysWeek $config['fontpath'], $round_corner, $home_url, $ttl); } -/** - * Print a pie graph with purge data of agent - * - * @param integer id_agent ID of agent to show - * @param integer width pie graph width - * @param integer height pie graph height - */ -function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) { - global $config; - global $graphic_type; - - $filter = array(); - - if ($id_agent < 1) { - $query = ""; - } - else { - $modules = agents_get_modules($id_agent); - $module_ids = array_keys($modules); - - if (!empty($module_ids)) - $filter['id_agente_modulo'] = $module_ids; - } - - // All data (now) - $time_now = time(); - - // 1 day ago - $time_1day = $time_now - SECONDS_1DAY; - - // 1 week ago - $time_1week = $time_now - SECONDS_1WEEK; - - // 1 month ago - $time_1month = $time_now - SECONDS_1MONTH; - - // Three months ago - $time_3months = $time_now - SECONDS_3MONTHS; - - $query_error = false; - - // Data from 1 day ago - $num_1day = 0; - $num_1day += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_1day); - $num_1day += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_string - WHERE utimestamp > ' . $time_1day); - $num_1day += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_log4x - WHERE utimestamp > ' . $time_1day); - if ($num_1day >= 0) { - // Data from 1 week ago - $num_1week = 0; - $num_1week += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_1week . ' - AND utimestamp < ' . $time_1day); - $num_1week += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_string - WHERE utimestamp > ' . $time_1week . ' - AND utimestamp < ' . $time_1day); - $num_1week += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_log4x - WHERE utimestamp > ' . $time_1week . ' - AND utimestamp < ' . $time_1day); - if ($num_1week >= 0) { - if ($num_1week > 0) { - $num_1week = 0; - $num_1week += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_1week); - $num_1week += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_string - WHERE utimestamp > ' . $time_1week); - $num_1week += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_log4x - WHERE utimestamp > ' . $time_1week); - } - // Data from 1 month ago - $num_1month = 0; - $num_1month += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_1month . ' - AND utimestamp < ' . $time_1week); - $num_1month += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_string - WHERE utimestamp > ' . $time_1month . ' - AND utimestamp < ' . $time_1week); - $num_1month += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_log4x - WHERE utimestamp > ' . $time_1month . ' - AND utimestamp < ' . $time_1week); - if ($num_1month >= 0) { - if ($num_1month > 0) { - $num_1month = 0; - $num_1month += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_1month); - $num_1month += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_string - WHERE utimestamp > ' . $time_1month); - $num_1month += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos_log4x - WHERE utimestamp > ' . $time_1month); - } - // Data from 3 months ago - $num_3months = 0; - $num_3months += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_3months . ' - AND utimestamp < ' . $time_1month); - $num_3months += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_3months . ' - AND utimestamp < ' . $time_1month); - $num_3months += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_3months . ' - AND utimestamp < ' . $time_1month); - if ($num_3months >= 0) { - if ($num_3months > 0) { - $num_3months = 0; - $num_3months += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_3months); - $num_3months += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_3months); - $num_3months += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp > ' . $time_3months); - } - // All data - $num_all = 0; - $num_all += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp < ' . $time_3months); - $num_all += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp < ' . $time_3months); - $num_all += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp < ' . $time_3months); - if ($num_all >= 0) { - $num_older = $num_all - $num_3months; - if ($config['history_db_enabled'] == 1) { - // All data in common and history database - $num_all_w_history = 0; - $num_all_w_history += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp < ' . $time_3months); - $num_all_w_history += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp < ' . $time_3months); - $num_all_w_history += (int) db_get_sql('SELECT COUNT(*) - FROM tagente_datos - WHERE utimestamp < ' . $time_3months); - if ($num_all_w_history >= 0) { - $num_history = $num_all_w_history - $num_all; - } - } - } - } - } - } - } - else if (($num_1day == 0) && ($num_1week == 0) && ($num_1month == 0) && ($num_3months == 0) && ($num_all == 0)) { - //If no data, returns empty - $query_error = true; - } - - // Error - if ($query_error || $num_older < 0 || ($config['history_db_enabled'] == 1 && $num_history < 0) - || (empty($num_1day) && empty($num_1week) && empty($num_1month) - && empty($num_3months) && empty($num_all) - && ($config['history_db_enabled'] == 1 && empty($num_all_w_history)))) { - return html_print_image('images/image_problem_area_small.png', true); - } - - // Data indexes - $str_1day = __("Today"); - $str_1week = "1 ".__("Week"); - $str_1month = "1 ".__("Month"); - $str_3months = "3 ".__("Months"); - $str_older = "> 3 ".__("Months"); - - // Filling the data array - $data = array(); - if (!empty($num_1day)) - $data[$str_1day] = $num_1day; - if (!empty($num_1week)) - $data[$str_1week] = $num_1week; - if (!empty($num_1month)) - $data[$str_1month] = $num_1month; - if (!empty($num_3months)) - $data[$str_3months] = $num_3months; - if (!empty($num_older)) - $data[$str_older] = $num_older; - if ($config['history_db_enabled'] == 1 && !empty($num_history)) { - // In this pie chart only 5 elements are shown, so we need to remove - // an element. With a history db enabled the >3 months element are dispensable - if (count($data) >= 5 && isset($data[$str_3months])) - unset($data[$str_3months]); - - $time_historic_db = time() - ((int)$config['history_db_days'] * SECONDS_1DAY); - $date_human = human_time_comparation($time_historic_db); - $str_history = "> $date_human (".__("History db").")"; - $data[$str_history] = $num_history; - } - - $water_mark = array( - 'file' => $config['homedir'] . "/images/logo_vertical_water.png", - 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false) - ); - - return pie3d_graph($config['flash_charts'], $data, $width, $height, - __('Other'), '', $water_mark, $config['fontpath'], $config['font_size']); -} - /** * Print a horizontal bar graph with packets data of agents * @@ -2950,55 +2751,6 @@ function graph_db_agentes_modulos($width, $height) { 'black'); } -/** - * Print a pie graph with users activity in a period of time - * - * @param integer width pie graph width - * @param integer height pie graph height - * @param integer period time period - */ -function graphic_user_activity ($width = 350, $height = 230) { - global $config; - global $graphic_type; - - $data = array (); - $max_items = 5; - switch ($config['dbtype']) { - case "mysql": - case "postgresql": - $sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario - FROM tsesion - GROUP BY id_usuario - ORDER BY 1 DESC LIMIT %d', $max_items); - break; - case "oracle": - $sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario - FROM tsesion - WHERE rownum <= %d - GROUP BY id_usuario - ORDER BY 1 DESC', $max_items); - break; - } - $logins = db_get_all_rows_sql ($sql); - - if ($logins == false) { - $logins = array(); - } - foreach ($logins as $login) { - $data[$login['id_usuario']] = $login['n_incidents']; - } - - if($config["fixed_graph"] == false){ - $water_mark = array('file' => - $config['homedir'] . "/images/logo_vertical_water.png", - 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); - } - - return pie3d_graph($config['flash_charts'], $data, $width, $height, - __('Other'), '', $water_mark, - $config['fontpath'], $config['font_size']); -} - /** * Print a pie graph with priodity incident */ @@ -3035,9 +2787,11 @@ function grafico_incidente_prioridad () { 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($config['flash_charts'], $data, 320, 200, + return pie_graph( + $data, 320, 200, __('Other'), '', '', - $config['fontpath'], $config['font_size']); + $config['fontpath'], $config['font_size'] + ); } /** @@ -3075,8 +2829,8 @@ function graph_incidents_status () { $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - - return pie3d_graph($config['flash_charts'], $data, 320, 200, + + return pie_graph($data, 320, 200, __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3132,7 +2886,7 @@ function graphic_incident_group () { 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($config['flash_charts'], $data, 320, 200, + return pie_graph($data, 320, 200, __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3187,7 +2941,8 @@ function graphic_incident_user () { 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($config['flash_charts'], $data, 320, 200, + return pie_graph( + $data, 320, 200, __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3241,7 +2996,8 @@ function graphic_incident_source($width = 320, $height = 200) { 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($config['flash_charts'], $data, $width, $height, + return pie_graph( + $data, $width, $height, __('Other'), '', '', $config['fontpath'], $config['font_size']); } @@ -3249,27 +3005,27 @@ function graphic_incident_source($width = 320, $height = 200) { function graph_events_validated($width = 300, $height = 200, $extra_filters = array(), $meta = false, $history = false) { global $config; global $graphic_type; - + $event_type = false; if (array_key_exists('event_type', $extra_filters)) $event_type = $extra_filters['event_type']; - + $event_severity = false; if (array_key_exists('event_severity', $extra_filters)) $event_severity = $extra_filters['event_severity']; - + $event_status = false; if (array_key_exists('event_status', $extra_filters)) $event_status = $extra_filters['event_status']; - + $event_filter_search = false; if (array_key_exists('event_filter_search', $extra_filters)) $event_filter_search = $extra_filters['event_filter_search']; - + $data_graph = events_get_count_events_validated( - array('id_group' => array_keys(users_get_groups())), null, null, + array('id_group' => array_keys(users_get_groups())), null, null, $event_severity, $event_type, $event_status, $event_filter_search); - + $colors = array(); foreach ($data_graph as $k => $v) { if ($k == __('Validated')) { @@ -3279,17 +3035,26 @@ function graph_events_validated($width = 300, $height = 200, $extra_filters = ar $colors[$k] = COL_CRITICAL; } } - + if($config["fixed_graph"] == false){ $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - - echo pie3d_graph( - true, $data_graph, $width, $height, __("other"), "", + + echo pie_graph( + $data_graph, + $width, + $height, + __("other"), + "", $water_mark, - $config['fontpath'], $config['font_size'], 1, false, $colors); + $config['fontpath'], + $config['font_size'], + 1, + false, + $colors + ); } /** @@ -3420,7 +3185,8 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = $water_mark = array(); } - return pie3d_graph($config['flash_charts'], $data, $width, $height, + return pie_graph( + $data, $width, $height, __('Other'), '', $water_mark, $config['fontpath'], $config['font_size'], 1, 'bottom'); } @@ -3484,7 +3250,8 @@ function grafico_eventos_agente ($width = 300, $height = 200, $result = false, $ 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($config['flash_charts'], $data, $width, $height, + return pie_graph( + $data, $width, $height, __('Others'), '', $water_mark, $config['fontpath'], $config['font_size'], 1, 'bottom'); } @@ -3565,7 +3332,8 @@ function grafico_eventos_total($filter = "", $width = 320, $height = 200, $noWat $water_mark = array(); } - return pie3d_graph($config['flash_charts'], $data, $width, $height, + return pie_graph( + $data, $width, $height, __('Other'), '', $water_mark, $config['fontpath'], $config['font_size'], 1, 'bottom', $colors); } @@ -3615,7 +3383,8 @@ function grafico_eventos_usuario ($width, $height) { 'file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png", false, false, false)); - return pie3d_graph($config['flash_charts'], $data, $width, $height, + return pie_graph( + $data, $width, $height, __('Other'), '', $water_mark, $config['fontpath'], $config['font_size']); } @@ -3631,10 +3400,11 @@ function grafico_eventos_usuario ($width, $height) { function graph_custom_sql_graph ($id, $width, $height, $type = 'sql_graph_vbar', $only_image = false, $homeurl = '', $ttl = 1, $max_num_elements = 8) { - + global $config; + $SQL_GRAPH_MAX_LABEL_SIZE = 20; - + $report_content = db_get_row ('treport_content', 'id_rc', $id); if($id != null){ $historical_db = db_get_value_sql("SELECT historical_db from treport_content where id_rc =".$id); @@ -3649,42 +3419,30 @@ function graph_custom_sql_graph ($id, $width, $height, $sql = db_get_row('treport_custom_sql', 'id', $report_content["treport_custom_sql_id"]); $sql = io_safe_output($sql['sql']); } - + if (($config['metaconsole'] == 1) && defined('METACONSOLE')) { $metaconsole_connection = enterprise_hook('metaconsole_get_connection', array($report_content['server_name'])); - + if ($metaconsole_connection === false) { return false; } - + if (enterprise_hook('metaconsole_load_external_db', array($metaconsole_connection)) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); return false; } } - - - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - break; - case "oracle": - $sql = str_replace(";", "", $sql); - break; - } - + $data_result = db_get_all_rows_sql ($sql,$historical_db); - - - + if (($config['metaconsole'] == 1) && defined('METACONSOLE')) enterprise_hook('metaconsole_restore_db'); - + if ($data_result === false) $data_result = array (); - + $data = array (); - + $count = 0; foreach ($data_result as $data_item) { $count++; @@ -3726,19 +3484,20 @@ function graph_custom_sql_graph ($id, $width, $height, } } } - +//XXXXpie_graph $flash_charts = $config['flash_charts']; - +html_debug_print('entra'); if ($only_image) { $flash_charts = false; + $ttl =2; } - + if($config["fixed_graph"] == false){ $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - + switch ($type) { case 'sql_graph_vbar': // vertical bar return vbar_graph( @@ -3787,8 +3546,17 @@ function graph_custom_sql_graph ($id, $width, $height, ); break; case 'sql_graph_pie': // Pie - return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homeurl, - $water_mark, $config['fontpath'], '', $ttl); + return pie_graph( + $data, + $width, + $height, + __("other"), + $homeurl, + $water_mark, + $config['fontpath'], + $config['font_size'], + $ttl + ); break; } } @@ -4512,7 +4280,7 @@ function graph_netflow_aggregate_pie ($data, $aggregate, $ttl = 1, $only_image = 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); } - return pie3d_graph($flash_chart, $values, 370, 200, + return pie_graph($flash_chart, $values, 370, 200, __('Other'), $config['homeurl'], $water_mark, $config['fontpath'], $config['font_size'], $ttl); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index ef14e3bedf..b1874bbb87 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1307,7 +1307,8 @@ function reporting_event_top_n($report, $content, $type = 'dinamic', if ($show_graph != REPORT_TOP_N_ONLY_TABLE) { arsort($data_pie_graph); - $return['charts']['pie'] = pie3d_graph(false, + $return['charts']['pie'] = pie_graph( + false, $data_pie_graph, $width, $height, __("other"), @@ -1460,7 +1461,7 @@ function reporting_event_report_group($report, $content, $filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $return['chart']['by_agent']= pie3d_graph( + $return['chart']['by_agent']= pie_graph( false, $data_graph, 500, @@ -1470,7 +1471,8 @@ function reporting_event_report_group($report, $content, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if ($event_graph_by_user_validator) { @@ -1479,7 +1481,7 @@ function reporting_event_report_group($report, $content, $report["datetime"],$filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $return['chart']['by_user_validator'] = pie3d_graph( + $return['chart']['by_user_validator'] = pie_graph( false, $data_graph, 500, @@ -1489,7 +1491,8 @@ function reporting_event_report_group($report, $content, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if ($event_graph_by_criticity) { @@ -1500,7 +1503,7 @@ function reporting_event_report_group($report, $content, $colors = get_criticity_pie_colors($data_graph); - $return['chart']['by_criticity'] = pie3d_graph( + $return['chart']['by_criticity'] = pie_graph( false, $data_graph, 500, @@ -1512,7 +1515,8 @@ function reporting_event_report_group($report, $content, $config['font_size'], $ttl, false, - $colors); + $colors + ); } if ($event_graph_validated_vs_unvalidated) { @@ -1521,7 +1525,7 @@ function reporting_event_report_group($report, $content, $report["datetime"],$filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $return['chart']['validated_vs_unvalidated'] = pie3d_graph( + $return['chart']['validated_vs_unvalidated'] = pie_graph( false, $data_graph, 500, @@ -1531,7 +1535,8 @@ function reporting_event_report_group($report, $content, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if ($config['metaconsole']) { @@ -2196,7 +2201,7 @@ function reporting_exception($report, $content, $type = 'dinamic', } - $return["chart"]["pie"] = pie3d_graph( + $return["chart"]["pie"] = pie_graph( false, $data_pie_graph, 600, @@ -2206,7 +2211,8 @@ function reporting_exception($report, $content, $type = 'dinamic', ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); $params = array( @@ -2378,7 +2384,7 @@ function reporting_event_report_agent($report, $content, $report["datetime"],$filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $return["chart"]["by_user_validator"] = pie3d_graph( + $return["chart"]["by_user_validator"] = pie_graph( false, $data_graph, 500, @@ -2388,7 +2394,8 @@ function reporting_event_report_agent($report, $content, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if ($event_graph_by_criticity) { @@ -2398,8 +2405,8 @@ function reporting_event_report_agent($report, $content, $filter_event_status, $filter_event_filter_search); $colors = get_criticity_pie_colors($data_graph); - - $return["chart"]["by_criticity"] = pie3d_graph( + + $return["chart"]["by_criticity"] = pie_graph( false, $data_graph, 500, @@ -2411,7 +2418,8 @@ function reporting_event_report_agent($report, $content, $config['font_size'], $ttl, false, - $colors); + $colors + ); } if ($event_graph_validated_vs_unvalidated) { @@ -2420,7 +2428,7 @@ function reporting_event_report_agent($report, $content, $report["datetime"],$filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $return["chart"]["validated_vs_unvalidated"] = pie3d_graph( + $return["chart"]["validated_vs_unvalidated"] = pie_graph( false, $data_graph, 500, @@ -2430,7 +2438,8 @@ function reporting_event_report_agent($report, $content, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if ($config['metaconsole']) { @@ -3309,9 +3318,9 @@ function reporting_alert_report_module($report, $content) { function reporting_sql_graph($report, $content, $type, $force_width_chart, $force_height_chart, $type_sql_graph) { - + global $config; - + switch ($type_sql_graph) { case 'sql_graph_hbar': $return['type'] = 'sql_graph_hbar'; @@ -3323,7 +3332,7 @@ function reporting_sql_graph($report, $content, $type, $return['type'] = 'sql_graph_pie'; break; } - + if (empty($content['name'])) { switch ($type_sql_graph) { case 'sql_graph_vbar': @@ -3337,23 +3346,22 @@ function reporting_sql_graph($report, $content, $type, break; } } - + // Get chart - reporting_set_conf_charts($width, $height, $only_image, $type, - $content, $ttl); - + reporting_set_conf_charts($width, $height, $only_image, $type,$content, $ttl); + if (!empty($force_width_chart)) { $width = $force_width_chart; } - + if (!empty($force_height_chart)) { $height = $force_height_chart; } - + $return['title'] = $content['name']; $return["description"] = $content["description"]; $return["date"] = reporting_get_date_text(); - + switch ($type) { case 'dinamic': case 'static': @@ -3370,7 +3378,7 @@ function reporting_sql_graph($report, $content, $type, case 'data': break; } - + return reporting_check_structure_content($return); } @@ -6610,7 +6618,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $event['chart']['by_user_validator'] = pie3d_graph( + $event['chart']['by_user_validator'] = pie_graph( false, $data_graph, 500, @@ -6620,7 +6628,8 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if ($event_graph_by_criticity) { @@ -6630,7 +6639,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $colors = get_criticity_pie_colors($data_graph); - $event['chart']['by_criticity'] = pie3d_graph( + $event['chart']['by_criticity'] = pie_graph( false, $data_graph, 500, @@ -6642,7 +6651,8 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, $config['font_size'], $ttl, false, - $colors); + $colors + ); } if ($event_graph_validated_vs_unvalidated) { @@ -6650,7 +6660,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, $filter_event_type, $filter_event_status, $filter_event_filter_search); - $event['chart']['validated_vs_unvalidated'] = pie3d_graph( + $event['chart']['validated_vs_unvalidated'] = pie_graph( false, $data_graph, 500, @@ -6660,7 +6670,8 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0, ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], - $ttl); + $ttl + ); } if (!empty ($event)) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index fd4d0a2c76..2afa8216a9 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3038,125 +3038,6 @@ function reporting_get_fired_alerts_table ($alerts_fired) { return $table; } -/** - * Get a report for alerts in a group of agents. - * - * It prints the numbers of alerts defined, fired and not fired in a group. - * It also prints all the alerts that were fired grouped by agents. - * - * @param int $id_group Group to get info of the alerts. - * @param int $period Period of time of the desired alert report. - * @param int $date Beggining date of the report (current date by default). - * @param bool $return Flag to return or echo the report (echo by default). - * - * @return string - */ -function reporting_alert_reporting ($id_group, $period = 0, $date = 0, $return = false) { - global $config; - - $output = ''; - $alerts = get_group_alerts ($id_group); - $alerts_fired = get_alerts_fired ($alerts, $period, $date); - - $fired_percentage = 0; - if (sizeof ($alerts) > 0) - $fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2); - $not_fired_percentage = 100 - $fired_percentage; - - $data = array (); - $data[__('Alerts fired')] = $fired_percentage; - $data[__('Alerts not fired')] = $not_fired_percentage; - - $output .= pie3d_graph(false, $data, 280, 150, - __("other"), - ui_get_full_url(false, false, false, false) . '/', - ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size']); - - $output .= ''.__('Alerts fired').': '.sizeof ($alerts_fired).'
'; - $output .= ''.__('Total alerts monitored').': '.sizeof ($alerts).'
'; - - if (! sizeof ($alerts_fired)) { - if (!$return) - echo $output; - - return $output; - } - $table = reporting_get_fired_alerts_table ($alerts_fired); - $table->width = '100%'; - $table->class = 'databox'; - $table->size = array (); - $table->size[0] = '100px'; - $table->style = array (); - $table->style[0] = 'font-weight: bold'; - - $output .= html_print_table ($table, true); - - if (!$return) - echo $output; - - return $output; -} - -/** - * Get a report for monitors modules in a group of agents. - * - * It prints the numbers of monitors defined, showing those which went up and down, in a group. - * It also prints all the down monitors in the group. - * - * @param int $id_group Group to get info of the monitors. - * @param int $period Period of time of the desired monitor report. - * @param int $date Beginning date of the report in UNIX time (current date by default). - * @param bool $return Flag to return or echo the report (by default). - * - * @return string - */ -function reporting_monitor_health ($id_group, $period = 0, $date = 0, $return = false) { - if (empty ($date)) //If date is 0, false or empty - $date = get_system_time (); - - $datelimit = $date - $period; - $output = ''; - - $monitors = modules_get_monitors_in_group ($id_group); - if (empty ($monitors)) //If monitors has returned false or an empty array - return; - $monitors_down = modules_get_monitors_down ($monitors, $period, $date); - $down_percentage = round (count ($monitors_down) / count ($monitors) * 100, 2); - $not_down_percentage = 100 - $down_percentage; - - $output .= ''.__('Total monitors').': '.count ($monitors).'
'; - $output .= ''.__('Monitors down on period').': '.count ($monitors_down).'
'; - - $table = reporting_get_monitors_down_table ($monitors_down); - $table->width = '100%'; - $table->class = 'databox'; - $table->size = array (); - $table->size[0] = '100px'; - $table->style = array (); - $table->style[0] = 'font-weight: bold'; - - $table->size = array (); - $table->size[0] = '100px'; - - $output .= html_print_table ($table, true); - - $data = array(); - $data[__('Monitors OK')] = $down_percentage; - $data[__('Monitors BAD')] = $not_down_percentage; - - $output .= pie3d_graph(false, $data, 280, 150, - __("other"), - ui_get_full_url(false, false, false, false) . '/', - ui_get_full_url(false, false, false, false) . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size']); - - if (!$return) - echo $output; - - return $output; -} - /** * Get a report table with all the monitors down. * diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index eb638f2c2a..43da132cef 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -180,12 +180,13 @@ function vbar_graph( return ''; } - if ($flash_chart) { + //if ($flash_chart) { return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir,$font,$font_size, $from_ux, $from_wux, $backgroundColor, $tick_color); - } + /* + } else { $new_chart_data = array(); foreach ($chart_data as $key => $value) { @@ -216,7 +217,7 @@ function vbar_graph( $id_graph = serialize_in_temp($graph, null, $ttl); return ""; - } + }*/ } function area_graph( @@ -307,9 +308,9 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, return ''; } - if ($flash_chart) { - return flot_hcolumn_chart( - $chart_data, $width, $height, $water_mark_url, $font, $font_size, $backgroundColor, $tick_color, $val_min, $val_max); + //if ($flash_chart) { + return flot_hcolumn_chart($chart_data, $width, $height, $water_mark_url, $font, $font_size, $backgroundColor, $tick_color, $val_min, $val_max); + /* } else { foreach ($chart_data as $key => $value) { @@ -344,31 +345,12 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, return ""; } + */ } -function pie3d_graph($flash_chart, $chart_data, $width, $height, - $others_str = "other", $homedir = "", $water_mark = "", $font = '', - $font_size = '', $ttl = 1, $legend_position = false, $colors = '', - $hide_labels = false) { - - return pie_graph('3d', $flash_chart, $chart_data, $width, $height, - $others_str, $homedir, $water_mark, $font, $font_size, $ttl, - $legend_position, $colors, $hide_labels); -} - -function pie2d_graph($flash_chart, $chart_data, $width, $height, - $others_str = "other", $homedir="", $water_mark = "", $font = '', - $font_size = '', $ttl = 1, $legend_position = false, $colors = '', - $hide_labels = false) { - - return pie_graph('2d', $flash_chart, $chart_data, $width, $height, - $others_str, $homedir, $water_mark, $font, $font_size, $ttl, - $legend_position, $colors, $hide_labels); -} - -function pie_graph($graph_type, $flash_chart, $chart_data, $width, +function pie_graph($chart_data, $width, $height, $others_str = "other", $homedir="", $water_mark = "", - $font = '', $font_size = '', $ttl = 1, $legend_position = false, + $font = '', $font_size = 8, $ttl = 1, $legend_position = false, $colors = '', $hide_labels = false) { if (empty($chart_data)) { @@ -405,34 +387,35 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $chart_data = $chart_data_trunc; } - if ($flash_chart) { - return flot_pie_chart(array_values($chart_data), - array_keys($chart_data), $width, $height, $water_mark_url, - $font, $font_size, $legend_position, $colors, $hide_labels); - } - else { - //TODO SET THE LEGEND POSITION - $graph = array(); - $graph['data'] = $chart_data; - $graph['width'] = $width; - $graph['height'] = $height; - $graph['water_mark'] = $water_mark_file; - $graph['font'] = $font; - $graph['font_size'] = $font_size; - $graph['legend_position'] = $legend_position; - $graph['color'] = $colors; + $params = array( + 'values' => array_values($chart_data), + 'keys' => array_keys($chart_data), + 'width' => $width, + 'height' => $height, + 'water_mark_url' => $water_mark_url, + 'font' => $font, + 'font_size' => $font_size, + 'legend_position' => $legend_position, + 'colors' => $colors, + 'hide_labels' => $hide_labels + ); - $id_graph = serialize_in_temp($graph, null, $ttl); - - switch ($graph_type) { - case "2d": - return ""; - break; - case "3d": - return ""; - break; - } + if($ttl == 2){ + return generator_chart_to_pdf('pie_chart', $params); } + + return flot_pie_chart( + array_values($chart_data), + array_keys($chart_data), + $width, + $height, + $water_mark_url, + $font, + $font_size, + $legend_position, + $colors, + $hide_labels + ); } function ring_graph($flash_chart, $chart_data, $width, diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 45208c12b8..6e8f69713b 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1,15 +1,12 @@ -/* - - -*/ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator, legend_position, height, colors, hide_labels) { var labels = labels.split(separator); var data = values.split(separator); + if (colors != '') { colors = colors.split(separator); } - + var pieRadius = 0.9; var color = null; @@ -17,62 +14,43 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat if (colors != '') { color = colors[i]; } - data[i] = { label: labels[i], data: parseFloat(data[i]), color: color} } - var label_conf; - - if (width < 400 || hide_labels) { - label_conf = { - show: false - }; - } - else { - label_conf = { - show: true, - radius: pieRadius, - formatter: function(label, series) { - return '
' + - label + '
' + series.percent.toFixed(2) + '%
'; - }, - background: { - opacity: 0.5, - color: '' - } - }; - } - var show_legend = true; if (legend_position == 'hidden') { show_legend = false; } var conf_pie = { - series: { - pie: { - show: true, - radius: pieRadius, - //offset: {top: -100}, - label: label_conf, - //$label_str - } - }, - legend: { - show: show_legend - }, - grid: { - hoverable: true, - clickable: true + series: { + pie: { + show: true, + radius: pieRadius } - }; - - if (width < 400) { - conf_pie.legend.labelFormatter = function(label, series) { - return label + " (" + series.percent.toFixed(2) + "%)"; - } + }, + legend: { + show: show_legend + }, + grid: { + hoverable: true, + clickable: true } + }; + + if(hide_labels != false && hide_labels != 0){ + conf_pie.series.pie.label = { + show: true, + radius: 2/3, + formatter: labelFormatter, + threshold: 0.1 + } + } + else{ + conf_pie.series.pie.label = { + show:false + } + } switch (legend_position) { case 'bottom': @@ -89,7 +67,7 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat var plot = $.plot($('#'+graph_id), data, conf_pie); var legends = $('#'+graph_id+' .legendLabel'); - legends.css('font-size', font_size+'pt'); + legends.css('font-size', font_size+'pt'); // Events $('#' + graph_id).bind('plothover', pieHover); @@ -106,14 +84,18 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat legends.eq(index).css('color', ''); } + function labelFormatter(label, series) { + return '
' + + label + '
' + series.percent.toFixed(2) + '%
'; + } + // Reset styles function resetInteractivity() { legends.css('color', '#3F3F3D'); } - + if (water_mark) { - set_watermark(graph_id, plot, - $('#watermark_image_' + graph_id).attr('src')); + set_watermark(graph_id, plot,$('#watermark_image_' + graph_id).attr('src')); } } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index bf423d2267..4ea828d7c5 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -371,16 +371,16 @@ function menu_graph( function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font = '', $font_size = 8, $legend_position = '', $colors = '', $hide_labels = false) { - + // include_javascript_dependencies_flot_graph(); - + $series = sizeof($values); if (($series != sizeof ($labels)) || ($series == 0) ) { return; } - + $graph_id = uniqid('graph_'); - + switch ($legend_position) { case 'bottom': $height = $height + (count($values) * 24); @@ -390,9 +390,9 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, //TODO FOR TOP OR LEFT OR RIGHT break; } - + $return = "
"; - + if ($water_mark != '') { $return .= ""; $water_mark = 'true'; @@ -400,23 +400,23 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, else { $water_mark = 'false'; } - + $separator = ';;::;;'; - + $labels = implode($separator, $labels); $values = implode($separator, $values); if (!empty($colors)) { $colors = implode($separator, $colors); } - + $return .= ""; - + return $return; } diff --git a/pandora_console/operation/snmpconsole/snmp_statistics.php b/pandora_console/operation/snmpconsole/snmp_statistics.php index 87ef1dabb5..ff7e95a41d 100755 --- a/pandora_console/operation/snmpconsole/snmp_statistics.php +++ b/pandora_console/operation/snmpconsole/snmp_statistics.php @@ -16,7 +16,6 @@ // Load global vars global $config; - enterprise_include ("operation/snmpconsole/snmp_view.php"); include_once($config['homedir'] . '/include/functions_graph.php'); require_once($config['homedir'] . "/include/functions_agents.php"); @@ -169,7 +168,7 @@ unset($table_source_data); if (empty($table_source_graph_data)) $table_source_graph = graph_nodata_image(); else - $table_source_graph = pie3d_graph($config['flash_charts'], $table_source_graph_data, 400, 550, __("Other"), + $table_source_graph = pie_graph($table_source_graph_data, 400, 550, __("Other"), '', $water_mark, $config['fontpath'], $config['font_size'], 1); $table_source_row['graph'] = $table_source_graph; @@ -216,7 +215,7 @@ unset($table_oid_data); if (empty($table_oid_graph_data)) $table_oid_graph = graph_nodata_image(); else - $table_oid_graph = pie3d_graph($config['flash_charts'], $table_oid_graph_data, 400, 550, __("Other"), + $table_oid_graph = pie_graph($table_oid_graph_data, 400, 550, __("Other"), '', $water_mark, $config['fontpath'], $config['font_size'], 1); $table_oid_row['graph'] = $table_oid_graph;