2013-02-26 Sergio Martin <sergio.martin@artica.es>

* 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
This commit is contained in:
zarzuelo 2013-02-26 16:10:02 +00:00
parent 79b5241c32
commit bef2a36c3d
8 changed files with 244 additions and 32 deletions

View File

@ -1,3 +1,17 @@
2013-02-26 Sergio Martin <sergio.martin@artica.es>
* 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 <miguel.dedios@artica.es>
* include/functions_modules.php: fixed in function

View File

@ -37,6 +37,7 @@ if(tags_has_user_acl_tags()) {
// Site news !
// ---------------------------------------------------------------------------
echo '<div>'; // Container top
echo '<div style="width:50%; float:left; padding-right: 30px;" id="leftcolumn">';
switch ($config["dbtype"]) {
@ -79,26 +80,6 @@ echo '</div>';
echo '<div style="width:30%; float:left; padding-left: 30px;" id="rightcolumn">';
$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] ='<b>'.__('Monitor health').'</b>';
$table->data[1][0] =
progress_bar($data["monitor_health"], 280, 20, $data["monitor_health"].'% '.__('of monitors up'), 0);
$table->data[2][0] = '<b>'.__('Module sanity').'</b>';
$table->data[3][0] =
progress_bar($data["module_sanity"], 280, 20, $data["module_sanity"].'% '.__('of total modules inited'), 0);
$table->data[4][0] = '<b>'.__('Alert level').'</b>';
$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&amp;sec2=operation/agentes/sta
$urls['monitor_warning'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=1";
$urls['monitor_ok'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=0";
$urls['monitor_unknown'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=3";
$urls['monitor_not_init'] = "index.php?sec=estado&amp;sec2=operation/agentes/status_monitor&amp;refr=60&amp;status=5";
$urls['monitor_alerts'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;refr=60";
$urls['monitor_alerts_fired'] = "index.php?sec=estado&amp;sec2=operation/agentes/alerts_status&amp;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] = '<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
__('Monitor health') . ui_print_help_tip (sprintf(__('%d Not OK monitors'), $data["monitor_not_normal"]), true) .
'</legend>' .
progress_bar($data["monitor_health"], 280, 20, $data["monitor_health"].'% '.__('of monitors up'), 0) . '</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
__('Module sanity') . ui_print_help_tip (sprintf(__('%d Not inited monitors'), $data["monitor_not_init"]), true) .
'</legend>' .
progress_bar($data["module_sanity"], 280, 20, $data["module_sanity"].'% '.__('of total modules inited'), 0) . '</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox" style="width:97%;">
<legend style="text-align:left; color: #666;">' .
__('Alert level') . ui_print_help_tip (sprintf(__('%d Fired alerts'), $data["monitor_alerts_fired"]), true) .
'</legend>' .
progress_bar($data["alert_level"], 280, 20, $data["alert_level"].'% '.__('of defined alerts not fired'), 0) . '</fieldset>';
$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] = '<div style="margin: auto; width: 250px;">' . graph_agent_status (false, 250, 150, true) . '</div>';
$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] = '<a style="color: ' . COL_NOTINIT . ';" class="big_data" href="' . $urls["monitor_not_init"] . '">' . $tdata[1] . '</a>';
$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] = '<div style="margin: auto; width: 250px;">' . graph_agent_status (false, 250, 150, true, true) . '</div>';
$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] = '<fieldset class="databox" style="width:97%;">
@ -255,9 +282,10 @@ html_print_table($table);
unset($table);
echo "</div>";
echo '<div id="activity" style="width:87%;">';
echo "<br /><br />";
echo "<div style='clear:both'></div>";
echo '</div>'; // Container top
echo '<div id="activity" style="width:87%;">';
// Show last activity from this user
echo "<h4>" . __('This is your last activity in Pandora FMS console') . "</h4>";

View File

@ -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);

View File

@ -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 = '<div';
//Valid attributes (invalid attributes get skipped)
$attrs = array ("id", "style", "class");
if (isset ($options['hidden'])) {
if (isset($options['style'])) {
$options['style'] .= 'display:none;';
}
else {
$options['style'] = 'display:none;';
}
}
foreach ($attrs as $attribute) {
if (isset ($options[$attribute])) {
$output .= ' '.$attribute.'="'.io_safe_input_html ($options[$attribute]).'"';
}
}
$output .= '>';
$output .= isset ($options['content']) ? $options['content'] : '';
$output .= '</div>';
if ($return) {
return $output;
}
else {
echo $output;
}
}
/**
* Render an input password element.
*
@ -1593,9 +1643,29 @@ function html_print_image ($src, $return = false, $options = false, $return_src
$style .= $options["style"];
}
// If title is provided activate forced title
if (isset ($options["title"])) {
if (isset ($options['class'])) {
$options['class'] .= ' forced_title';
}
else {
$options['class'] = 'forced_title';
}
if (!isset ($options['id'])) {
$options['id'] = uniqid();
}
$params = array('id' => '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");

View File

@ -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;

View File

@ -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();
});
});

View File

@ -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;
}

View File

@ -553,4 +553,7 @@ echo '</html>';
$run_time = format_numeric (microtime (true) - $config['start_time'], 3);
echo "\n<!-- Page generated in $run_time seconds -->\n";
// Hidden div to forced title
html_print_div(array('id' => 'forced_title_layer', 'class' => 'forced_title_layer', 'hidden' => true));
?>