Merge branch '936-weird-general-item-in-reports-dev' into 'develop'
Fixed general item in reports See merge request !526
This commit is contained in:
commit
1c4f64ac2a
|
@ -5519,7 +5519,8 @@ function reporting_general($report, $content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($generals as $key => $row) {
|
$index = 0;
|
||||||
|
foreach ($generals as $row) {
|
||||||
//Metaconsole connection
|
//Metaconsole connection
|
||||||
$server_name = $row ['server_name'];
|
$server_name = $row ['server_name'];
|
||||||
if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
|
if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
|
||||||
|
@ -5549,78 +5550,78 @@ function reporting_general($report, $content) {
|
||||||
$row['id_agent_module']);
|
$row['id_agent_module']);
|
||||||
|
|
||||||
if ($content['period'] == 0) {
|
if ($content['period'] == 0) {
|
||||||
$data_res[$key] =
|
$data_res[$index] =
|
||||||
modules_get_last_value($row['id_agent_module']);
|
modules_get_last_value($row['id_agent_module']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(is_numeric($type_mod)){
|
if(is_numeric($type_mod)){
|
||||||
switch ($row['operation']) {
|
switch ($row['operation']) {
|
||||||
case 'sum':
|
case 'sum':
|
||||||
$data_res[$key] =
|
$data_res[$index] =
|
||||||
reporting_get_agentmodule_data_sum(
|
reporting_get_agentmodule_data_sum(
|
||||||
$row['id_agent_module'], $content['period'], $report["datetime"]);
|
$row['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
break;
|
break;
|
||||||
case 'max':
|
case 'max':
|
||||||
$data_res[$key] =
|
$data_res[$index] =
|
||||||
reporting_get_agentmodule_data_max(
|
reporting_get_agentmodule_data_max(
|
||||||
$row['id_agent_module'], $content['period']);
|
$row['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
case 'min':
|
case 'min':
|
||||||
$data_res[$key] =
|
$data_res[$index] =
|
||||||
reporting_get_agentmodule_data_min(
|
reporting_get_agentmodule_data_min(
|
||||||
$row['id_agent_module'], $content['period']);
|
$row['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
case 'avg':
|
case 'avg':
|
||||||
default:
|
default:
|
||||||
$data_res[$key] =
|
$data_res[$index] =
|
||||||
reporting_get_agentmodule_data_average(
|
reporting_get_agentmodule_data_average(
|
||||||
$row['id_agent_module'], $content['period']);
|
$row['id_agent_module'], $content['period']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$data_res[$key] = $type_mod;
|
$data_res[$index] = $type_mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($content['group_by_agent']) {
|
switch ($content['group_by_agent']) {
|
||||||
case REPORT_GENERAL_NOT_GROUP_BY_AGENT:
|
case REPORT_GENERAL_NOT_GROUP_BY_AGENT:
|
||||||
$id_agent_module[$key] = $row['id_agent_module'];
|
$id_agent_module[$index] = $row['id_agent_module'];
|
||||||
$agent_name[$key] = $ag_name;
|
$agent_name[$index] = $ag_name;
|
||||||
$module_name[$key] = $mod_name;
|
$module_name[$index] = $mod_name;
|
||||||
$units[$key] = $unit;
|
$units[$index] = $unit;
|
||||||
$operations[$key] = $row['operation'];
|
$operations[$index] = $row['operation'];
|
||||||
break;
|
break;
|
||||||
case REPORT_GENERAL_GROUP_BY_AGENT:
|
case REPORT_GENERAL_GROUP_BY_AGENT:
|
||||||
if ($data_res[$key] === false) {
|
if ($data_res[$index] === false) {
|
||||||
$return["data"][$ag_name][$mod_name] = null;
|
$return["data"][$ag_name][$mod_name] = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!is_numeric($data_res[$key])) {
|
if (!is_numeric($data_res[$index])) {
|
||||||
$return["data"][$ag_name][$mod_name] = $data_res[$key];
|
$return["data"][$ag_name][$mod_name] = $data_res[$index];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return["data"][$ag_name][$mod_name] =
|
$return["data"][$ag_name][$mod_name] =
|
||||||
format_for_graph($data_res[$key], 2) . " " . $unit;
|
format_for_graph($data_res[$index], 2) . " " . $unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the avg, min and max
|
// Calculate the avg, min and max
|
||||||
if (is_numeric($data_res[$key])) {
|
if (is_numeric($data_res[$index])) {
|
||||||
$change_min = false;
|
$change_min = false;
|
||||||
if (is_null($return["min"]["value"])) {
|
if (is_null($return["min"]["value"])) {
|
||||||
$change_min = true;
|
$change_min = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($return["min"]["value"] > $data_res[$key]) {
|
if ($return["min"]["value"] > $data_res[$index]) {
|
||||||
$change_min = true;
|
$change_min = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($change_min) {
|
if ($change_min) {
|
||||||
$return["min"]["value"] = $data_res[$key];
|
$return["min"]["value"] = $data_res[$index];
|
||||||
$return["min"]["formated_value"] =
|
$return["min"]["formated_value"] =
|
||||||
format_for_graph($data_res[$key], 2) . " " . $unit;
|
format_for_graph($data_res[$index], 2) . " " . $unit;
|
||||||
$return["min"]["agent"] = $ag_name;
|
$return["min"]["agent"] = $ag_name;
|
||||||
$return["min"]["module"] = $mod_name;
|
$return["min"]["module"] = $mod_name;
|
||||||
}
|
}
|
||||||
|
@ -5630,30 +5631,31 @@ function reporting_general($report, $content) {
|
||||||
$change_max = true;
|
$change_max = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($return["max"]["value"] < $data_res[$key]) {
|
if ($return["max"]["value"] < $data_res[$index]) {
|
||||||
$change_max = true;
|
$change_max = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($change_max) {
|
if ($change_max) {
|
||||||
$return["max"]["value"] = $data_res[$key];
|
$return["max"]["value"] = $data_res[$index];
|
||||||
$return["max"]["formated_value"] =
|
$return["max"]["formated_value"] =
|
||||||
format_for_graph($data_res[$key], 2) . " " . $unit;
|
format_for_graph($data_res[$index], 2) . " " . $unit;
|
||||||
$return["max"]["agent"] = $ag_name;
|
$return["max"]["agent"] = $ag_name;
|
||||||
$return["max"]["module"] = $mod_name;
|
$return["max"]["module"] = $mod_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
$return["avg_value"] = $data_res[$key];
|
$return["avg_value"] = $data_res[$index];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return["avg_value"] =
|
$return["avg_value"] =
|
||||||
(($return["avg_value"] * $i) / ($i + 1))
|
(($return["avg_value"] * $i) / ($i + 1))
|
||||||
+
|
+
|
||||||
($data_res[$key] / ($i + 1));
|
($data_res[$index] / ($i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$index++;
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
//Restore dbconnection
|
//Restore dbconnection
|
||||||
|
|
|
@ -2592,10 +2592,6 @@ function reporting_html_general(&$table, $item) {
|
||||||
$table1->head[2] = __('Operation');
|
$table1->head[2] = __('Operation');
|
||||||
}
|
}
|
||||||
$table1->head[3] = __('Value');
|
$table1->head[3] = __('Value');
|
||||||
$table1->style[0] = 'text-align: left';
|
|
||||||
$table1->style[1] = 'text-align: left';
|
|
||||||
$table1->style[2] = 'text-align: left';
|
|
||||||
$table1->style[3] = 'text-align: left';
|
|
||||||
|
|
||||||
/* Begin - Order by agent */
|
/* Begin - Order by agent */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue