2011-04-13 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_graph.php, godmode/db/db_info.php, godmode/db/db_purge.php: added functions "grafico_db_agentes_purge2", "grafico_db_agentes_paquetes2", "graph_db_agentes_modulos2", and changed in the code for this functions. * include/graphs/functions_pchart.php: in function "pch_bar_graph" fixed when pass a empty array as color. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4211 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
67d1b9b750
commit
22c5906961
|
@ -1,3 +1,13 @@
|
|||
2011-04-13 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_graph.php, godmode/db/db_info.php,
|
||||
godmode/db/db_purge.php: added functions "grafico_db_agentes_purge2",
|
||||
"grafico_db_agentes_paquetes2", "graph_db_agentes_modulos2", and changed
|
||||
in the code for this functions.
|
||||
|
||||
* include/graphs/functions_pchart.php: in function "pch_bar_graph" fixed
|
||||
when pass a empty array as color.
|
||||
|
||||
2011-04-13 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* operation/servers/view_server_detail.php,
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
// Load global vars
|
||||
global $config;
|
||||
|
||||
require_once ($config["homedir"] . '/include/functions_graph.php');
|
||||
|
||||
if ($config['flash_charts']) {
|
||||
require('include/fgraph.php');
|
||||
}
|
||||
|
@ -42,34 +44,21 @@ if (! check_acl ($config['id_user'], 0, "DM")) {
|
|||
- A more powerful selection (by Agent, by Module, etc).
|
||||
*/
|
||||
|
||||
|
||||
if ($config['flash_charts']) {
|
||||
$id_agente=0;
|
||||
$width=600;
|
||||
$height=400;
|
||||
echo grafico_db_agentes_purge ($id_agente, $width, $height);
|
||||
} else {
|
||||
echo '<img src="include/fgraph.php?tipo=db_agente_purge&id=-1&height=400&width=600">';
|
||||
}
|
||||
|
||||
echo grafico_db_agentes_purge2(0, 600, 400);
|
||||
|
||||
echo '<div id="db_info_graph">';
|
||||
echo '<table border=0>';
|
||||
echo '<tr><td>';
|
||||
echo '<h3>'.__('Modules per agent').'</h3>';
|
||||
if ($config['flash_charts']) {
|
||||
echo graph_db_agentes_modulos ($width, $height);
|
||||
} else {
|
||||
echo '<img src="include/fgraph.php?tipo=db_agente_modulo&width=600&height=200"><br />';
|
||||
}
|
||||
|
||||
echo graph_db_agentes_modulos2(600, 250);
|
||||
|
||||
echo '</td></tr><tr><td><br /></tr></td>';
|
||||
echo '<tr><td>';
|
||||
echo '<h3>'.__('Packets per agent').'</h3>';
|
||||
if ($config['flash_charts']) {
|
||||
echo grafico_db_agentes_paquetes ($width, $height);
|
||||
} else {
|
||||
echo '<img src="include/fgraph.php?tipo=db_agente_paquetes&width=600&height=200"><br />';
|
||||
}
|
||||
|
||||
echo grafico_db_agentes_paquetes2(700, 300);
|
||||
|
||||
echo '</table>';
|
||||
echo '<a href="#" onClick="toggleDiv(\'db_info_data\'); toggleDiv(\'db_info_graph\'); return false;"><b>'.__('Press here to get database information as text').'</b> ' . print_image("images/down.png", true, array("alt" => "down", "title" => "down")) . '</a></div>';
|
||||
echo '<div id="db_info_data" style="display:none">';
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
// Load global vars
|
||||
global $config;
|
||||
|
||||
require_once ($config["homedir"] . '/include/functions_graph.php');
|
||||
|
||||
if ($config['flash_charts']) {
|
||||
require('include/fgraph.php');
|
||||
}
|
||||
|
@ -36,11 +38,8 @@ $id_agent = (int) get_parameter_post ("agent", -1);
|
|||
|
||||
print_page_header (__('Database maintenance').' » '.__('Database purge'), "images/god8.png", false, "", true);
|
||||
|
||||
if ($config['flash_charts']) {
|
||||
echo grafico_db_agentes_purge ($id_agent, $width, $height);
|
||||
} else {
|
||||
echo '<img src="include/fgraph.php?tipo=db_agente_purge&id='.$id_agent.'" />';
|
||||
}
|
||||
echo grafico_db_agentes_purge2($id_agent);
|
||||
|
||||
echo '<br /><br />';
|
||||
echo '<h3>'.__('Get data from agent').'</h3>';
|
||||
|
||||
|
|
|
@ -746,4 +746,161 @@ function graph_sla_slicebar ($id, $period, $sla_min, $sla_max, $daysWeek, $time_
|
|||
|
||||
return slicesbar_graph($data, $width, $height, $colors, $config['fontpath'], $config['round_corner']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_purge2 ($id_agent, $width, $height) {
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
if ($id_agent < 1) {
|
||||
$id_agent = -1;
|
||||
$query = "";
|
||||
} else {
|
||||
$modules = get_agent_modules ($id_agent);
|
||||
$query = sprintf (" AND id_agente_modulo IN (%s)", implode (",", array_keys ($modules)));
|
||||
}
|
||||
|
||||
// All data (now)
|
||||
$time["all"] = get_system_time ();
|
||||
|
||||
// 1 day ago
|
||||
$time["1day"] = $time["all"] - 86400;
|
||||
|
||||
// 1 week ago
|
||||
$time["1week"] = $time["all"] - 604800;
|
||||
|
||||
// 1 month ago
|
||||
$time["1month"] = $time["all"] - 2592000;
|
||||
|
||||
// Three months ago
|
||||
$time["3month"] = $time["all"] - 7776000;
|
||||
|
||||
$data[__("Today")] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query), 0, true);
|
||||
$data["1 ".__("Week")] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query), 0, true);
|
||||
$data["1 ".__("Month")] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query), 0, true);
|
||||
$data["3 ".__("Months")] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query), 0, true);
|
||||
$data[__("Older")] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
|
||||
$data[__("Today")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1day"], $query), 0, true);
|
||||
$data["1 ".__("Week")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1week"], $query), 0, true);
|
||||
$data["1 ".__("Month")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1month"], $query), 0, true);
|
||||
$data["3 ".__("Months")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query), 0, true);
|
||||
$data[__("Older")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE 1=1 %s", $query), 0, true);
|
||||
|
||||
$data[__("Today")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["1day"], $query), 0, true);
|
||||
$data["1 ".__("Week")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["1week"], $query), 0, true);
|
||||
$data["1 ".__("Month")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["1month"], $query), 0, true);
|
||||
$data["3 ".__("Months")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE utimestamp > %d %s", $time["3month"], $query), 0, true);
|
||||
$data[__("Older")] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_log4x WHERE 1=1 %s", $query), 0, true);
|
||||
|
||||
$data[__("Older")] = $data[__("Older")] - $data["3 ".__("Months")];
|
||||
|
||||
|
||||
return pie3d_graph($config['flash_charts'], $data, $width, $height);
|
||||
|
||||
////////////////////////
|
||||
|
||||
if (! $graphic_type) {
|
||||
return fs_3d_pie_chart ($data, $width, $height);
|
||||
}
|
||||
|
||||
generic_pie_graph ($width, $height, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a horizontal bar graph with packets data of agents
|
||||
*
|
||||
* @param integer width pie graph width
|
||||
* @param integer height pie graph height
|
||||
*/
|
||||
function grafico_db_agentes_paquetes2($width = 380, $height = 300) {
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$data = array ();
|
||||
$legend = array ();
|
||||
|
||||
$agents = get_group_agents (array_keys (get_user_groups ()), false, "none");
|
||||
$count = get_agent_modules_data_count (array_keys ($agents));
|
||||
unset ($count["total"]);
|
||||
arsort ($count, SORT_NUMERIC);
|
||||
$count = array_slice ($count, 0, 8, true);
|
||||
|
||||
foreach ($count as $agent_id => $value) {
|
||||
$data[$agents[$agent_id]]['g'] = $value;
|
||||
}
|
||||
|
||||
return hbar_graph($config['flash_charts'], $data, $width, $height, array(), $legend);
|
||||
|
||||
/////////////////////////////////////
|
||||
|
||||
if (! $graphic_type) {
|
||||
return fs_3d_bar_chart ($data, $width, $height);
|
||||
}
|
||||
|
||||
generic_horizontal_bar_graph ($width, $height, $data, $legend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a horizontal bar graph with modules data of agents
|
||||
*
|
||||
* @param integer height graph height
|
||||
* @param integer width graph width
|
||||
*/
|
||||
function graph_db_agentes_modulos2($width, $height) {
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$data = array ();
|
||||
|
||||
switch ($config['dbtype']){
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente
|
||||
FROM tagente_modulo
|
||||
GROUP BY id_agente
|
||||
ORDER BY 1 DESC LIMIT 10');
|
||||
break;
|
||||
case "oracle":
|
||||
$modules = get_db_all_rows_sql ('SELECT COUNT(id_agente_modulo), id_agente
|
||||
FROM tagente_modulo
|
||||
WHERE rownum <= 10
|
||||
GROUP BY id_agente
|
||||
ORDER BY 1 DESC');
|
||||
break;
|
||||
}
|
||||
if ($modules === false)
|
||||
$modules = array ();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$agent_name = get_agent_name ($module['id_agente'], "none");
|
||||
switch ($config['dbtype']){
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$data[$agent_name]['g'] = $module['COUNT(id_agente_modulo)'];
|
||||
break;
|
||||
case "oracle":
|
||||
$data[$agent_name]['g'] = $module['count(id_agente_modulo)'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return hbar_graph($config['flash_charts'], $data, $width, $height);
|
||||
|
||||
/////////////////////////////////////
|
||||
|
||||
if (! $graphic_type) {
|
||||
return fs_3d_bar_chart ($data, $width, $height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
generic_horizontal_bar_graph ($width, $height, $data);
|
||||
}
|
||||
?>
|
|
@ -398,7 +398,8 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $rgb_color
|
|||
$overridePalette = array();
|
||||
foreach($data as $i => $values) {
|
||||
$MyData->addPoints($values,$i);
|
||||
if($rgb_color !== false) {
|
||||
|
||||
if(!empty($rgb_color)) {
|
||||
$MyData->setPalette($i,
|
||||
array("R" => $rgb_color[$i]['color']["R"],
|
||||
"G" => $rgb_color[$i]['color']["G"],
|
||||
|
|
Loading…
Reference in New Issue