2009-01-09 Evi Vanoost <vanooste@rcbi.rochester.edu>
* general/footer.php, operation/agentes/sla_view.php, operation/agentes/estado_ultimopaquete.php: Replaced time function with get_system_time * operation/reporting/reporting_viewer.php, operation/reporting/reporting_xml.php, reporting/stat_win.php, godmode/agentes/configurar_agente.php: Function renaming * include/functions_reporting.php, include/functions_db.php, operation/agentes/exportdata.php, operation/agentes/estado_generalagente.php, reporting/fgraph.php, godmode/db/db_info.php, godmode/db/db_purge.php, godmode/agentes/modificar_agente.php: Made tagente_datos.id_agente redundant by using the internal functions and separate queries. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1324 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c385a6b0cc
commit
1493bb66cd
|
@ -1,3 +1,20 @@
|
|||
2009-01-09 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* general/footer.php, operation/agentes/sla_view.php,
|
||||
operation/agentes/estado_ultimopaquete.php: Replaced time
|
||||
function with get_system_time
|
||||
|
||||
* operation/reporting/reporting_viewer.php,
|
||||
operation/reporting/reporting_xml.php, reporting/stat_win.php,
|
||||
godmode/agentes/configurar_agente.php: Function renaming
|
||||
|
||||
* include/functions_reporting.php, include/functions_db.php,
|
||||
operation/agentes/exportdata.php,
|
||||
operation/agentes/estado_generalagente.php, reporting/fgraph.php,
|
||||
godmode/db/db_info.php, godmode/db/db_purge.php,
|
||||
godmode/agentes/modificar_agente.php: Made tagente_datos.id_agente
|
||||
redundant by using the internal functions and separate queries.
|
||||
|
||||
2009-01-08 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* general/footer.php: Made image link relative. It wasn't working for me.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
if (isset($_SERVER['REQUEST_TIME'])) {
|
||||
$time = $_SERVER['REQUEST_TIME'];
|
||||
} else {
|
||||
$time = time();
|
||||
$time = get_system_time ();
|
||||
}
|
||||
|
||||
echo '<a class="white_bold" target="_new" href="general/license/pandora_info_'.$config["language"].'.html">Pandora FMS '.$pandora_version.' - Build '.$build_version.'<br>';
|
||||
|
|
|
@ -252,7 +252,7 @@ if (isset ($_POST["create_agent"])) {
|
|||
if (isset($_GET["fix_module"])){
|
||||
$id_module = get_parameter_get ("fix_module",0);
|
||||
// get info about this module
|
||||
$media = get_agent_module_value_average ($id_module, 30758400); //Get average over the year
|
||||
$media = get_agentmodule_data_average ($id_module, 30758400); //Get average over the year
|
||||
$media *= 1.3;
|
||||
$error = "";
|
||||
//If the value of media is 0 or something went wrong, don't delete
|
||||
|
|
|
@ -39,6 +39,7 @@ if (isset ($_GET["borrar_agente"])) { // if delete agent
|
|||
$id_agente = get_parameter_get ("borrar_agente");
|
||||
$agent_name = get_agent_name ($id_agente);
|
||||
$id_grupo = dame_id_grupo ($id_agente);
|
||||
$modules = array_keys (get_agent_modules ($id_agente));
|
||||
if (give_acl ($config["id_user"], $id_grupo, "AW")==1) {
|
||||
//Start transaction - this improves consistency
|
||||
process_sql ("SET AUTOCOMMIT=0;");
|
||||
|
@ -55,29 +56,28 @@ if (isset ($_GET["borrar_agente"])) { // if delete agent
|
|||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
|
||||
// Delete tagente_datos data
|
||||
$sql_delete = "DELETE FROM tagente_datos WHERE id_agente = ".$id_agente;
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
if (!empty ($modules) {
|
||||
// Delete tagente_datos data
|
||||
$sql_delete = "DELETE FROM tagente_datos WHERE id_agente_modulo IN (".implode (",",$modules).")";
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
|
||||
// Delete tagente_datos_string data
|
||||
$sql_delete = "DELETE FROM tagente_datos_string WHERE id_agente = ".$id_agente;
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
// Delete tagente_datos_string data
|
||||
$sql_delete = "DELETE FROM tagente_datos_string WHERE id_agente_modulo IN (".implode (",",$modules).")";
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
|
||||
// Delete from tagente_datos - relies on id_agente_modulo
|
||||
$sql_delete = "DELETE FROM tagente_datos_inc WHERE
|
||||
id_agente_modulo = ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agente.")";
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
|
||||
// Delete alerts from talerta_agente_modulo - relies on
|
||||
// id_agente_modulo
|
||||
$sql_delete = "DELETE FROM talerta_agente_modulo WHERE
|
||||
id_agente_modulo = ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agente.")";
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
// Delete from tagente_datos - relies on id_agente_modulo
|
||||
$sql_delete = "DELETE FROM tagente_datos_inc WHERE id_agente_modulo IN (".implode (",",$modules).")";
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
|
||||
// Delete alerts from talerta_agente_modulo - relies on
|
||||
// id_agente_modulo
|
||||
$sql_delete = "DELETE FROM talerta_agente_modulo WHERE id_agente_modulo IN (".implode (",",$modules).")";
|
||||
if (process_sql ($sql_delete) === false)
|
||||
$del_error++;
|
||||
}
|
||||
// Delete from tagente_modulo
|
||||
$sql_delete ="DELETE FROM tagente_modulo WHERE id_agente = ".$id_agente;
|
||||
if (process_sql ($sql_delete) === false)
|
||||
|
|
|
@ -53,6 +53,7 @@ echo '<img src="reporting/fgraph.php?tipo=db_agente_paquetes&width=600&height=20
|
|||
echo '</table>';
|
||||
echo '<a href="#" onClick="toggleDiv(\'db_info_data\'); toggleDiv(\'db_info_graph\'); return false;">'.__('Press here to get database information as text').'</a></div>';
|
||||
echo '<div id="db_info_data" style="display:none">';
|
||||
|
||||
//Merged from db_info_data.php because the queries are the same, so the cache
|
||||
//will kick in.
|
||||
|
||||
|
@ -62,30 +63,23 @@ $table->head[0] = __('Agent name');
|
|||
$table->head[1] = __('Assigned modules');
|
||||
$table->head[2] = __('Total data');
|
||||
|
||||
$sql = "SELECT DISTINCT(id_agente), COUNT(id_agente_datos) AS count FROM tagente_datos GROUP BY id_agente ORDER BY count ASC";
|
||||
$agents = get_group_agents (1);
|
||||
|
||||
// Not implemented yet
|
||||
//$sql2 = "SELECT DISTINCT(id_agente), COUNT(id_agente_datos_string) AS count FROM tagente_datos_string GROUP BY id_agente ORDER BY count ASC";
|
||||
$count = get_agent_modules_data_count (array_keys ($agents));
|
||||
|
||||
//This query takes 1s on a 1 million entry database. Merging it with tagente
|
||||
//costs 7 seconds so we rely on the functions to return information on
|
||||
//id_agente.
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
if ($result === false) {
|
||||
$result = array();
|
||||
}
|
||||
unset ($count["total"]); //Not interested in total
|
||||
asort ($count, SORT_NUMERIC);
|
||||
|
||||
foreach ($result as $row) {
|
||||
foreach ($count as $agent_id => $value) {
|
||||
$data = array ();
|
||||
|
||||
//First row is a link to the agent
|
||||
$data[0] = '<strong><a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.
|
||||
$row["id_agente"].'">'.get_agent_name ($row["id_agente"]).'</a></strong>';
|
||||
$data[0] = '<strong><a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$agent_id.'">'.$agents[$agent_id].'</a></strong>';
|
||||
//Second row is a number of modules for the agent
|
||||
$data[1] = get_agent_modules_count ($row["id_agente"]);
|
||||
$data[1] = get_agent_modules_count ($agent_id);
|
||||
//Then the number of data packets for the agent
|
||||
$data[2] = $row["count"];
|
||||
|
||||
$data[2] = $value;
|
||||
|
||||
array_unshift ($table->data, $data);
|
||||
}
|
||||
print_table ($table);
|
||||
|
|
|
@ -159,29 +159,29 @@ if ($id_agent > 0) { //If the agent is not All or Not selected
|
|||
$query = "";
|
||||
}
|
||||
|
||||
$data["1day"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
$data["1day"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
|
||||
$data["1day"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += get_db_sql (sprintf ("SELECT COUNT(id_adi) FROM tagente_datos_inc WHERE 1=1 %s", $query));
|
||||
$data["1day"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_inc WHERE 1=1 %s", $query));
|
||||
|
||||
$data["1day"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE 1=1 %s", $query));
|
||||
$data["1day"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data["3day"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3day"], $query));
|
||||
$data["1week"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data["2week"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["2week"], $query));
|
||||
$data["1month"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data["3month"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data["total"] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE 1=1 %s", $query));
|
||||
|
||||
|
||||
if (isset ($table)) {
|
||||
|
|
|
@ -190,9 +190,9 @@ function give_disabled_group ($id_group) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all the agents within a group(s).
|
||||
* Get all the agents within a group(s). For non-godmode usage get_user_groups should be used.
|
||||
*
|
||||
* @param mixed $id_group Group id or an array of ID's
|
||||
* @param mixed $id_group Group id or an array of ID's. If nothing is selected, it will select all
|
||||
*
|
||||
* @param bool $disabled Add disabled agents to agents. Default: False.
|
||||
*
|
||||
|
@ -200,16 +200,16 @@ function give_disabled_group ($id_group) {
|
|||
*
|
||||
* @return array An array with all agents in the group or an empty array
|
||||
*/
|
||||
function get_group_agents ($id_group, $disabled = false, $case = "lower") {
|
||||
$id_group = (array) safe_int ($id_group, 1);
|
||||
function get_group_agents ($id_group = 0, $disabled = false, $case = "lower") {
|
||||
$id_group = safe_int ($id_group, 1);
|
||||
|
||||
//If id_group is an array, then
|
||||
if (in_array (1, $id_group)) {
|
||||
if (empty ($id_group) || in_array (1, (array) $id_group)) {
|
||||
//If All is included in the group list, just select All
|
||||
$id_group = 1;
|
||||
} else {
|
||||
//If All is not included, select what we need
|
||||
$id_group = implode (",", $id_group);
|
||||
$id_group = implode (",", (array) $id_group);
|
||||
}
|
||||
|
||||
/* 'All' group must return all agents */
|
||||
|
@ -244,9 +244,9 @@ function get_group_agents ($id_group, $disabled = false, $case = "lower") {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all the modules in an agent.
|
||||
* Get all the modules in an agent. If an empty list is passed it will select all
|
||||
*
|
||||
* @param int $id_agent Agent id
|
||||
* @param mixed $id_agent Agent id. If empty it selects all, array or int can be passed too
|
||||
* @param mixed $details Array, comma delimited list or singular value of rows to select. If nothing is specified, nombre will be selected
|
||||
*
|
||||
* @return array An array with all modules in the agent. If multiple rows are selected, they will be in an array
|
||||
|
@ -256,10 +256,8 @@ function get_agent_modules ($id_agent, $details = false) {
|
|||
|
||||
if (empty ($id_agent)) {
|
||||
$filter = '';
|
||||
} elseif (is_array ($id_agent)) {
|
||||
$filter = sprintf (' WHERE id_agente IN (%s)', implode (",",$id_agent));
|
||||
} else {
|
||||
$filter = sprintf (' WHERE id_agente = %d', $id_agent);
|
||||
$filter = sprintf (' WHERE id_agente IN (%s)', implode (",", (array) $id_agent));
|
||||
}
|
||||
|
||||
if (empty ($details)) {
|
||||
|
@ -822,34 +820,54 @@ function dame_id_grupo ($id_agent) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the number of pandora data in the database.
|
||||
*
|
||||
* @param int $id_agent Agent id or 0 for all
|
||||
* Get the number of pandora data packets in the database.
|
||||
*
|
||||
* @return int The number of data in the database
|
||||
* In case an array is passed, it will have a value for every agent passed
|
||||
* incl. a total otherwise it will just return the total
|
||||
*
|
||||
* @param mixed $id_agent Agent id or array of agent id's, 0 for all
|
||||
*
|
||||
* @return mixed The number of data in the database
|
||||
*/
|
||||
function dame_numero_datos ($id_agent = 0) {
|
||||
if ($id_agent < 1) {
|
||||
$query = '';
|
||||
function get_agent_modules_data_count ($id_agent = 0) {
|
||||
$id_agent = safe_int ($id_agent, 1);
|
||||
|
||||
if (empty ($id_agent)) {
|
||||
$id_agent = array ();
|
||||
} else {
|
||||
$query = sprintf (" WHERE id_agente_modulo = ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = %d)", $id_agent);
|
||||
$id_agent = (array) $id_agent;
|
||||
}
|
||||
$datos = 0;
|
||||
$datos += (int) get_db_sql ("SELECT COUNT(*) FROM tagente_datos".$query);
|
||||
$datos += (int) get_db_sql ("SELECT COUNT(*) FROM tagente_datos_inc".$query);
|
||||
$datos += (int) get_db_sql ("SELECT COUNT(*) FROM tagente_datos_string".$query);
|
||||
return $datos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data value of a agent module of string type.
|
||||
*
|
||||
* @param int $id Agent module string id
|
||||
*
|
||||
* @return string Data value of the agent module.
|
||||
*/
|
||||
function dame_generic_string_data ($id) {
|
||||
return (string) get_db_value ('datos', 'tagente_datos_string', 'id_tagente_datos_string', $id);
|
||||
|
||||
$count = array ();
|
||||
$count["total"] = 0;
|
||||
|
||||
$query[0] = "SELECT COUNT(*) FROM tagente_datos";
|
||||
//$query[1] = "SELECT COUNT(*) FROM tagente_datos_inc";
|
||||
//$query[2] = "SELECT COUNT(*) FROM tagente_datos_string";
|
||||
|
||||
foreach ($id_agent as $agent_id) {
|
||||
//Init value
|
||||
$count[$agent_id] = 0;
|
||||
$modules = array_keys (get_agent_modules ($agent_id));
|
||||
foreach ($query as $sql) {
|
||||
//Add up each table's data
|
||||
$count[$agent_id] += (int) get_db_sql ($sql." WHERE id_agente_modulo IN (".implode (",", $modules).")");
|
||||
}
|
||||
//Add total agent count to total count
|
||||
$count["total"] += $count[$agent_id];
|
||||
}
|
||||
|
||||
if ($count["total"] == 0) {
|
||||
foreach ($query as $sql) {
|
||||
$count["total"] += (int) get_db_sql ($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset ($agent_id)) {
|
||||
//If agent_id is not set, it didn't loop through any agents
|
||||
return $count["total"];
|
||||
}
|
||||
return $count; //Return the array
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1648,7 +1666,7 @@ function get_previous_data ($id_agent_module, $utimestamp) {
|
|||
*
|
||||
* @return int The average module value in the interval.
|
||||
*/
|
||||
function get_agent_module_value_average ($id_agent_module, $period, $date = 0) {
|
||||
function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
||||
if (! $date)
|
||||
$date = get_system_time ();
|
||||
$datelimit = $date - $period;
|
||||
|
@ -1680,7 +1698,7 @@ function get_agent_module_value_average ($id_agent_module, $period, $date = 0) {
|
|||
*
|
||||
* @return int The maximum module value in the interval.
|
||||
*/
|
||||
function get_agent_module_value_max ($id_agent_module, $period, $date = 0) {
|
||||
function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
||||
if (! $date)
|
||||
$date = get_system_time ();
|
||||
$datelimit = $date - $period;
|
||||
|
@ -1708,7 +1726,7 @@ function get_agent_module_value_max ($id_agent_module, $period, $date = 0) {
|
|||
*
|
||||
* @return int The minimum module value of the module
|
||||
*/
|
||||
function get_agent_module_value_min ($id_agent_module, $period, $date = 0) {
|
||||
function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
|
||||
if (! $date)
|
||||
$date = get_system_time ();
|
||||
$datelimit = $date - $period;
|
||||
|
@ -1727,7 +1745,7 @@ function get_agent_module_value_min ($id_agent_module, $period, $date = 0) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the sumatory of values of an agent module in a period of time.
|
||||
* Get the sum of values of an agent module in a period of time.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id to get the sumatory.
|
||||
* @param int $period Period of time to check (in seconds)
|
||||
|
@ -1735,7 +1753,7 @@ function get_agent_module_value_min ($id_agent_module, $period, $date = 0) {
|
|||
*
|
||||
* @return int The sumatory of the module values in the interval.
|
||||
*/
|
||||
function get_agent_module_value_sumatory ($id_agent_module, $period, $date = 0) {
|
||||
function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
||||
if (! $date)
|
||||
$date = get_system_time ();
|
||||
$datelimit = $date - $period; // limit date
|
||||
|
@ -2167,11 +2185,11 @@ function get_server_info ($id_server = -1) {
|
|||
*/
|
||||
function get_agent_modules_count ($id_agent = 0) {
|
||||
$id_agent = safe_int ($id_agent, 1); //Make sure we're all int's and filter out bad stuff
|
||||
|
||||
if (empty ($id_agent)) {
|
||||
//If the array proved empty or the agent is less than 1 (eg. -1)
|
||||
$filter = '';
|
||||
} else {
|
||||
$filter = sprintf (" WHERE id_agente IN (%s)", implode (",",$id_agent));
|
||||
$filter = sprintf (" WHERE id_agente IN (%s)", implode (",", (array) $id_agent));
|
||||
}
|
||||
|
||||
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo".$filter);
|
||||
|
@ -2222,10 +2240,12 @@ function process_alerts_validate ($id_alert) {
|
|||
global $config;
|
||||
require_once ("include/functions_events.php");
|
||||
|
||||
$id_alert = (array) safe_int ($id_alert, 1);
|
||||
$id_alert = safe_int ($id_alert, 1);
|
||||
|
||||
if (empty ($id_alert)) {
|
||||
return false;
|
||||
} else {
|
||||
$id_alert = (array) $id_alert;
|
||||
}
|
||||
|
||||
foreach ($id_alert as $id_aam) {
|
||||
|
|
|
@ -37,27 +37,22 @@ function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value
|
|||
|
||||
$datelimit = $date - $period; // start date
|
||||
|
||||
$id_agent = get_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', (int) $id_agent_module);
|
||||
if (empty ($id_agent))
|
||||
return 0;
|
||||
//No agent connected to this module. Something bad in the database
|
||||
|
||||
/* Get all the data in the interval */
|
||||
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_datos
|
||||
WHERE id_agente = %d AND id_agente_modulo = %d
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$id_agent, $id_agent_module, $datelimit, $date);
|
||||
$id_agent_module, $datelimit, $date);
|
||||
$datas = get_db_all_rows_sql ($sql);
|
||||
if ($datas === false) {
|
||||
|
||||
/* Try to get data from tagente_estado. It may found nothing because of
|
||||
data compression */
|
||||
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_estado
|
||||
WHERE id_agente = %d AND id_agente_modulo = %d
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp > %d AND utimestamp <= %d
|
||||
ORDER BY utimestamp ASC',
|
||||
$id_agent, $id_agent_module, $datelimit, $date);
|
||||
$id_agent_module, $datelimit, $date);
|
||||
$data = get_db_sql ($sql);
|
||||
|
||||
if ($data === false) {
|
||||
|
|
|
@ -46,7 +46,7 @@ echo '<div style="height: 10px"> </div>';
|
|||
//Floating div
|
||||
echo '<div style="float:right; width:300px; padding-top:16px;">';
|
||||
echo '<b>'.__('Agent access rate (24h)').'</b><br /><br />';
|
||||
echo '<img border="1" src="reporting/fgraph.php?id='.$id_agente.'&tipo=agentaccess&periodo=1440&height=70&width=280" />';
|
||||
echo '<img border="1" src="reporting/fgraph.php?id='.$id_agente.'&tipo=agentaccess&periodo=86400&height=70&width=280" />';
|
||||
echo '<div style="height:25px"> </div>';
|
||||
echo '<b>'.__('Events generated -by module-').'</b><br /><br />';
|
||||
echo '<img border="1" src="reporting/fgraph.php?tipo=event_module&width=250&height=180&id_agent='.$id_agente.'" />';
|
||||
|
@ -94,7 +94,7 @@ echo '<td class="datos2" colspan="2">'.$agent["agent_version"].'</td></tr>';
|
|||
|
||||
// Total packets
|
||||
echo '<tr><td class="datos"><b>'. __('Total packets'). '</b></td>';
|
||||
echo '<td class="datos" colspan=2>'.dame_numero_datos ($id_agente).'</td></tr>';
|
||||
echo '<td class="datos" colspan=2>'.get_agent_modules_data_count ($id_agente).'</td></tr>';
|
||||
|
||||
// Last contact
|
||||
echo '<tr><td class="datos2"><b>'.__('Last contact')." / ".__('Remote').'</b></td><td class="datos2 f9" colspan="2">';
|
||||
|
|
|
@ -191,7 +191,7 @@ if (mysql_num_rows ($result3)) {
|
|||
if ($row3["timestamp"] == "0000-00-00 00:00:00"){
|
||||
echo __('Never');
|
||||
} else {
|
||||
$ahora = time();
|
||||
$ahora = get_system_time ();
|
||||
// Async modules
|
||||
if (($row3["id_tipo_modulo"] > 20) AND ($row3["id_tipo_modulo"] < 100)){
|
||||
echo human_time_comparation($row3["timestamp"]);
|
||||
|
|
|
@ -178,15 +178,14 @@ if ((isset($_POST["export"])) AND (! isset($_POST["update_agent"]))){
|
|||
// Begin the render !
|
||||
for ($a=0; $a <count($origen_modulo); $a++){ // For each module (not used multiple modules yet!)
|
||||
$id_modulo = $origen_modulo[$a];
|
||||
$sql1='SELECT * FROM tdatos WHERE id_agente = '.$origen;
|
||||
$tipo = get_moduletype_name (get_agentmodule_type ($id_modulo));
|
||||
if ($tipo == "generic_data_string")
|
||||
$sql1 = 'SELECT * FROM tagente_datos_string WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_modulo.' ORDER BY timestamp DESC';
|
||||
else
|
||||
$sql1 = 'SELECT * FROM tagente_datos WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_modulo.' ORDER BY timestamp DESC';
|
||||
$result1 = mysql_query ($sql1);
|
||||
$result1 = get_db_all_rows_sql ($sql1);
|
||||
$color=1;
|
||||
while ($row = mysql_fetch_array ($result1)){
|
||||
foreach ($result1 as $row){
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
|
|
|
@ -74,7 +74,7 @@ if (mysql_num_rows ($result_t)) {
|
|||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
$seconds = time() - $module_data["utimestamp"];
|
||||
$seconds = get_system_time () - $module_data["utimestamp"];
|
||||
if ($seconds >= ($temp_interval*2)) // If every interval x 2 secs. we get nothing, there's and alert
|
||||
$agent_down = 1;
|
||||
else
|
||||
|
|
|
@ -309,7 +309,7 @@ foreach ($contents as $content) {
|
|||
|
||||
$data = array ();
|
||||
$table->colspan[1][0] = 2;
|
||||
$value = format_numeric (get_agent_module_value_average ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$value = format_numeric (get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
|
@ -324,7 +324,7 @@ foreach ($contents as $content) {
|
|||
|
||||
$data = array ();
|
||||
$table->colspan[1][0] = 2;
|
||||
$value = format_numeric (get_agent_module_value_max ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$value = format_numeric (get_agentmodule_data_max ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
|
@ -339,7 +339,7 @@ foreach ($contents as $content) {
|
|||
|
||||
$data = array ();
|
||||
$table->colspan[1][0] = 2;
|
||||
$value = format_numeric (get_agent_module_value_min ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$value = format_numeric (get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
|
@ -354,7 +354,7 @@ foreach ($contents as $content) {
|
|||
|
||||
$data = array ();
|
||||
$table->colspan[1][0] = 2;
|
||||
$value = format_numeric (get_agent_module_value_sumatory ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$value = format_numeric (get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
|
|
|
@ -245,22 +245,22 @@ foreach ($contents as $content) {
|
|||
case 7:
|
||||
case 'avg_value':
|
||||
$data["title"] = __('Avg. Value');
|
||||
$data["objdata"] = format_numeric (get_agent_module_value_average ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data["objdata"] = format_numeric (get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $datetime));
|
||||
break;
|
||||
case 8:
|
||||
case 'max_value':
|
||||
$data["title"] = __('Max. Value');
|
||||
$data["objdata"] = format_numeric (get_agent_module_value_max ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data["objdata"] = format_numeric (get_agentmodule_data_max ($content['id_agent_module'], $content['period'], $datetime));
|
||||
break;
|
||||
case 9:
|
||||
case 'min_value':
|
||||
$data["title"] = __('Min. Value');
|
||||
$data["objdata"] = format_numeric (get_agent_module_value_min ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data["objdata"] = format_numeric (get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $datetime));
|
||||
break;
|
||||
case 10:
|
||||
case 'sumatory':
|
||||
$data["title"] = __('Sumatory');
|
||||
$data["objdata"] = format_numeric (get_agent_module_value_sumatory ($content['id_agent_module'], $content['period'], $datetime));
|
||||
$data["objdata"] = format_numeric (get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $datetime));
|
||||
break;
|
||||
case 11:
|
||||
case 'general_group_report':
|
||||
|
|
|
@ -47,18 +47,6 @@ function graphic_error () {
|
|||
imagePng($imgPng);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a MySQL timestamp date, formatted with actual date MINUS X minutes,
|
||||
*
|
||||
* @param int Date in unix format (timestamp)
|
||||
*
|
||||
* @return string Formatted date string (YY-MM-DD hh:mm:ss)
|
||||
*/
|
||||
function dame_fecha ($mh) {
|
||||
$mh *= 60;
|
||||
return date ("Y-m-d H:i:00", time() - $mh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a short timestamp data, D/M h:m
|
||||
*
|
||||
|
@ -166,17 +154,14 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
|
|||
}
|
||||
$previous=0;
|
||||
// Get the first data outsite (to the left---more old) of the interval given
|
||||
$sql = "SELECT datos, utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope AND utimestamp >= $date ORDER BY utimestamp DESC LIMIT 1";
|
||||
if ($result = mysql_query($sql)) {
|
||||
$row = mysql_fetch_array($result);
|
||||
$previous = $row[0];
|
||||
}
|
||||
$sql = "SELECT datos FROM tagente_datos WHERE id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope AND utimestamp >= $date ORDER BY utimestamp DESC";
|
||||
$previous = (float) get_db_sql ($sql);
|
||||
|
||||
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp >= $fechatope AND utimestamp < $date";
|
||||
if ($result = mysql_query($sql1))
|
||||
while ($row = mysql_fetch_array ($result)) {
|
||||
$datos = $row[0];
|
||||
$utimestamp = $row[1];
|
||||
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente_modulo = $id_agente_modulo AND utimestamp >= $fechatope AND utimestamp < $date";
|
||||
$result = (array) get_db_all_rows_sql ($sql);
|
||||
foreach ($result as $row) {
|
||||
$datos = $row["datos"];
|
||||
$utimestamp = $row["utimestamp"];
|
||||
for ($j = 0; $j <= $resolution; $j++) {
|
||||
if ($utimestamp <= $valores[$j][3] && $utimestamp > $valores[$j][2]) {
|
||||
$valores[$j][0]=$valores[$j][0]+$datos;
|
||||
|
@ -473,22 +458,21 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
|
|||
$min_value = 0;
|
||||
|
||||
// Get the first data outsite (to the left---more old) of the interval given
|
||||
$sql = sprintf ('SELECT datos, utimestamp FROM tagente_datos
|
||||
WHERE id_agente = %d AND id_agente_modulo = %d
|
||||
AND utimestamp < %d ORDER BY utimestamp DESC LIMIT 1', $id_agente, $id_agente_modulo, $fechatope);
|
||||
$sql = sprintf ('SELECT datos FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
AND utimestamp < %d ORDER BY utimestamp DESC', $id_agente_modulo, $fechatope);
|
||||
$previous = (float) get_db_sql ($sql);
|
||||
|
||||
$sql = sprintf ('SELECT datos,utimestamp FROM tagente_datos
|
||||
WHERE id_agente = %d AND id_agente_modulo = %d AND utimestamp > %d',
|
||||
$id_agente, $id_agente_modulo, $fechatope);
|
||||
$result = mysql_query ($sql);
|
||||
if (mysql_num_rows ($result) == 0) {
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d', $id_agente_modulo, $fechatope);
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
if (empty ($result)) {
|
||||
graphic_error ();
|
||||
return;
|
||||
}
|
||||
while ($row = mysql_fetch_array ($result)) {
|
||||
$datos = $row[0];
|
||||
$utimestamp = $row[1];
|
||||
foreach ($result as $row) {
|
||||
$datos = $row["datos"];
|
||||
$utimestamp = $row["utimestamp"];
|
||||
for ($i = 0; $i <= $resolution; $i++) {
|
||||
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
|
||||
$valores[$i][0]=$valores[$i][0]+$datos;
|
||||
|
@ -803,7 +787,8 @@ function graphic_agentaccess ($id_agent, $periodo, $width, $height) {
|
|||
|
||||
}*/
|
||||
$intervalo = 24;
|
||||
$fechatope = dame_fecha($periodo);
|
||||
$fechatope = get_system_time () - $periodo;
|
||||
|
||||
$horasint = $periodo / $intervalo;
|
||||
|
||||
// $intervalo now stores "ideal" interval }
|
||||
|
@ -816,25 +801,25 @@ function graphic_agentaccess ($id_agent, $periodo, $width, $height) {
|
|||
// esto acelera el tiempo de calculo al maximo, aunque complica el algoritmo :-)
|
||||
|
||||
// Creamos la tabla (array) con los valores para el grafico. Inicializacion
|
||||
for ($i = 0; $i <$intervalo; $i++) {
|
||||
for ($i = 0; $i < $intervalo; $i++) {
|
||||
$valores[$i][0] = 0; // [0] Valor (contador)
|
||||
$valores[$i][1] = 0; // [0] Valor (contador)
|
||||
$valores[$i][2] = dame_fecha($horasint * $i); // [2] Rango superior de fecha para ese rango
|
||||
$valores[$i][3] = dame_fecha($horasint*($i+1)); // [3] Rango inferior de fecha para ese rango
|
||||
$valores[$i][2] = date ("Y-m-d H:i:00", get_system_time () - ($horasint * $i)); // [2] Rango superior de fecha para ese rango
|
||||
$valores[$i][3] = date ("Y-m-d H:i:00", get_system_time () - ($horasint * ($i+1))); // [3] Rango inferior de fecha para ese rango
|
||||
}
|
||||
$sql1="SELECT * FROM tagent_access WHERE id_agent = ".$id_agent." and timestamp > '".$fechatope."'";
|
||||
$sql1="SELECT timestamp FROM tagent_access WHERE id_agent = ".$id_agent." and timestamp > '".date ("Y-m-d H:i:00", $fechatope)."'";
|
||||
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
for ($i = 0; $i < $intervalo; $i++){
|
||||
if (($row["timestamp"] < $valores[$i][2]) and ($row["timestamp"] >= $valores[$i][3]) ){
|
||||
$result= get_db_all_rows_sql ($sql1);
|
||||
foreach ($result as $row) {
|
||||
for ($i = 0; $i < $intervalo; $i++) {
|
||||
if (($row["timestamp"] < $valores[$i][2]) and ($row["timestamp"] >= $valores[$i][3])) {
|
||||
// entra en esta fila
|
||||
$valores[$i][0]++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$valor_maximo = 0;
|
||||
|
||||
for ($i = 0; $i < $intervalo; $i++) { // 30 entries in graph, one by day
|
||||
$grafica[]=$valores[$i][0];
|
||||
if ($valores[$i][0] > $valor_maximo)
|
||||
|
@ -851,8 +836,7 @@ function graphic_agentaccess ($id_agent, $periodo, $width, $height) {
|
|||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array("", 2)),
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
0)
|
||||
$Plotarea = Image_Graph::factory('plotarea'),0)
|
||||
);
|
||||
// Create the dataset
|
||||
// Merge data into a dataset object (sancho)
|
||||
|
@ -905,11 +889,11 @@ function graphic_string_data ($id_agent_module, $periodo, $width, $height, $pure
|
|||
$valores[$i][3] = $fechatope + ($horasint * ($i + 1)); // [3] Botom limit
|
||||
}
|
||||
$sql1="SELECT utimestamp FROM tagente_datos_string WHERE id_agente_modulo = ".$id_agent_module." and utimestamp > '".$fechatope."'";
|
||||
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
$result = get_db_all_rows_sql ($sql1);
|
||||
|
||||
foreach ($result as $row) {
|
||||
for ($i = 0; $i < $resolution; $i++){
|
||||
if (($row[0] < $valores[$i][3]) and ($row[0] >= $valores[$i][2]) ){
|
||||
if (($row["utimestamp"] < $valores[$i][3]) and ($row["utimestamp"] >= $valores[$i][2]) ){
|
||||
// entra en esta fila
|
||||
$valores[$i][0]++;
|
||||
}
|
||||
|
@ -1197,21 +1181,17 @@ function grafico_db_agentes_modulos($width, $height) {
|
|||
$data = array();
|
||||
$legend = array();
|
||||
|
||||
$sql = "SELECT DISTINCT(id_agente), COUNT(id_agente_datos) AS count FROM tagente_datos GROUP BY id_agente ORDER BY count ASC";
|
||||
//This query is not the most efficient on itself. But other functions
|
||||
//use this query so it will a) be fetched from cache and b) it will
|
||||
//return the result in the same order as the other graph and data
|
||||
$agents = get_group_agents (1);
|
||||
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
if ($result === false)
|
||||
$result = array();
|
||||
|
||||
foreach ($result as $row) {
|
||||
$data[] = get_agent_modules_count ($row["id_agente"]);
|
||||
$legend[] = get_agent_name ($row["id_agente"], "lower");
|
||||
foreach ($agents as $agent_id => $agent_name) {
|
||||
//This query is not the most efficient on itself. But other functions
|
||||
//use this query so it will a) be fetched from cache and b) it will
|
||||
//return the result in the same order as the other graph and data
|
||||
$data[$agent_name] = get_agent_modules_count ($agent_id);
|
||||
}
|
||||
asort ($data, SORT_NUMERIC);
|
||||
|
||||
generic_bar_graph ($width, $height, $data, $legend);
|
||||
generic_bar_graph ($width, $height, $data, array_keys ($data));
|
||||
}
|
||||
|
||||
function grafico_eventos_usuario( $width=420, $height=200) {
|
||||
|
@ -1410,8 +1390,10 @@ function generic_bar_graph ( $width =380, $height = 200, $data, $legend) {
|
|||
// Create the dataset
|
||||
// Merge data into a dataset object (sancho)
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < sizeof($data); $i++) {
|
||||
$Dataset1->addPoint(substr($legend[$i], 0, 22), $data[$i]);
|
||||
$i = 0;
|
||||
foreach ($data as $datapoint) {
|
||||
$Dataset1->addPoint(substr($legend[$i], 0, 22), $datapoint);
|
||||
$i++;
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('bar', $Dataset1);
|
||||
$GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
|
@ -1426,15 +1408,16 @@ function grafico_db_agentes_paquetes ($width = 380, $height = 300) {
|
|||
$data = array();
|
||||
$legend = array();
|
||||
|
||||
$sql = "SELECT DISTINCT(id_agente), COUNT(id_agente_datos) AS count FROM tagente_datos GROUP BY id_agente ORDER BY count ASC";
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
$agents = get_group_agents (1);
|
||||
|
||||
if ($result === false)
|
||||
$result = array();
|
||||
|
||||
foreach ($result as $row) {
|
||||
$data[] = $row["count"];
|
||||
$legend[] = get_agent_name ($row["id_agente"], "lower");
|
||||
$count = get_agent_modules_data_count (array_keys ($agents));
|
||||
|
||||
unset ($count["total"]);
|
||||
asort ($count, SORT_NUMERIC);
|
||||
|
||||
foreach ($count as $agent_id => $value) {
|
||||
$data[] = $value;
|
||||
$legend[] = $agents[$agent_id];
|
||||
}
|
||||
|
||||
generic_bar_graph ($width, $height, $data, $legend);
|
||||
|
@ -1473,18 +1456,18 @@ function grafico_db_agentes_purge ($id_agent, $width, $height) {
|
|||
$legend[3] = "3 ".__("Months");
|
||||
$legend[4] = __("Older");
|
||||
|
||||
$data[0] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data[1] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data[2] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data[3] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data[4] = get_db_sql (sprintf ("SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
$data[0] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data[1] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data[2] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data[3] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data[4] = get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos WHERE 1=1 %s", $query));
|
||||
|
||||
|
||||
$data[0] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data[1] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data[2] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data[3] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data[4] += get_db_sql (sprintf ("SELECT COUNT(id_tagente_datos_string) FROM tagente_datos_string WHERE 1=1 %s", $query));
|
||||
$data[0] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1day"], $query));
|
||||
$data[1] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1week"], $query));
|
||||
$data[2] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["1month"], $query));
|
||||
$data[3] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE utimestamp > %d %s", $time["3month"], $query));
|
||||
$data[4] += get_db_sql (sprintf ("SELECT COUNT(*) FROM tagente_datos_string WHERE 1=1 %s", $query));
|
||||
|
||||
$data[4] = $data[4] - $data[3];
|
||||
|
||||
|
@ -1704,11 +1687,10 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
|
|||
|
||||
$resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph
|
||||
|
||||
//$unix_timestamp = strtotime($mysql_timestamp) // Convert MYSQL format tio utime
|
||||
$fechatope = time() - $periodo; // limit date
|
||||
$fechatope = get_system_time () - $periodo; // limit date
|
||||
$horasint = $periodo / $resolution; // Each intervalo is $horasint seconds length
|
||||
$nombre_agente = get_agentmodule_agent_name($id_agente_modulo);
|
||||
$id_agente = dame_agente_id($nombre_agente);
|
||||
$id_agente = get_agentmodule_agent ($id_agente_modulo);
|
||||
$nombre_agente = get_agent_name ($id_agente);
|
||||
$nombre_modulo = get_agentmodule_name ($id_agente_modulo);
|
||||
|
||||
if ($show_event == 1)
|
||||
|
@ -1718,16 +1700,14 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
|
|||
$alert_high = 0;
|
||||
$alert_low = 10000000;
|
||||
// If we want to show alerts limits
|
||||
$sql1="SELECT * FROM talerta_agente_modulo where id_agente_modulo = ".$id_agente_modulo;
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
if ($row["dis_max"] > $alert_high)
|
||||
$alert_high = $row["dis_max"];
|
||||
if ($row["dis_min"] < $alert_low)
|
||||
$alert_low = $row["dis_min"];
|
||||
$sql1 = "SELECT MAX(dis_max), MIN(dis_min) FROM talerta_agente_modulo WHERE id_agente_modulo = ".$id_agente_modulo;
|
||||
$result = get_db_row_sql ($sql1);
|
||||
if ($result !== false) {
|
||||
$alert_high = $result["max"];
|
||||
$alert_low = $result["min"];
|
||||
}
|
||||
// if no valid alert defined to render limits, disable it
|
||||
if (($alert_low == 10000000) && ($alert_high == 0)){
|
||||
if (($alert_low == 10000000) && ($alert_high == 0)) {
|
||||
$show_alert = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1741,7 +1721,7 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
|
|||
$valores[$i][0] = 0; // SUM of all values for this interval
|
||||
$valores[$i][1] = 0; // counter
|
||||
$valores[$i][2] = $fechatope + ($horasint * $i); // [2] Top limit for this range
|
||||
$valores[$i][3] = $fechatope + ($horasint*($i+1)); // [3] Botom limit
|
||||
$valores[$i][3] = $fechatope + ($horasint * ($i+1)); // [3] Botom limit
|
||||
$valores[$i][4] = -1; // MIN
|
||||
$valores[$i][5] = -1; // MAX
|
||||
$valores[$i][6] = -1; // Event
|
||||
|
@ -1750,12 +1730,11 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
|
|||
if ($show_event == 1){
|
||||
// If we want to show events in graphs
|
||||
$sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope";
|
||||
$result=mysql_query($sql1);
|
||||
while ($row = mysql_fetch_array($result)){
|
||||
$utimestamp = $row[0];
|
||||
$result = get_db_all_rows_sql ($sql1);
|
||||
foreach ($result as $row) {
|
||||
for ($i=0; $i <= $resolution; $i++) {
|
||||
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
|
||||
$real_event[$i]=1;
|
||||
if ( ($row["utimestamp"] <= $valores[$i][3]) && ($row["utimestamp"] >= $valores[$i][2]) ){
|
||||
$real_event[$i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1772,46 +1751,53 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
|
|||
$row=mysql_fetch_array($result);
|
||||
$title=$title." [C] ".$row[0];
|
||||
*/
|
||||
$previous=0;
|
||||
$previous = 0;
|
||||
// Get the first data outsite (to the left---more old) of the interval given
|
||||
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope ORDER BY utimestamp DESC LIMIT 1";
|
||||
$result=mysql_query($sql1);
|
||||
if ($row=mysql_fetch_array($result))
|
||||
$previous=$row[0];
|
||||
$sql1 = "SELECT datos FROM tagente_datos WHERE id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope ORDER BY utimestamp DESC";
|
||||
$result = get_db_sql ($sql1);
|
||||
if (!empty ($result)) {
|
||||
$previous = $result["datos"];
|
||||
}
|
||||
|
||||
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope";
|
||||
//echo "$sql1<br>";
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
$datos = $row[0];
|
||||
$utimestamp = $row[1];
|
||||
$sql1="SELECT datos, utimestamp FROM tagente_datos WHERE id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope";
|
||||
|
||||
$result = get_db_all_rows_sql ($sql1);
|
||||
if ($result === false) {
|
||||
$result = array ();
|
||||
}
|
||||
foreach ($result as $row) {
|
||||
$datos = $row["datos"];
|
||||
$utimestamp = $row["utimestamp"];
|
||||
|
||||
$i = round(($utimestamp - $fechatope) / $horasint);
|
||||
if (isset($valores[$i][0])){
|
||||
if (isset ($valores[$i][0])) {
|
||||
$valores[$i][0] += $datos;
|
||||
$valores[$i][1]++;
|
||||
|
||||
if ($valores[$i][6] == -1)
|
||||
$valores[$i][6]=$datos;
|
||||
if ($valores[$i][6] == -1) {
|
||||
$valores[$i][6] = $datos;
|
||||
}
|
||||
|
||||
// Init min value
|
||||
if ($valores[$i][4] == -1)
|
||||
if ($valores[$i][4] == -1) {
|
||||
$valores[$i][4] = $datos;
|
||||
else {
|
||||
} else {
|
||||
// Check min value
|
||||
if ($datos < $valores[$i][4])
|
||||
if ($datos < $valores[$i][4]) {
|
||||
$valores[$i][4] = $datos;
|
||||
}
|
||||
}
|
||||
// Check max value
|
||||
if ($valores[$i][5] == -1)
|
||||
if ($valores[$i][5] == -1) {
|
||||
$valores[$i][5] = $datos;
|
||||
else
|
||||
if ($datos > $valores[$i][5])
|
||||
} else {
|
||||
if ($datos > $valores[$i][5]) {
|
||||
$valores[$i][5] = $datos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$last = $previous;
|
||||
// Calculate Average value for $valores[][0]
|
||||
for ($i =0; $i <= $resolution; $i++) {
|
||||
|
|
|
@ -111,11 +111,11 @@ if ($start_date != $current){
|
|||
|
||||
echo "<table width=450 cellspacing=1 cellpadding=1 class='databox' style='margin-left: 20px'>";
|
||||
echo "<tr><td><b>";
|
||||
echo __('Max. Value')." </b>: ". format_for_graph(get_agent_module_value_max ($id, $period));
|
||||
echo __('Max. Value')." </b>: ". format_for_graph(get_agentmodule_data_max ($id, $period));
|
||||
echo "</td><td><b>";
|
||||
echo __('Avg. Value')." </b>: ". format_for_graph(get_agent_module_value_average ($id, $period));
|
||||
echo __('Avg. Value')." </b>: ". format_for_graph(get_agentmodule_data_average ($id, $period));
|
||||
echo "</td><td><b>";
|
||||
echo __('Min. Value')." </b>: ". format_for_graph(get_agent_module_value_min ($id, $period));
|
||||
echo __('Min. Value')." </b>: ". format_for_graph(get_agentmodule_data_min ($id, $period));
|
||||
echo "</td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
|
|
Loading…
Reference in New Issue