mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
2010-02-01 Sancho Lerena <slerena@artica.es>
Changes ported from 3.0 branch. * include/javascript/pandora_visual_console.js: Thiner lines in maps. * include/functions_visual_map.php: Fixed several issues in visual maps (bad hierarchy status color, limited depth for recursion, get unknown for agents and modules, and line color is now always associated to parent status) and non-status elements like labels, graphs or progress bars now doesnt propagate module status to parents. * include/functions_db.php: Added parameter to get_db_all_rows_sql() to avoid use of cache. Function process_sql() was not properly checking if cache usage was disabled and was always using cache. Added support for checking unknown status in get_agentmodule_status() function. * extensions/dbmanager/dbmanager.css, extensions/dbmanager.php: Fixed width of textarea. * operation/events/events.php: Fixed bug #2943907. * operation/agentes/exportdata.php: Fixed problem exporting CSV when data to export is TOO big, using an internal cache to read data. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2327 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e94bf6d263
commit
e79bc4095c
@ -1,3 +1,30 @@
|
|||||||
|
2010-02-01 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
Changes ported from 3.0 branch.
|
||||||
|
|
||||||
|
* include/javascript/pandora_visual_console.js: Thiner lines in maps.
|
||||||
|
|
||||||
|
* include/functions_visual_map.php: Fixed several issues in visual maps
|
||||||
|
(bad hierarchy status color, limited depth for recursion, get unknown
|
||||||
|
for agents and modules, and line color is now always associated to
|
||||||
|
parent status) and non-status elements like labels, graphs or progress
|
||||||
|
bars now doesnt propagate module status to parents.
|
||||||
|
|
||||||
|
* include/functions_db.php: Added parameter to get_db_all_rows_sql() to
|
||||||
|
avoid use of cache. Function process_sql() was not properly checking if
|
||||||
|
cache usage was disabled and was always using cache. Added support for
|
||||||
|
checking unknown status in get_agentmodule_status() function.
|
||||||
|
|
||||||
|
* extensions/dbmanager/dbmanager.css,
|
||||||
|
extensions/dbmanager.php: Fixed width of textarea.
|
||||||
|
|
||||||
|
* operation/events/events.php: Fixed bug #2943907.
|
||||||
|
|
||||||
|
* operation/agentes/exportdata.php: Fixed problem exporting CSV
|
||||||
|
when data to export is TOO big, using an internal cache to read
|
||||||
|
data.
|
||||||
|
|
||||||
|
|
||||||
2010-02-01 Raúl Mateos <raulofpandora@gmail.com>
|
2010-02-01 Raúl Mateos <raulofpandora@gmail.com>
|
||||||
|
|
||||||
* operation/agentes/estado_agente.php: Changed colour order for
|
* operation/agentes/estado_agente.php: Changed colour order for
|
||||||
|
@ -63,12 +63,11 @@ function dbmgr_extension_main () {
|
|||||||
echo "<br />";
|
echo "<br />";
|
||||||
echo "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
|
echo "Some samples of usage: <blockquote><em>SHOW STATUS;<br />DESCRIBE tagente<br />SELECT * FROM tserver<br />UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'</em></blockquote>";
|
||||||
|
|
||||||
|
|
||||||
echo "<br /><br />";
|
echo "<br /><br />";
|
||||||
echo "<form method='post' action=''>";
|
echo "<form method='post' action=''>";
|
||||||
print_textarea ('sql', 5, 50, html_entity_decode($sql, ENT_QUOTES));
|
print_textarea ('sql', 5, 40, html_entity_decode($sql, ENT_QUOTES));
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<div class="action-buttons" style="width: 100%">';
|
echo '<div class="action-buttons" style="width: 96%">';
|
||||||
print_submit_button (__('Execute SQL'), '', false, 'class="sub next"');
|
print_submit_button (__('Execute SQL'), '', false, 'class="sub next"');
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
@ -22,9 +22,9 @@ table.dbmanager th {
|
|||||||
background: #888;
|
background: #888;
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea.dbmanager {
|
textarea {
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
width: 90%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* Pandora build version and version
|
* Pandora build version and version
|
||||||
*/
|
*/
|
||||||
$build_version = 'PC091231';
|
$build_version = 'PC100202';
|
||||||
$pandora_version = 'v3.1-dev';
|
$pandora_version = 'v3.1-dev';
|
||||||
|
|
||||||
/* Help to debug problems. Override global PHP configuration */
|
/* Help to debug problems. Override global PHP configuration */
|
||||||
|
@ -1816,13 +1816,14 @@ function get_db_sql ($sql, $field = 0, $search_history_db = false) {
|
|||||||
* Get all the result rows using an SQL statement.
|
* Get all the result rows using an SQL statement.
|
||||||
*
|
*
|
||||||
* @param string SQL statement to execute.
|
* @param string SQL statement to execute.
|
||||||
|
* @param bool If want to search in history database also
|
||||||
|
* @param bool If want to use cache (true by default)
|
||||||
*
|
*
|
||||||
* @return mixed A matrix with all the values returned from the SQL statement or
|
* @return mixed A matrix with all the values returned from the SQL statement or
|
||||||
* false in case of empty result
|
* false in case of empty result
|
||||||
*/
|
*/
|
||||||
function get_db_all_rows_sql ($sql, $search_history_db = false) {
|
function get_db_all_rows_sql ($sql, $search_history_db = false, $cache = true) {
|
||||||
global $config;
|
global $config;
|
||||||
$cache = true;
|
|
||||||
$history = array ();
|
$history = array ();
|
||||||
|
|
||||||
// Read from the history DB if necessary
|
// Read from the history DB if necessary
|
||||||
@ -2072,7 +2073,9 @@ function process_sql ($sql, $rettype = "affected_rows", $dbconnection = '', $cac
|
|||||||
while ($row = mysql_fetch_array ($result)) {
|
while ($row = mysql_fetch_array ($result)) {
|
||||||
array_push ($retval, $row);
|
array_push ($retval, $row);
|
||||||
}
|
}
|
||||||
$sql_cache[$sql] = $retval;
|
|
||||||
|
if ($cache === true)
|
||||||
|
$sql_cache[$sql] = $retval;
|
||||||
mysql_free_result ($result);
|
mysql_free_result ($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2348,12 +2351,28 @@ function format_array_to_where_clause_sql ($values, $join = 'AND', $prefix = fal
|
|||||||
* module were fired.
|
* module were fired.
|
||||||
*/
|
*/
|
||||||
function get_agentmodule_status ($id_agentmodule = 0) {
|
function get_agentmodule_status ($id_agentmodule = 0) {
|
||||||
|
$current_timestamp = get_system_time ();
|
||||||
|
|
||||||
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule);
|
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule);
|
||||||
if ($times_fired > 0) {
|
if ($times_fired > 0) {
|
||||||
return 4; // Alert
|
return 4; // Alert
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = get_db_value ('estado', 'tagente_estado', 'id_agente_modulo', $id_agentmodule);
|
|
||||||
|
|
||||||
|
$status_row = get_db_row ("tagente_estado", "id_agente_modulo", $id_agentmodule);
|
||||||
|
|
||||||
|
// Not init or current_interval == 0: Return current status and avoid problems here !
|
||||||
|
if ($status_row["current_interval"] == 0)
|
||||||
|
return $status_row["estado"];
|
||||||
|
|
||||||
|
// Unknown status
|
||||||
|
if ( ($status_row["current_interval"] * 2) + $status_row["utimestamp"] < $current_timestamp){
|
||||||
|
$status = 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$status = $status_row['estado'];
|
||||||
|
}
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
@ -2470,7 +2489,7 @@ function get_agentmodule_data ($id_agent_module, $period, $date = 0) {
|
|||||||
AND utimestamp > %d AND utimestamp <= %d ORDER BY utimestamp ASC",
|
AND utimestamp > %d AND utimestamp <= %d ORDER BY utimestamp ASC",
|
||||||
$id_agent_module, $datelimit, $date);
|
$id_agent_module, $datelimit, $date);
|
||||||
|
|
||||||
$values = get_db_all_rows_sql ($sql, true);
|
$values = get_db_all_rows_sql ($sql, true, false);
|
||||||
|
|
||||||
if ($values === false) {
|
if ($values === false) {
|
||||||
return array ();
|
return array ();
|
||||||
|
@ -59,34 +59,73 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
|||||||
|
|
||||||
if ($layout_datas !== false) {
|
if ($layout_datas !== false) {
|
||||||
foreach ($layout_datas as $layout_data) {
|
foreach ($layout_datas as $layout_data) {
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
|
// Get parent status (Could be an agent, module, map, others doesnt have parent info)
|
||||||
|
// ****************************************************************
|
||||||
|
|
||||||
|
if ($layout_data["parent_item"] != 0){
|
||||||
|
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
|
||||||
|
$id_agent_parent = get_db_value ("id_agent", "tlayout_data", "id", $layout_data["parent_item"]);
|
||||||
|
$id_layout_linked = get_db_value ("id_layout_linked", "tlayout_data", "id", $layout_data["parent_item"]);
|
||||||
|
|
||||||
|
// Module
|
||||||
|
if ($id_agent_module_parent != 0) {
|
||||||
|
$status_parent = get_agentmodule_status ($id_agent_module_parent);
|
||||||
|
// Agent
|
||||||
|
}
|
||||||
|
elseif ($id_agent_parent != 0) {
|
||||||
|
$status_parent = get_agent_status ($id_agent_parent);
|
||||||
|
}
|
||||||
|
// Another layout/map
|
||||||
|
elseif ($id_layout_linked != 0) {
|
||||||
|
$status_parent = get_layout_status ($id_layout_linked);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
$status_parent = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$id_agent_module_parent = 0;
|
||||||
|
$status_parent = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
|
// Get STATUS of current object
|
||||||
|
// ****************************************************************
|
||||||
|
|
||||||
// Linked to other layout ?? - Only if not module defined
|
// Linked to other layout ?? - Only if not module defined
|
||||||
if ($layout_data['id_layout_linked'] != 0) {
|
if ($layout_data['id_layout_linked'] != 0) {
|
||||||
$status = get_layout_status ($layout_data['id_layout_linked']);
|
$status = get_layout_status ($layout_data['id_layout_linked']);
|
||||||
$status_parent = 3;
|
|
||||||
} else {
|
// Single object
|
||||||
|
} elseif ($layout_data["type"] == 0) {
|
||||||
// Status for a simple module
|
// Status for a simple module
|
||||||
if ($layout_data['id_agente_modulo'] != 0) {
|
if ($layout_data['id_agente_modulo'] != 0) {
|
||||||
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
|
|
||||||
$id_agent_module_parent = get_db_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
|
|
||||||
// Item value
|
|
||||||
$status = get_agentmodule_status ($layout_data['id_agente_modulo']);
|
$status = get_agentmodule_status ($layout_data['id_agente_modulo']);
|
||||||
if ($layout_data['no_link_color'] == 1)
|
$id_agent = get_db_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
|
||||||
$status_parent = 3;
|
|
||||||
else
|
// Status for a whole agent, if agente_modulo was == 0
|
||||||
$status_parent = get_agentmodule_status ($id_agent_module_parent);
|
|
||||||
// Status for a whole agent
|
|
||||||
} elseif ($layout_data['id_agent'] != 0) {
|
} elseif ($layout_data['id_agent'] != 0) {
|
||||||
$status = get_agent_status ($layout_data["id_agent"]);
|
$status = get_agent_status ($layout_data["id_agent"]);
|
||||||
$status_parent = $status;
|
if ($status == -1) // get_agent_status return -1 for unknown!
|
||||||
|
$status = 3;
|
||||||
$id_agent = $layout_data["id_agent"];
|
$id_agent = $layout_data["id_agent"];
|
||||||
} else {
|
} else {
|
||||||
$status = 3;
|
$status = 3;
|
||||||
$status_parent = 3;
|
|
||||||
$id_agent = 0;
|
$id_agent = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If it's a graph, a progress bar or a data tag, ALWAYS report
|
||||||
|
// status OK (=0) to avoid confussions here.
|
||||||
|
$status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
// STATIC IMAGE (type = 0)
|
// STATIC IMAGE (type = 0)
|
||||||
|
// ****************************************************************
|
||||||
if ($layout_data['type'] == 0) {
|
if ($layout_data['type'] == 0) {
|
||||||
// Link image
|
// Link image
|
||||||
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
|
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
|
||||||
@ -110,11 +149,14 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
|||||||
|
|
||||||
if ($show_links) {
|
if ($show_links) {
|
||||||
if (($id_agent > 0) && ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0)) {
|
if (($id_agent > 0) && ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0)) {
|
||||||
|
|
||||||
// Link to an agent
|
// Link to an agent
|
||||||
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'">';
|
echo '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.'">';
|
||||||
} elseif ($layout_data['id_layout_linked'] > 0) {
|
} elseif ($layout_data['id_layout_linked'] > 0) {
|
||||||
|
|
||||||
// Link to a map
|
// Link to a map
|
||||||
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data["id_layout_linked"].'">';
|
echo '<a href="index.php?sec=visualc&sec2=operation/visual_console/render_view&pure='.$config["pure"].'&id='.$layout_data["id_layout_linked"].'">';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// A void object
|
// A void object
|
||||||
echo '<a href="#">';
|
echo '<a href="#">';
|
||||||
@ -184,7 +226,9 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
|||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
// SIMPLE DATA VALUE (type = 2)
|
// SIMPLE DATA VALUE (type = 2)
|
||||||
|
// ****************************************************************
|
||||||
switch ($layout_data['type']) {
|
switch ($layout_data['type']) {
|
||||||
case 2:
|
case 2:
|
||||||
if ($resizedMap)
|
if ($resizedMap)
|
||||||
@ -195,6 +239,10 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
|||||||
echo get_db_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']);
|
echo get_db_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']);
|
||||||
echo '</strong></div>';
|
echo '</strong></div>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
|
// Progress bar
|
||||||
|
// ****************************************************************
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
// Percentile bar (type = 3)
|
// Percentile bar (type = 3)
|
||||||
@ -220,6 +268,10 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
//}
|
//}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
|
// Single module graph
|
||||||
|
// ****************************************************************
|
||||||
case 1;
|
case 1;
|
||||||
// SINGLE GRAPH (type = 1)
|
// SINGLE GRAPH (type = 1)
|
||||||
if ($resizedMap)
|
if ($resizedMap)
|
||||||
@ -263,12 +315,25 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// ****************************************************************
|
||||||
|
// Lines joining objects
|
||||||
|
// ****************************************************************
|
||||||
// Get parent relationship - Create line data
|
// Get parent relationship - Create line data
|
||||||
if ($layout_data["parent_item"] != "" && $layout_data["parent_item"] != 0) {
|
if ($layout_data["parent_item"] != "" && $layout_data["parent_item"] != 0) {
|
||||||
$line['id'] = $layout_data['id'];
|
$line['id'] = $layout_data['id'];
|
||||||
$line['node_begin'] = 'layout-data-'.$layout_data["parent_item"];
|
$line['node_begin'] = 'layout-data-'.$layout_data["parent_item"];
|
||||||
$line['node_end'] = 'layout-data-'.$layout_data["id"];
|
$line['node_end'] = 'layout-data-'.$layout_data["id"];
|
||||||
$line['color'] = $status_parent ? '#00dd00' : '#dd0000';
|
switch ($status_parent) {
|
||||||
|
case 3: $line["color"] = "#ccc"; // Gray
|
||||||
|
break;
|
||||||
|
case 2: $line["color"] = "#20f6f6"; // Yellow
|
||||||
|
break;
|
||||||
|
case 0: $line["color"] = "#00ff00"; // Green
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 1: $line["color"] = "#ff0000"; // Red
|
||||||
|
break;
|
||||||
|
}
|
||||||
array_push ($lines, $line);
|
array_push ($lines, $line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,12 +415,19 @@ function get_user_layouts ($id_user = 0, $only_names = false, $filter = false) {
|
|||||||
* are OK. If any of them is down, then result is down (0)
|
* are OK. If any of them is down, then result is down (0)
|
||||||
*
|
*
|
||||||
* @param int Id of the layout
|
* @param int Id of the layout
|
||||||
|
* @param int Depth (for recursion control)
|
||||||
*
|
*
|
||||||
* @return bool The status of the given layout. True if it's OK, false if not.
|
* @return bool The status of the given layout. True if it's OK, false if not.
|
||||||
*/
|
*/
|
||||||
function get_layout_status ($id_layout = 0) {
|
function get_layout_status ($id_layout = 0, $depth = 0) {
|
||||||
$temp_status = 0;
|
$temp_status = 0;
|
||||||
$temp_total = 0;
|
$temp_total = 0;
|
||||||
|
$depth++; // For recursion depth checking
|
||||||
|
|
||||||
|
// TODO: Implement this limit as a configurable item in setup
|
||||||
|
if ($depth > 10){
|
||||||
|
return 3; // No status data if we need to exit by a excesive recursion
|
||||||
|
}
|
||||||
|
|
||||||
$id_layout = (int) $id_layout;
|
$id_layout = (int) $id_layout;
|
||||||
|
|
||||||
@ -371,7 +443,7 @@ function get_layout_status ($id_layout = 0) {
|
|||||||
continue;
|
continue;
|
||||||
// Other Layout (Recursive!)
|
// Other Layout (Recursive!)
|
||||||
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) {
|
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) {
|
||||||
$status = get_layout_status ($data["id_layout_linked"]);
|
$status = get_layout_status ($data["id_layout_linked"], $depth);
|
||||||
// Module
|
// Module
|
||||||
} elseif ($data["id_agente_modulo"] != 0) {
|
} elseif ($data["id_agente_modulo"] != 0) {
|
||||||
$status = get_agentmodule_status ($data["id_agente_modulo"]);
|
$status = get_agentmodule_status ($data["id_agente_modulo"]);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
function draw_line (line, id_div) {
|
function draw_line (line, id_div) {
|
||||||
div = document.getElementById (id_div);
|
div = document.getElementById (id_div);
|
||||||
brush = new jsGraphics (div);
|
brush = new jsGraphics (div);
|
||||||
brush.setStroke (2);
|
brush.setStroke (1);
|
||||||
brush.setColor (line['color']);
|
brush.setColor (line['color']);
|
||||||
if (line['x1']) {
|
if (line['x1']) {
|
||||||
x1 = line['x'];
|
x1 = line['x'];
|
||||||
|
@ -81,6 +81,12 @@ $export_type = get_parameter_post ('export_type', 'data');
|
|||||||
$export_btn = get_parameter_post ('export_btn', 0);
|
$export_btn = get_parameter_post ('export_btn', 0);
|
||||||
|
|
||||||
if (!empty ($export_btn) && !empty ($module)) {
|
if (!empty ($export_btn) && !empty ($module)) {
|
||||||
|
|
||||||
|
// Disable SQL cache
|
||||||
|
global $sql_cache;
|
||||||
|
$sql_cache = array ('saved' => 0);
|
||||||
|
|
||||||
|
|
||||||
//Convert start time and end time to unix timestamps
|
//Convert start time and end time to unix timestamps
|
||||||
$start = strtotime ($start_date." ".$start_time);
|
$start = strtotime ($start_date." ".$start_time);
|
||||||
$end = strtotime ($end_date." ".$end_time);
|
$end = strtotime ($end_date." ".$end_time);
|
||||||
@ -92,47 +98,17 @@ if (!empty ($export_btn) && !empty ($module)) {
|
|||||||
print_error_message (__('Invalid time specified'));
|
print_error_message (__('Invalid time specified'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data
|
// ***************************************************
|
||||||
$data = array ();
|
|
||||||
switch ($export_type) {
|
|
||||||
case "data":
|
|
||||||
case "excel":
|
|
||||||
case "csv":
|
|
||||||
foreach ($module as $selected) {
|
|
||||||
$data_single = get_agentmodule_data ($selected, $period, $end);
|
|
||||||
if (!empty ($data_single)) {
|
|
||||||
$data = array_merge ($data, $data_single);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "avg":
|
|
||||||
foreach ($module as $selected) {
|
|
||||||
$arr = array ();
|
|
||||||
$arr["data"] = get_agentmodule_data_average ($selected, $period, $end);
|
|
||||||
if ($arr["data"] === false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$arr["module_name"] = get_agentmodule_name ($selected);
|
|
||||||
$arr["agent_name"] = get_agentmodule_agent_name ($selected);
|
|
||||||
$arr["agent_id"] = get_agentmodule_agent ($selected);
|
|
||||||
$arr["utimestamp"] = $end;
|
|
||||||
array_push ($data, $arr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
print_error_message (__('Invalid method supplied'));
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Starts, ends and dividers
|
// Starts, ends and dividers
|
||||||
|
// ***************************************************
|
||||||
|
|
||||||
switch ($export_type) {
|
switch ($export_type) {
|
||||||
case "data":
|
case "data":
|
||||||
case "avg":
|
case "avg":
|
||||||
default:
|
default:
|
||||||
//HTML output - don't style or use XHTML just in case somebody needs to copy/paste it. (Office doesn't handle <thead> and <tbody>)
|
//HTML output - don't style or use XHTML just in case somebody needs to copy/paste it. (Office doesn't handle <thead> and <tbody>)
|
||||||
$datastart = '<table style="width:700px;"><tr><td>'.__('Agent').'</td><td>'.__('Module').'</td><td>'.__('Data').'</td><td>'.__('Timestamp').'</td></tr>';
|
$datastart = '<table style="width:700px;"><tr><th>'.__('Agent').'</th><th>'.__('Module').'</th><th>'.__('Data').'</th><th>'.__('Timestamp').'</th></tr>';
|
||||||
$rowstart = '<tr><td>';
|
$rowstart = '<tr><td>';
|
||||||
$divider = '</td><td>';
|
$divider = '</td><td>';
|
||||||
$rowend = '</td></tr>';
|
$rowend = '</td></tr>';
|
||||||
@ -158,42 +134,124 @@ if (!empty ($export_btn) && !empty ($module)) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $datastart;
|
// ***************************************************
|
||||||
foreach ($data as $key => $module) {
|
// Header output
|
||||||
$output .= $rowstart;
|
// ***************************************************
|
||||||
$output .= $module['agent_name'];
|
|
||||||
$output .= $divider;
|
|
||||||
$output .= $module['module_name'];
|
|
||||||
$output .= $divider;
|
|
||||||
$output .= $module['data'];
|
|
||||||
$output .= $divider;
|
|
||||||
$output .= date ($config["date_format"], $module['utimestamp']);
|
|
||||||
$output .= $rowend;
|
|
||||||
}
|
|
||||||
$output .= $dataend;
|
|
||||||
|
|
||||||
switch ($export_type) {
|
switch ($export_type) {
|
||||||
default:
|
|
||||||
case "data":
|
|
||||||
case "avg":
|
|
||||||
echo $output;
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
case "excel":
|
case "excel":
|
||||||
case "csv":
|
case "csv":
|
||||||
//Encase into a file and offer download
|
|
||||||
//Flush buffers - we don't need them.
|
|
||||||
$config['ignore_callback'] = true;
|
$config['ignore_callback'] = true;
|
||||||
while (@ob_end_clean ());
|
while (@ob_end_clean ());
|
||||||
|
|
||||||
header("Content-type: application/octet-stream");
|
header("Content-type: application/octet-stream");
|
||||||
header("Content-Disposition: attachment; filename=export_".date("Ymd", $start)."_".date("Ymd", $end).".".$extension);
|
header("Content-Disposition: attachment; filename=export_".date("Ymd", $start)."_".date("Ymd", $end).".".$extension);
|
||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
header("Expires: 0");
|
header("Expires: 0");
|
||||||
echo $output;
|
}
|
||||||
exit;
|
|
||||||
//Exit necessary so it doesn't continue processing and give erroneous downloads
|
// ***************************************************
|
||||||
|
// Data processing
|
||||||
|
// ***************************************************
|
||||||
|
|
||||||
|
$data = array ();
|
||||||
|
switch ($export_type) {
|
||||||
|
case "data":
|
||||||
|
case "excel":
|
||||||
|
case "csv":
|
||||||
|
|
||||||
|
// Show header
|
||||||
|
echo $datastart;
|
||||||
|
|
||||||
|
foreach ($module as $selected) {
|
||||||
|
|
||||||
|
$output = "";
|
||||||
|
$work_period = 120000;
|
||||||
|
|
||||||
|
$work_end = $end - $period + $work_period;
|
||||||
|
//Buffer to get data, anyway this will report a memory exhaustin
|
||||||
|
|
||||||
|
while ( $work_end < $end) {
|
||||||
|
$work_end = $work_end + $work_period;
|
||||||
|
|
||||||
|
$data = array (); // Reinitialize array for each module chunk
|
||||||
|
$data_single = get_agentmodule_data ($selected, $work_period, $work_end);
|
||||||
|
if (!empty ($data_single)) {
|
||||||
|
$data = array_merge ($data, $data_single);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ($work_end > $end) {
|
||||||
|
$work_period = $work_end - $end;
|
||||||
|
$work_end = $end;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
foreach ($data as $key => $module) {
|
||||||
|
$output .= $rowstart;
|
||||||
|
$output .= $module['agent_name'];
|
||||||
|
$output .= $divider;
|
||||||
|
$output .= $module['module_name'];
|
||||||
|
$output .= $divider;
|
||||||
|
$output .= $module['data'];
|
||||||
|
$output .= $divider;
|
||||||
|
$output .= date ("Y-m-d g:i:s", $module['utimestamp']);
|
||||||
|
$output .= $rowend;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($export_type) {
|
||||||
|
default:
|
||||||
|
case "data":
|
||||||
|
case "avg":
|
||||||
|
echo $output;
|
||||||
|
break;
|
||||||
|
case "excel":
|
||||||
|
case "csv":
|
||||||
|
echo $output;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unset($output);
|
||||||
|
$output = "";
|
||||||
|
unset($data);
|
||||||
|
unset($data_single);
|
||||||
|
}
|
||||||
|
unset ($output);
|
||||||
|
$output = "";
|
||||||
|
} // main foreach
|
||||||
|
echo $dataend;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "avg":
|
||||||
|
foreach ($module as $selected) {
|
||||||
|
$arr = array ();
|
||||||
|
$arr["data"] = get_agentmodule_data_average ($selected, $period, $end);
|
||||||
|
if ($arr["data"] === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$arr["module_name"] = get_agentmodule_name ($selected);
|
||||||
|
$arr["agent_name"] = get_agentmodule_agent_name ($selected);
|
||||||
|
$arr["agent_id"] = get_agentmodule_agent ($selected);
|
||||||
|
$arr["utimestamp"] = $end;
|
||||||
|
array_push ($data, $arr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print_error_message (__('Invalid method supplied'));
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ($export_type) {
|
||||||
|
case "excel":
|
||||||
|
case "csv":
|
||||||
|
exit; // Necesary for CSV export, if not give problems
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} elseif (!empty ($export_btn) && empty ($module)) {
|
} elseif (!empty ($export_btn) && empty ($module)) {
|
||||||
print_error_message (__('No modules specified'));
|
print_error_message (__('No modules specified'));
|
||||||
}
|
}
|
||||||
@ -252,14 +310,14 @@ if ($agent > 0) {
|
|||||||
$table->data[2][1] = print_select ($modules, "module_arr[]", array_keys ($modules), '', '', 0, true, true, true, 'w130', false);
|
$table->data[2][1] = print_select ($modules, "module_arr[]", array_keys ($modules), '', '', 0, true, true, true, 'w130', false);
|
||||||
|
|
||||||
//Start date selector
|
//Start date selector
|
||||||
$table->data[3][0] = '<b>'.__('Begin date (*)').'</b>';
|
$table->data[3][0] = '<b>'.__('Begin date').'</b>';
|
||||||
|
|
||||||
$table->data[3][1] = print_input_text ('start_date', date ("Y-m-d", get_system_time () - 86400), false, 10, 10, true);
|
$table->data[3][1] = print_input_text ('start_date', date ("Y-m-d", get_system_time () - 86400), false, 10, 10, true);
|
||||||
$table->data[3][1] .= print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => 'scwShow(scwID("text-start_date"),this);'));
|
$table->data[3][1] .= print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => 'scwShow(scwID("text-start_date"),this);'));
|
||||||
$table->data[3][1] .= print_input_text ('start_time', date ("H:m", get_system_time () - 86400), false, 10, 5, true);
|
$table->data[3][1] .= print_input_text ('start_time', date ("H:m", get_system_time () - 86400), false, 10, 5, true);
|
||||||
|
|
||||||
//End date selector
|
//End date selector
|
||||||
$table->data[4][0] = '<b>'.__('End date (*)').'</b>';
|
$table->data[4][0] = '<b>'.__('End date').'</b>';
|
||||||
$table->data[4][1] = print_input_text ('end_date', date ("Y-m-d", get_system_time ()), false, 10, 10, true);
|
$table->data[4][1] = print_input_text ('end_date', date ("Y-m-d", get_system_time ()), false, 10, 10, true);
|
||||||
$table->data[4][1] .= print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => 'scwShow(scwID("text-end_date"),this);'));
|
$table->data[4][1] .= print_image ("images/calendar_view_day.png", true, array ("alt" => "calendar", "onclick" => 'scwShow(scwID("text-end_date"),this);'));
|
||||||
$table->data[4][1] .= print_input_text ('end_time', date ("H:m", get_system_time ()), false, 10, 5, true);
|
$table->data[4][1] .= print_input_text ('end_time', date ("H:m", get_system_time ()), false, 10, 5, true);
|
||||||
|
@ -430,11 +430,11 @@ foreach ($result as $event) {
|
|||||||
// Colored box
|
// Colored box
|
||||||
if ($event["estado"] == 0) {
|
if ($event["estado"] == 0) {
|
||||||
$img = "images/tick_off.png";
|
$img = "images/tick_off.png";
|
||||||
$title = __('Event validated');
|
$title = __('Event not validated');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$img = "images/tick.png";
|
$img = "images/tick.png";
|
||||||
$title = __('Event not validated');
|
$title = __('Event validated');
|
||||||
}
|
}
|
||||||
$data[0] = print_image ($img, true,
|
$data[0] = print_image ($img, true,
|
||||||
array ("class" => "image_status",
|
array ("class" => "image_status",
|
||||||
@ -504,7 +504,7 @@ foreach ($result as $event) {
|
|||||||
array ("title" => __('Go to alert overview')));
|
array ("title" => __('Go to alert overview')));
|
||||||
$data[5] .= '</a>';
|
$data[5] .= '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[6] = print_group_icon ($event["id_grupo"], true);
|
$data[6] = print_group_icon ($event["id_grupo"], true);
|
||||||
|
|
||||||
if ($group_rep == 1) {
|
if ($group_rep == 1) {
|
||||||
@ -512,8 +512,8 @@ foreach ($result as $event) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!empty ($event["estado"])) {
|
if (!empty ($event["estado"])) {
|
||||||
if ($event["id_usuario"] != '0' && $event["id_usuario"] != ''){
|
if ($event["id_usuario"] != '0' && $event["id_usuario"] != '' && $event["id_usuario"] != 'system' && $event["id_usuario"] != "System"){
|
||||||
$data[7] = '<a href="index.php?sec=usuario&sec2=operation/user/user_edit&ver='.$event["id_usuario"].'" title="'.dame_nombre_real ($event["id_usuario"]).'">'.mb_substr ($event["id_usuario"],0,8).'</a>';
|
$data[7] = '<a href="index.php?sec=usuarios&sec2=operation/users/user_edit&id='.$event["id_usuario"].'" title="'.dame_nombre_real ($event["id_usuario"]).'">'.mb_substr ($event["id_usuario"],0,8).'</a>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data[7] = __('System');
|
$data[7] = __('System');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user