2011-10-26 17:18:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; version 2
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package Include
|
|
|
|
* @subpackage Forecast
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a prediction based on module data with least square method (linear regression)
|
|
|
|
*
|
|
|
|
* @param int Module id.
|
|
|
|
* @param int Period of the module data.
|
|
|
|
* @param int Period of the prediction or false to use it in prediction_date function (see below).
|
|
|
|
* @param int Maximun value using this function for prediction_date.
|
|
|
|
* @param int Minimun value using this function for prediction_date.
|
2011-12-15 16:27:32 +01:00
|
|
|
* @param bool Result data for CSV file exportation.
|
2011-10-26 17:18:51 +02:00
|
|
|
*
|
|
|
|
* @return array Void array or prediction of the module data.
|
|
|
|
*/
|
2015-06-08 11:05:19 +02:00
|
|
|
function forecast_projection_graph($module_id,
|
|
|
|
$period = SECONDS_2MONTHS, $prediction_period, $max_value = false,
|
|
|
|
$min_value = false, $csv = false) {
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
global $config;
|
2015-06-08 11:05:19 +02:00
|
|
|
|
2013-07-24 13:38:10 +02:00
|
|
|
$max_exec_time = ini_get('max_execution_time');
|
2015-06-08 11:05:19 +02:00
|
|
|
|
2013-07-24 13:38:10 +02:00
|
|
|
if ($max_exec_time !== false) {
|
2015-06-08 11:05:19 +02:00
|
|
|
|
2013-07-24 13:38:10 +02:00
|
|
|
$max_exec_time = (int)$max_exec_time;
|
2015-06-08 11:05:19 +02:00
|
|
|
|
2013-07-24 13:38:10 +02:00
|
|
|
}
|
2015-06-08 11:05:19 +02:00
|
|
|
|
2013-07-24 13:38:10 +02:00
|
|
|
$begin_time = time();
|
2015-06-08 11:05:19 +02:00
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
$module_data=grafico_modulo_sparse ($module_id, $period, 0,
|
2015-06-08 11:05:19 +02:00
|
|
|
300, 300 , '', null,
|
|
|
|
false, 0, false,
|
|
|
|
0, '', 0, 1, false,
|
|
|
|
true, '', 1, true);
|
|
|
|
|
|
|
|
if (empty($module_data)) {
|
2011-10-26 17:18:51 +02:00
|
|
|
return array();
|
|
|
|
}
|
2011-11-08 10:56:43 +01:00
|
|
|
// Prevents bad behaviour over image error
|
2012-02-28 13:05:41 +01:00
|
|
|
else if (!is_array($module_data) and preg_match('/^<img(.)*$/', $module_data)) {
|
2011-11-08 10:56:43 +01:00
|
|
|
return;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
}
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
// Data initialization
|
|
|
|
$sum_obs = 0;
|
|
|
|
$sum_xi = 0;
|
|
|
|
$sum_yi = 0;
|
|
|
|
$sum_xi_yi = 0;
|
|
|
|
$sum_xi2 = 0;
|
|
|
|
$sum_yi2 = 0;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
$sum_diff_dates = 0;
|
2011-10-26 17:18:51 +02:00
|
|
|
$last_timestamp = get_system_time();
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
$agent_interval = SECONDS_5MINUTES;
|
2011-10-26 17:18:51 +02:00
|
|
|
$cont = 1;
|
|
|
|
$data = array();
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
//$table->data = array();
|
2011-11-08 10:56:43 +01:00
|
|
|
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
// Creates data for calculation
|
2017-02-27 16:48:28 +01:00
|
|
|
if (is_array($module_data) || is_object($module_data)) {
|
|
|
|
foreach ($module_data as $utimestamp => $row) {
|
|
|
|
if ($utimestamp == '') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data[0] = '';
|
|
|
|
$data[1] = $cont;
|
|
|
|
$data[2] = date($config["date_format"], $utimestamp);
|
|
|
|
$data[3] = $utimestamp;
|
|
|
|
$data[4] = $row['sum'];
|
|
|
|
$data[5] = $utimestamp * $row['sum'];
|
|
|
|
$data[6] = $utimestamp * $utimestamp;
|
|
|
|
$data[7] = $row['sum'] * $row['sum'];
|
|
|
|
if ($cont == 1) {
|
|
|
|
$data[8] = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$data[8] = $utimestamp - $last_timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sum_obs = $sum_obs + $cont;
|
|
|
|
$sum_xi = $sum_xi + $utimestamp;
|
|
|
|
$sum_yi = $sum_yi + $row['sum'];
|
|
|
|
$sum_xi_yi = $sum_xi_yi + $data[5];
|
|
|
|
$sum_xi2 = $sum_xi2 + $data[6];
|
|
|
|
$sum_yi2 = $sum_yi2 + $data[7];
|
|
|
|
$sum_diff_dates = $sum_diff_dates + $data[8];
|
|
|
|
$last_timestamp = $utimestamp;
|
|
|
|
$cont++;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
$cont--;
|
|
|
|
|
|
|
|
// Calculation over data above:
|
|
|
|
// 1. Calculation of linear correlation coefficient...
|
|
|
|
|
|
|
|
// 1.1 Average for X: Sum(Xi)/Obs
|
|
|
|
// 1.2 Average for Y: Sum(Yi)/Obs
|
|
|
|
// 2. Covariance between vars
|
|
|
|
// 3.1 Standard deviation for X: sqrt((Sum(Xi²)/Obs) - (avg X)²)
|
|
|
|
// 3.2 Standard deviation for Y: sqrt((Sum(Yi²)/Obs) - (avg Y)²)
|
|
|
|
// Linear correlation coefficient:
|
|
|
|
|
2014-05-23 08:44:15 +02:00
|
|
|
if ($sum_xi != 0) {
|
|
|
|
$avg_x = $cont/$sum_xi;
|
|
|
|
} else {
|
|
|
|
$avg_x = 0;
|
|
|
|
}
|
2012-02-27 17:20:28 +01:00
|
|
|
if ($sum_yi != 0)
|
|
|
|
$avg_y = $cont/$sum_yi;
|
|
|
|
else
|
|
|
|
$avg_y = 0;
|
2014-05-23 08:44:15 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
if ($cont != 0) {
|
|
|
|
$covariance = $sum_xi_yi/$cont;
|
|
|
|
$dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x));
|
|
|
|
$dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y));
|
|
|
|
} else {
|
|
|
|
$covariance = 0;
|
|
|
|
$dev_x = 0;
|
|
|
|
$dev_y = 0;
|
|
|
|
}
|
2011-10-26 17:18:51 +02:00
|
|
|
// Prevents division by zero
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($dev_x != 0 and $dev_y != 0) {
|
|
|
|
$linear_coef = $covariance / ($dev_x * $dev_y);
|
2011-10-26 17:18:51 +02:00
|
|
|
}
|
2014-05-23 08:44:15 +02:00
|
|
|
*/
|
2011-10-26 17:18:51 +02:00
|
|
|
// Agent interval could be zero, 300 is the predefined
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($sum_obs == 0) {
|
|
|
|
$agent_interval = SECONDS_5MINUTES;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$agent_interval = $sum_diff_dates / $sum_obs;
|
|
|
|
}
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
// Could be a inverse correlation coefficient
|
|
|
|
// if $linear_coef < 0.0
|
|
|
|
// if $linear_coef >= -1.0 and $linear_coef <= -0.8999
|
|
|
|
// Function variables have an inverse linear relathionship!
|
|
|
|
// else
|
|
|
|
// Function variables don't have an inverse linear relathionship!
|
|
|
|
|
|
|
|
// Could be a direct correlation coefficient
|
|
|
|
// else
|
|
|
|
// if ($linear_coef >= 0.8999 and $linear_coef <= 1.0) {
|
|
|
|
// Function variables have a direct linear relathionship!
|
|
|
|
// else
|
|
|
|
// Function variables don't have a direct linear relathionship!
|
|
|
|
|
|
|
|
// 2. Calculation of linear regresion...
|
|
|
|
|
|
|
|
$b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi));
|
|
|
|
$b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi));
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($b_den == 0)
|
|
|
|
return;
|
2011-10-26 17:18:51 +02:00
|
|
|
$b = $b_num / $b_den;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
$a_num = ($sum_yi) - ($b * $sum_xi);
|
2014-05-23 08:44:15 +02:00
|
|
|
|
|
|
|
if ($cont != 0) {
|
|
|
|
$a = $a_num / $cont;
|
|
|
|
} else {
|
|
|
|
$a = 0;
|
|
|
|
}
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
// Data inicialization
|
|
|
|
$output_data = array();
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($prediction_period != false) {
|
2011-10-26 17:18:51 +02:00
|
|
|
$limit_timestamp = $last_timestamp + $prediction_period;
|
|
|
|
}
|
|
|
|
$current_ts = $last_timestamp;
|
|
|
|
$in_range = true;
|
2012-01-03 18:41:04 +01:00
|
|
|
$time_format_2 = '';
|
|
|
|
|
|
|
|
$temp_range = $period;
|
|
|
|
if ($period < $prediction_period)
|
|
|
|
$temp_range = $prediction_period;
|
|
|
|
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($temp_range <= SECONDS_6HOURS) {
|
2012-01-03 18:41:04 +01:00
|
|
|
$time_format = 'H:i:s';
|
2011-10-26 17:18:51 +02:00
|
|
|
}
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
elseif ($temp_range < SECONDS_1DAY) {
|
2012-01-03 18:41:04 +01:00
|
|
|
$time_format = 'H:i';
|
2011-10-26 17:18:51 +02:00
|
|
|
}
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
elseif ($temp_range < SECONDS_15DAYS) {
|
2012-01-03 18:41:04 +01:00
|
|
|
$time_format = 'M d';
|
|
|
|
$time_format_2 = 'H\h';
|
2011-10-26 17:18:51 +02:00
|
|
|
}
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
elseif ($temp_range <= SECONDS_1MONTH) {
|
2012-01-03 18:41:04 +01:00
|
|
|
$time_format = 'M d';
|
|
|
|
$time_format_2 = 'H\h';
|
2011-10-26 17:18:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-01-03 18:41:04 +01:00
|
|
|
$time_format = 'M d';
|
|
|
|
}
|
2011-10-26 17:18:51 +02:00
|
|
|
|
|
|
|
// Aplying linear regression to module data in order to do the prediction
|
|
|
|
$output_data = array();
|
2011-12-15 16:27:32 +01:00
|
|
|
$idx = 0;
|
2011-10-26 17:18:51 +02:00
|
|
|
// Create data in graph format like
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
while ($in_range) {
|
2013-07-24 13:38:10 +02:00
|
|
|
$now = time();
|
|
|
|
|
|
|
|
// Check that exec time is not greater than half max exec server time
|
|
|
|
if ($max_exec_time !== false) {
|
|
|
|
if (($begin_time + ($max_exec_time/2)) < $now) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
$timestamp_f = date($time_format, $current_ts);
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
|
2012-01-03 18:41:04 +01:00
|
|
|
//$timestamp_f = date($time_format, $current_ts);
|
|
|
|
$timestamp_f = graph_get_formatted_date($current_ts, $time_format, $time_format_2);
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
|
|
|
|
if ($csv) {
|
2011-12-15 16:27:32 +01:00
|
|
|
$output_data[$idx]['date'] = $current_ts;
|
|
|
|
$output_data[$idx]['data'] = ($a + ($b * $current_ts));
|
|
|
|
}
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
else {
|
2011-12-15 16:27:32 +01:00
|
|
|
$output_data[$timestamp_f] = ($a + ($b * $current_ts));
|
|
|
|
}
|
2011-10-26 17:18:51 +02:00
|
|
|
// Using this function for prediction_date
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($prediction_period == false) {
|
2012-06-12 11:21:02 +02:00
|
|
|
// These statements stop the prediction when interval is greater than 2 years
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($current_ts - $last_timestamp >= 94608000) {
|
2011-10-26 17:18:51 +02:00
|
|
|
return false;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
}
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
// Found it
|
2015-06-08 11:05:19 +02:00
|
|
|
if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]) {
|
2011-10-26 17:18:51 +02:00
|
|
|
return $current_ts;
|
|
|
|
}
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
}
|
|
|
|
else if ($current_ts > $limit_timestamp) {
|
2011-10-26 17:18:51 +02:00
|
|
|
$in_range = false;
|
|
|
|
}
|
|
|
|
$current_ts = $current_ts + $agent_interval;
|
2011-12-15 16:27:32 +01:00
|
|
|
$idx++;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
}
|
|
|
|
|
2011-10-26 17:18:51 +02:00
|
|
|
return $output_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a date when the date interval is reached
|
|
|
|
*
|
|
|
|
* @param int Module id.
|
2011-10-27 13:27:49 +02:00
|
|
|
* @param int Given data period to make the prediction
|
2011-10-26 17:18:51 +02:00
|
|
|
* @param int Max value in the interval.
|
|
|
|
* @param int Min value in the interval.
|
|
|
|
*
|
|
|
|
* @return mixed timestamp with the prediction date or false
|
|
|
|
*/
|
2015-06-08 11:05:19 +02:00
|
|
|
function forecast_prediction_date ($module_id,
|
|
|
|
$period = SECONDS_2MONTHS, $max_value = 0, $min_value = 0) {
|
2011-10-26 17:18:51 +02:00
|
|
|
// Checks interval
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
if ($min_value > $max_value) {
|
2011-10-26 17:18:51 +02:00
|
|
|
return false;
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
}
|
|
|
|
|
2011-10-27 13:27:49 +02:00
|
|
|
return forecast_projection_graph($module_id, $period, false, $max_value, $min_value);
|
2011-10-26 17:18:51 +02:00
|
|
|
}
|