From bef2a36c3d39c6d7ca7e16f40f2a86cb838c093f Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 26 Feb 2013 16:10:02 +0000 Subject: [PATCH] 2013-02-26 Sergio Martin * include/functions_html.php include/styles/pandora.css include/functions_graph.php include/javascript/jquery.pandora.js index.php: Change the HTML native title for the images by a jquery engined title more visible and customizable * general/logon_ok.php include/functions_reporting.php: Improve the main page graphs and layout git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7721 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 ++++ pandora_console/general/logon_ok.php | 76 +++++++++++++------ pandora_console/include/functions_graph.php | 17 +++-- pandora_console/include/functions_html.php | 72 +++++++++++++++++- .../include/functions_reporting.php | 5 +- .../include/javascript/jquery.pandora.js | 56 ++++++++++++++ pandora_console/include/styles/pandora.css | 33 +++++++- pandora_console/index.php | 3 + 8 files changed, 244 insertions(+), 32 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8619bf72f8..0d21877f8a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2013-02-26 Sergio Martin + + * include/functions_html.php + include/styles/pandora.css + include/functions_graph.php + include/javascript/jquery.pandora.js + index.php: Change the HTML native title for + the images by a jquery engined title more + visible and customizable + + * general/logon_ok.php + include/functions_reporting.php: Improve the + main page graphs and layout + 2013-02-25 Miguel de Dios * include/functions_modules.php: fixed in function diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 5aed041847..8eda0ea5bc 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -37,6 +37,7 @@ if(tags_has_user_acl_tags()) { // Site news ! // --------------------------------------------------------------------------- +echo '
'; // Container top echo '
'; switch ($config["dbtype"]) { @@ -79,26 +80,6 @@ echo '
'; echo '
'; $data = reporting_get_group_stats (); -$table->class = "databox"; -$table->cellpadding = 4; -$table->cellspacing = 4; -$table->head = array (); -$table->data = array (); -$table->width = "100%"; - -$table->data[0][0] =''.__('Monitor health').''; -$table->data[1][0] = - progress_bar($data["monitor_health"], 280, 20, $data["monitor_health"].'% '.__('of monitors up'), 0); -$table->data[2][0] = ''.__('Module sanity').''; -$table->data[3][0] = - progress_bar($data["module_sanity"], 280, 20, $data["module_sanity"].'% '.__('of total modules inited'), 0); -$table->data[4][0] = ''.__('Alert level').''; -$table->data[5][0] = - progress_bar($data["alert_level"], 280, 20, $data["alert_level"].'% '.__('of defined alerts not fired'), 0); - -html_print_table ($table); -unset ($table); - /////////////// // Overview /////////////// @@ -111,6 +92,7 @@ $urls['monitor_critical'] = "index.php?sec=estado&sec2=operation/agentes/sta $urls['monitor_warning'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=1"; $urls['monitor_ok'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=0"; $urls['monitor_unknown'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=3"; +$urls['monitor_not_init'] = "index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=5"; $urls['monitor_alerts'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60"; $urls['monitor_alerts_fired'] = "index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired"; if (check_acl ($config['id_user'], 0, "UM")) { @@ -129,6 +111,33 @@ $table_transparent->data = array (); $table_transparent->style[0] = $table_transparent->style[1] = $table_transparent->style[2] = $table_transparent->style[3] = 'text-align:center; width: 25%;'; $table_transparent->width = "100%"; +// Indicators table +$table_ind = clone $table_transparent; + +$tdata[0] = '
+ ' . + __('Monitor health') . ui_print_help_tip (sprintf(__('%d Not OK monitors'), $data["monitor_not_normal"]), true) . + '' . + progress_bar($data["monitor_health"], 280, 20, $data["monitor_health"].'% '.__('of monitors up'), 0) . '
'; +$table_ind->rowclass[] = ''; +$table_ind->data[] = $tdata; + +$tdata[0] = '
+ ' . + __('Module sanity') . ui_print_help_tip (sprintf(__('%d Not inited monitors'), $data["monitor_not_init"]), true) . + '' . + progress_bar($data["module_sanity"], 280, 20, $data["module_sanity"].'% '.__('of total modules inited'), 0) . '
'; +$table_ind->rowclass[] = ''; +$table_ind->data[] = $tdata; + +$tdata[0] = '
+ ' . + __('Alert level') . ui_print_help_tip (sprintf(__('%d Fired alerts'), $data["monitor_alerts_fired"]), true) . + '' . + progress_bar($data["alert_level"], 280, 20, $data["alert_level"].'% '.__('of defined alerts not fired'), 0) . '
'; +$table_ind->rowclass[] = ''; +$table_ind->data[] = $tdata; + // Agents and modules table $table_am = clone $table_transparent; @@ -169,11 +178,23 @@ $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; $tdata = array(); -$table_mbs->colspan[count($table_mbs->data)][0] = 4; -$tdata[0] = '
' . graph_agent_status (false, 250, 150, true) . '
'; +$tdata[0] = html_print_image('images/status_sets/default/agent_no_data_ball.png', true, array('title' => __('Monitor not init'), 'width' => '20px')); +$tdata[1] = $data["monitor_not_init"] == 0 ? '-' : $data["monitor_not_init"]; +$tdata[1] = '' . $tdata[1] . ''; + +$tdata[2] = $tdata[3] = ''; $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; +if($data["monitor_checks"] > 0) { + $tdata = array(); + $table_mbs->colspan[count($table_mbs->data)][0] = 4; + $table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;'; + $tdata[0] = '
' . graph_agent_status (false, 250, 150, true, true) . '
'; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; +} + // Alerts table $table_al = clone $table_transparent; @@ -211,6 +232,12 @@ $table->width = "100%"; $table->head[0] = __('Pandora FMS Overview'); $table->head_colspan[0] = 4; +// Indicators +$tdata = array(); +$tdata[0] = html_print_table($table_ind, true); +$table->rowclass[] = ''; +$table->data[] = $tdata; + // Total agents and modules $tdata = array(); $tdata[0] = '
@@ -255,9 +282,10 @@ html_print_table($table); unset($table); echo "
"; -echo '
'; -echo "

"; +echo "
"; +echo '
'; // Container top +echo '
'; // Show last activity from this user echo "

" . __('This is your last activity in Pandora FMS console') . "

"; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index d8ed8b4cc1..49d40cd6bb 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1345,8 +1345,9 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0, $return = * @param integer width pie graph width * @param integer height pie graph height * @param bool return or echo flag + * @param bool show_not_init flag */ -function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $return = false) { +function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $return = false, $show_not_init = false) { global $config; @@ -1360,9 +1361,11 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re $fields = array('SUM(critical_count) Critical', 'SUM(warning_count) Warning', 'SUM(normal_count) Normal', - 'SUM(unknown_count) Unknown', - 'SUM(fired_count) "Fired Alerts"'/*, - 'SUM(notinit_count) "Not init"'*/); + 'SUM(unknown_count) Unknown'); + + if($show_not_init) { + $fields[] = 'SUM(notinit_count) "Not init"'; + } $agent_status = db_get_all_rows_filter('tagente', $filter, $fields); @@ -1371,7 +1374,11 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => ui_get_full_url("/images/logo_vertical_water.png")); - $colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN, COL_ALERTFIRED/*, COL_NOTINIT*/); + $colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN); + + if($show_not_init) { + $colors[] = COL_NOTINIT; + } $out = pie2d_graph($config['flash_charts'], $data, $width, $height, __("other"), '', $water_mark, $config['fontpath'], $config['font_size'], 1, "hidden", $colors); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 5e5083695e..3f0a60e0b9 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -829,6 +829,56 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle return $output; } +/** + * Render an input password element. + * + * The element will have an id like: "password-$name" + * + * @param mixed parameters: + * - id: string + * - style: string + * - hidden: boolean + * - content: string + * @param bool return or echo flag + * + * @return string HTML code if return parameter is true. + */ +function html_print_div ($options, $return = false) { + $output = ' 'forced_title_' . $options['id'], + 'class' => 'forced_title_layer', + 'content' => $options["title"], + 'hidden' => true); + $output = html_print_div($params, true) . $output; + } + //Valid attributes (invalid attributes get skipped) $attrs = array ("height", "longdesc", "usemap","width","id", - "class","title","lang","xml:lang", "onclick", "ondblclick", + "class","lang","xml:lang", "onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup","pos_tree"); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2e157bae3c..b7abfbda75 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -881,6 +881,7 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') { $data["monitor_bad"] = 0; // Critical + Unknown + Warning $data["monitor_warning"] = 0; $data["monitor_critical"] = 0; + $data["monitor_not_normal"] = 0; $data["monitor_alerts"] = 0; $data["monitor_alerts_fired"] = 0; $data["monitor_alerts_fire_count"] = 0; @@ -1068,6 +1069,8 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') { // Get total count of monitors for this group, except disabled. $data["monitor_checks"] = $data["monitor_not_init"] + $data["monitor_unknown"] + $data["monitor_warning"] + $data["monitor_critical"] + $data["monitor_ok"]; + // Calculate not_normal monitors + $data["monitor_not_normal"] += $data["monitor_checks"] - $data["monitor_ok"]; } // Get total count of monitors for this group, except disabled. @@ -1087,7 +1090,7 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') { } if ($data["monitor_unknown"] > 0 && $data["monitor_checks"] > 0) { - $data["monitor_health"] = format_numeric (100 - ($data["monitor_unknown"] / ($data["monitor_checks"] / 100)), 1); + $data["monitor_health"] = format_numeric (100 - ($data["monitor_not_normal"] / ($data["monitor_checks"] / 100)), 1); } else { $data["monitor_health"] = 100; diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js index 61ae70c464..009c44e883 100644 --- a/pandora_console/include/javascript/jquery.pandora.js +++ b/pandora_console/include/javascript/jquery.pandora.js @@ -174,4 +174,60 @@ $(document).ready (function () { } + // Forced title code + $('IMG.forced_title').hover(function() { + /////////////////////////////////////////// + // Get info of the image + /////////////////////////////////////////// + + var img_top = $(this).offset().top; + var img_width = $(this).width(); + var img_height = $(this).height(); + var img_id = $(this).attr('id'); + var img_left_mid = $(this).offset().left + (img_width / 2); + + /////////////////////////////////////////// + // Put title in the layer + /////////////////////////////////////////// + + var title = $('#forced_title_'+img_id).html(); + $('#forced_title_layer').html(title); + + /////////////////////////////////////////// + // Get info of the layer + /////////////////////////////////////////// + + var layer_width = $('#forced_title_layer').width(); + var layer_height = $('#forced_title_layer').height(); + + /////////////////////////////////////////// + // Obtain the new position of the layer + /////////////////////////////////////////// + + // Jquery doesnt know the padding of the layer + var layer_padding = 4; + + // Deduct padding of both sides + var layer_top = img_top - layer_height - (layer_padding * 2); + if(layer_top < 0) { + layer_top = img_top + img_height + (layer_padding * 2); + } + + // Deduct padding of one side + var layer_left = img_left_mid - (layer_width / 2) - layer_padding; + if(layer_left < 0) { + layer_left = 0; + } + + /////////////////////////////////////////// + // Set the layer position and show + /////////////////////////////////////////// + + $('#forced_title_layer').css('left', layer_left); + $('#forced_title_layer').css('top', layer_top); + $('#forced_title_layer').show(); + }, + function () { + $('#forced_title_layer').hide(); + }); }); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index a86428a583..4dc6b3fd8a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -209,7 +209,7 @@ div#noaccess { padding-left: 40px; } div#activity{ - padding-top: 18px; + padding-top: 0px; padding-bottom: 18px; } div#noa { @@ -1791,3 +1791,34 @@ span#plugin_description { -webkit-border-bottom-right-radius: 10px; border-bottom-right-radius: 10px; } + +/* Images forced title */ + +DIV.forced_title_layer { + display: block; + text-decoration: none; + position: absolute; + z-index: 100; + border: 1px solid #708090; + background-color: #333; + color: #DDD; + padding: 4px; + font-weight: bold; + font-size: small; + + -moz-border-top-right-radius: 5px; + -webkit-border-top-right-radius: 5px; + border-top-right-radius: 5px; + + -moz-border-bottom-right-radius: 5px; + -webkit-border-bottom-right-radius: 5px; + border-bottom-right-radius: 5px; + + -moz-border-top-left-radius: 5px; + -webkit-border-top-left-radius: 5px; + border-top-left-radius: 5px; + + -moz-border-bottom-left-radius: 5px; + -webkit-border-bottom-left-radius: 5px; + border-bottom-left-radius: 5px; +} diff --git a/pandora_console/index.php b/pandora_console/index.php index 2b849b46ac..8805cb78f7 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -553,4 +553,7 @@ echo ''; $run_time = format_numeric (microtime (true) - $config['start_time'], 3); echo "\n\n"; + +// Hidden div to forced title +html_print_div(array('id' => 'forced_title_layer', 'class' => 'forced_title_layer', 'hidden' => true)); ?>