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
This commit is contained in:
mdtrooper 2012-07-16 09:24:04 +00:00
parent dbf98363f4
commit b967940c41
20 changed files with 826 additions and 723 deletions

View File

@ -1,3 +1,21 @@
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.
2012-07-16 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2012-07-16 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* operation/tree.php: Removed trace. * operation/tree.php: Removed trace.

View File

@ -24,7 +24,7 @@ function mainAgentsAlerts() {
// Load global vars // Load global vars
require_once ("include/config.php"); require_once ("include/config.php");
require_once ("include/functions_reporting.php"); require_once ("include/functions_reporting.php");
check_login (); check_login ();
// ACL Check // ACL Check
if (! check_acl ($config['id_user'], 0, "AR")) { if (! check_acl ($config['id_user'], 0, "AR")) {
@ -33,7 +33,7 @@ function mainAgentsAlerts() {
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; exit;
} }
// Update network modules for this group // Update network modules for this group
// Check for Network FLAG change request // Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side // Made it a subquery, much faster on both the database and server side
@ -50,7 +50,7 @@ function mainAgentsAlerts() {
exit; exit;
} }
} }
if ($config["realtimestats"] == 0) { if ($config["realtimestats"] == 0) {
$updated_info = __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); $updated_info = __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true);
} }
@ -59,14 +59,14 @@ function mainAgentsAlerts() {
} }
$updated_time = html_print_image ("images/information.png", true, array ("title" => __('Last update'), "style" => 'margin: 5px 3px 0px 10px')).$updated_info; $updated_time = html_print_image ("images/information.png", true, array ("title" => __('Last update'), "style" => 'margin: 5px 3px 0px 10px')).$updated_info;
$refr = get_parameter('refr', 30); // By default 30 seconds $refr = get_parameter('refr', 30); // By default 30 seconds
$group_id = get_parameter('group_id', 0); $group_id = get_parameter('group_id', 0);
$offset = get_parameter('offset', 0); $offset = get_parameter('offset', 0);
$hor_offset = get_parameter('hor_offset', 0); $hor_offset = get_parameter('hor_offset', 0);
$block = 20; $block = 20;
$groups = users_get_groups (); $groups = users_get_groups ();
$filter_groups = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">'; $filter_groups = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">';
@ -76,7 +76,13 @@ function mainAgentsAlerts() {
$comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">'; $comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">';
$comborefr .= '<b>'.__('Refresh').'</b>'; $comborefr .= '<b>'.__('Refresh').'</b>';
$comborefr .= html_print_select (array('30' => '30 '.__('seconds'), '60' => '1 '.__('minute'), '120' => '2 '.__('minutes'), '300' => '5 '.__('minutes'), '600' => '10 '.__('minutes')) , 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); $comborefr .= html_print_select (
array('30' => '30 '.__('seconds'),
(string)SECONDS_1MINUTE => __('1 minute'),
(string)SECONDS_2MINUTES => __('2 minutes'),
(string)SECONDS_5MINUTES => __('5 minutes'),
(string)SECONDS_10MINUTES => __('10 minutes'))
, 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;');
$comborefr .= "</form>"; $comborefr .= "</form>";
if ($config["pure"] == 0) { if ($config["pure"] == 0) {
@ -92,38 +98,41 @@ function mainAgentsAlerts() {
} }
$onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen, $onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen,
'combo_groups' => $filter_groups); 'combo_groups' => $filter_groups);
if($config['pure'] == 1) { if ($config['pure'] == 1) {
$onheader['combo_refr'] = $comborefr; $onheader['combo_refr'] = $comborefr;
} }
// Header // Header
ui_print_page_header (__("Agents/Alerts"), "images/bell.png", false, "", false, $onheader); ui_print_page_header (__("Agents/Alerts"), "images/bell.png", false, "", false, $onheader);
// Old style table, we need a lot of special formatting,don't use table function // Old style table, we need a lot of special formatting,don't use table function
// Prepare old-style table // Prepare old-style table
$filter = array ('offset' => (int) $offset, $filter = array ('offset' => (int) $offset,
'limit' => (int) $config['block_size']); 'limit' => (int) $config['block_size']);
$filter_count = array(); $filter_count = array();
if($group_id > 0) { if ($group_id > 0) {
$filter['id_grupo'] = $group_id; $filter['id_grupo'] = $group_id;
$filter_count['id_grupo'] = $group_id; $filter_count['id_grupo'] = $group_id;
} }
// Get the id of all agents with alerts // Get the id of all agents with alerts
$sql = 'SELECT DISTINCT(id_agente) FROM tagente_modulo WHERE id_agente_modulo IN $sql = 'SELECT DISTINCT(id_agente)
(SELECT id_agent_module FROM talert_template_modules)'; FROM tagente_modulo
WHERE id_agente_modulo IN
(SELECT id_agent_module
FROM talert_template_modules)';
$agents_with_alerts_raw = db_get_all_rows_sql($sql); $agents_with_alerts_raw = db_get_all_rows_sql($sql);
if($agents_with_alerts_raw === false) { if ($agents_with_alerts_raw === false) {
$agents_with_alerts_raw = array(); $agents_with_alerts_raw = array();
} }
$agents_with_alerts = array(); $agents_with_alerts = array();
foreach($agents_with_alerts_raw as $awar) { foreach ($agents_with_alerts_raw as $awar) {
$agents_with_alerts[] = $awar['id_agente']; $agents_with_alerts[] = $awar['id_agente'];
} }
@ -131,11 +140,11 @@ function mainAgentsAlerts() {
$filter_count['id_agente'] = $agents_with_alerts; $filter_count['id_agente'] = $agents_with_alerts;
$agents = agents_get_agents ($filter); $agents = agents_get_agents ($filter);
$nagents = count(agents_get_agents ($filter_count)); $nagents = count(agents_get_agents ($filter_count));
if($agents == false) { if ($agents == false) {
echo "<div class='nf'>".__('There are no agents with alerts')."</div>"; echo "<div class='nf'>" . __('There are no agents with alerts')."</div>";
return; return;
} }
@ -147,7 +156,7 @@ function mainAgentsAlerts() {
$templates = array(); $templates = array();
$agent_alerts = array(); $agent_alerts = array();
foreach($all_alerts as $alert) { foreach ($all_alerts as $alert) {
$templates[$alert['id_alert_template']] = ''; $templates[$alert['id_alert_template']] = '';
$agent_alerts[$alert['agent_name']][$alert['id_alert_template']][] = $alert; $agent_alerts[$alert['agent_name']][$alert['id_alert_template']][] = $alert;
} }
@ -158,54 +167,55 @@ function mainAgentsAlerts() {
echo '<table cellpadding="4" cellspacing="4" border="0" width=98%>'; echo '<table cellpadding="4" cellspacing="4" border="0" width=98%>';
echo "<th width='140px' height='25px'>".__("Agents")." / ".__("Alert templates")."</th>"; echo "<th width='140px' height='25px'>".__("Agents")." / ".__("Alert templates")."</th>";
if($hor_offset > 0) { if ($hor_offset > 0) {
$new_hor_offset = $hor_offset-$block; $new_hor_offset = $hor_offset-$block;
echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_alerts&refr=0&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."'>".html_print_image("images/darrowleft.png",true, array('title' => __('Previous templates')))."</a> </th>"; echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_alerts&refr=0&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."'>".html_print_image("images/darrowleft.png",true, array('title' => __('Previous templates')))."</a> </th>";
} }
if(!empty($templates)) { if (!empty($templates)) {
$sql = sprintf('SELECT id, name FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates))); $sql = sprintf('SELECT id, name
FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates)));
$templates_raw = db_get_all_rows_sql($sql); $templates_raw = db_get_all_rows_sql($sql);
} }
$alerts = array(); $alerts = array();
$ntemplates = 0; $ntemplates = 0;
foreach($templates_raw as $temp) { foreach ($templates_raw as $temp) {
if(isset($templates[$temp['id']]) && $templates[$temp['id']] == '') { if (isset($templates[$temp['id']]) && $templates[$temp['id']] == '') {
$ntemplates++; $ntemplates++;
if($ntemplates <= $hor_offset || $ntemplates > ($hor_offset+$block)) { if ($ntemplates <= $hor_offset || $ntemplates > ($hor_offset+$block)) {
continue; continue;
} }
$templates[$temp['id']] = $temp['name']; $templates[$temp['id']] = $temp['name'];
} }
} }
foreach($templates as $tid => $tname) { foreach ($templates as $tid => $tname) {
if($tname == '') { if ($tname == '') {
continue; continue;
} }
echo '<th width="20px" >'. html_print_image('images/information.png', true, array('title' => io_safe_output($tname))) ."</th>"; echo '<th width="20px" >'. html_print_image('images/information.png', true, array('title' => io_safe_output($tname))) ."</th>";
} }
if(($hor_offset + $block) < $ntemplates) { if (($hor_offset + $block) < $ntemplates) {
$new_hor_offset = $hor_offset+$block; $new_hor_offset = $hor_offset+$block;
echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."'>".html_print_image("images/darrowright.png",true, array('title' => __('More templates')))."</a> </th>"; echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_alerts&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."'>".html_print_image("images/darrowright.png",true, array('title' => __('More templates')))."</a> </th>";
} }
foreach($agents as $agent) { foreach ($agents as $agent) {
echo '<tr>'; echo '<tr>';
// Name of the agent // Name of the agent
echo '<td style="font-weight:bold;">'.$agent['nombre'].'</td>'; echo '<td style="font-weight:bold;">'.$agent['nombre'].'</td>';
// Alerts of the agent // Alerts of the agent
$anyfired = false; $anyfired = false;
foreach($templates as $tid => $tname) { foreach ($templates as $tid => $tname) {
if($tname == '') { if ($tname == '') {
continue; continue;
} }
if(isset($agent_alerts[$agent['nombre']][$tid])) { if (isset($agent_alerts[$agent['nombre']][$tid])) {
foreach($agent_alerts[$agent['nombre']][$tid] as $alert) { foreach($agent_alerts[$agent['nombre']][$tid] as $alert) {
if($alert["times_fired"] > 0) { if($alert["times_fired"] > 0) {
$anyfired = true; $anyfired = true;
@ -247,7 +257,7 @@ function print_alerts_summary_modal_window($id, $alerts) {
$table->width = '98%'; $table->width = '98%';
$table->class = "databox"; $table->class = "databox";
$table->data = array (); $table->data = array ();
$table->head[0] = __('Module'); $table->head[0] = __('Module');
$table->head[1] = __('Action'); $table->head[1] = __('Action');
$table->head[2] = __('Last fired'); $table->head[2] = __('Last fired');

View File

@ -24,7 +24,7 @@ function mainAgentsModules() {
// Load global vars // Load global vars
require_once ("include/config.php"); require_once ("include/config.php");
require_once ("include/functions_reporting.php"); require_once ("include/functions_reporting.php");
check_login (); check_login ();
// ACL Check // ACL Check
if (! check_acl ($config['id_user'], 0, "AR")) { if (! check_acl ($config['id_user'], 0, "AR")) {
@ -33,7 +33,7 @@ function mainAgentsModules() {
require ("general/noaccess.php"); require ("general/noaccess.php");
exit; exit;
} }
// Update network modules for this group // Update network modules for this group
// Check for Network FLAG change request // Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side // Made it a subquery, much faster on both the database and server side
@ -50,8 +50,8 @@ function mainAgentsModules() {
exit; exit;
} }
} }
if ($config["realtimestats"] == 0) { if ($config["realtimestats"] == 0) {
$updated_info = __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); $updated_info = __('Last update'). " : ". ui_print_timestamp (db_get_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true);
} }
@ -60,17 +60,17 @@ function mainAgentsModules() {
} }
$updated_time = html_print_image ("images/information.png", true, array ("title" => __('Last update'), "style" => 'margin: 5px 3px 0px 10px')).$updated_info; $updated_time = html_print_image ("images/information.png", true, array ("title" => __('Last update'), "style" => 'margin: 5px 3px 0px 10px')).$updated_info;
$modulegroup = get_parameter('modulegroup', 0); $modulegroup = get_parameter('modulegroup', 0);
$refr = get_parameter('refr', 30); // By default 30 seconds $refr = get_parameter('refr', 30); // By default 30 seconds
$group_id = get_parameter('group_id', 0); $group_id = get_parameter('group_id', 0);
$offset = get_parameter('offset', 0); $offset = get_parameter('offset', 0);
$hor_offset = get_parameter('hor_offset', 0); $hor_offset = get_parameter('hor_offset', 0);
$block = 20; $block = 20;
$groups = users_get_groups (); $groups = users_get_groups ();
$filter_module_groups = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">'; $filter_module_groups = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">';
$filter_module_groups .= '<b>'.__('Module group').'</b>'; $filter_module_groups .= '<b>'.__('Module group').'</b>';
$filter_module_groups .= html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name", $filter_module_groups .= html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name",
@ -84,7 +84,13 @@ function mainAgentsModules() {
$comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">'; $comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">';
$comborefr .= '<b>'.__('Refresh').'</b>'; $comborefr .= '<b>'.__('Refresh').'</b>';
$comborefr .= html_print_select (array('30' => '30 '.__('seconds'), '60' => '1 '.__('minute'), '120' => '2 '.__('minutes'), '300' => '5 '.__('minutes'), '600' => '10 '.__('minutes')) , 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); $comborefr .= html_print_select (
array('30' => '30 '.__('seconds'),
(string)SECONDS_1MINUTE => __('1 minute'),
(string)SECONDS_2MINUTES => __('2 minutes'),
(string)SECONDS_5MINUTES => __('5 minutes'),
(string)SECONDS_10MINUTES => __('10 minutes')),
'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;');
$comborefr .= "</form>"; $comborefr .= "</form>";
if ($config["pure"] == 0) { if ($config["pure"] == 0) {
@ -100,37 +106,37 @@ function mainAgentsModules() {
} }
$onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen, $onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen,
'combo_module_groups' => $filter_module_groups, 'combo_module_groups' => $filter_module_groups,
'combo_groups' => $filter_groups); 'combo_groups' => $filter_groups);
if($config['pure'] == 1) { if ($config['pure'] == 1) {
$onheader['combo_refr'] = $comborefr; $onheader['combo_refr'] = $comborefr;
} }
// Header // Header
ui_print_page_header (__("Agents/Modules"), "images/bricks.png", false, "", false, $onheader); ui_print_page_header (__("Agents/Modules"), "images/bricks.png", false, "", false, $onheader);
// Old style table, we need a lot of special formatting,don't use table function // Old style table, we need a lot of special formatting,don't use table function
// Prepare old-style table // Prepare old-style table
$agents = ''; $agents = '';
if($group_id > 0) { if ($group_id > 0) {
$agents = agents_get_group_agents($group_id); $agents = agents_get_group_agents($group_id);
$agents = array_keys($agents); $agents = array_keys($agents);
} }
$filter_module_groups = false; $filter_module_groups = false;
if($modulegroup > 0) { if ($modulegroup > 0) {
$filter_module_groups['id_module_group'] = $modulegroup; $filter_module_groups['id_module_group'] = $modulegroup;
} }
$all_modules = agents_get_modules($agents, false, $filter_module_groups, true, false); $all_modules = agents_get_modules($agents, false, $filter_module_groups, true, false);
$modules_by_name = array(); $modules_by_name = array();
$name = ''; $name = '';
$cont = 0; $cont = 0;
foreach($all_modules as $key => $module) { foreach($all_modules as $key => $module) {
if($module == $name) { if($module == $name) {
$modules_by_name[$cont-1]['id'][] = $key; $modules_by_name[$cont-1]['id'][] = $key;
@ -146,10 +152,10 @@ function mainAgentsModules() {
if($config["pure"] == 1) { if($config["pure"] == 1) {
$block = count($modules_by_name); $block = count($modules_by_name);
} }
$filter_groups = array ('offset' => (int) $offset, $filter_groups = array ('offset' => (int) $offset,
'limit' => (int) $config['block_size']); 'limit' => (int) $config['block_size']);
if($group_id > 0) { if($group_id > 0) {
$filter_groups['id_grupo'] = $group_id; $filter_groups['id_grupo'] = $group_id;
} }
@ -171,10 +177,10 @@ function mainAgentsModules() {
echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_modules&refr=0&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."&modulegroup=".$modulegroup."'>".html_print_image("images/darrowleft.png",true, array('title' => __('Previous modules')))."</a> </th>"; echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_modules&refr=0&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."&modulegroup=".$modulegroup."'>".html_print_image("images/darrowleft.png",true, array('title' => __('Previous modules')))."</a> </th>";
} }
$nmodules = 0; $nmodules = 0;
foreach($modules_by_name as $module) { foreach ($modules_by_name as $module) {
$nmodules++; $nmodules++;
if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) { if ($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) {
continue; continue;
} }
@ -265,9 +271,9 @@ function mainAgentsModules() {
echo '</a>'; echo '</a>';
echo "</td>"; echo "</td>";
$match = true; $match = true;
} }
} }
if(!$match) { if(!$match) {
echo "<td></td>"; echo "<td></td>";
} }
@ -275,7 +281,7 @@ function mainAgentsModules() {
echo "</tr>"; echo "</tr>";
} }
echo "</table>"; echo "</table>";
echo "<br><br><p>" . __("The colours meaning:") . echo "<br><br><p>" . __("The colours meaning:") .
@ -307,5 +313,4 @@ function mainAgentsModules() {
extensions_add_operation_menu_option(__("Agents/Modules view"), 'estado', 'agents_modules/icon_menu.png'); extensions_add_operation_menu_option(__("Agents/Modules view"), 'estado', 'agents_modules/icon_menu.png');
extensions_add_main_function('mainAgentsModules'); extensions_add_main_function('mainAgentsModules');
?> ?>

View File

@ -29,28 +29,31 @@ function users_extension_main_god ($god = true) {
// Header // Header
ui_print_page_header (__("Users connected"), "images/group.png", false, "", $god); ui_print_page_header (__("Users connected"), "images/group.png", false, "", $god);
// Get user conected last 5 minutes // Get user conected last 5 minutes
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$sql = "SELECT id_user, last_connect $sql = "SELECT id_user, last_connect
FROM tusuario FROM tusuario
WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - 300) ORDER BY last_connect DESC"; WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - " . SECONDS_5MINUTES . ")
ORDER BY last_connect DESC";
break; break;
case "postgresql": case "postgresql":
$sql = "SELECT id_user, last_connect $sql = "SELECT id_user, last_connect
FROM tusuario FROM tusuario
WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - 300) ORDER BY last_connect DESC"; WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_5MINUTES . ")
ORDER BY last_connect DESC";
break; break;
case "oracle": case "oracle":
$sql = "SELECT id_user, last_connect $sql = "SELECT id_user, last_connect
FROM tusuario FROM tusuario
WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - 300) ORDER BY last_connect DESC"; WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_5MINUTES . ")
ORDER BY last_connect DESC";
break; break;
} }
$rows = db_get_all_rows_sql ($sql); $rows = db_get_all_rows_sql ($sql);
if (empty ($rows)) { if (empty ($rows)) {
$rows = array (); $rows = array ();
echo "<div class='nf'>".__('No other users connected')."</div>"; echo "<div class='nf'>".__('No other users connected')."</div>";
@ -63,14 +66,14 @@ function users_extension_main_god ($god = true) {
$table->size = array (); $table->size = array ();
$table->data = array (); $table->data = array ();
$table->head = array (); $table->head = array ();
$table->head[0] = __('User'); $table->head[0] = __('User');
$table->head[1] = __('IP'); $table->head[1] = __('IP');
$table->head[2] = __('Date'); $table->head[2] = __('Date');
$rowPair = true; $rowPair = true;
$iterator = 0; $iterator = 0;
// Get data // Get data
foreach ($rows as $row) { foreach ($rows as $row) {
// Get ip_origin of the last login of the user // Get ip_origin of the last login of the user
@ -78,34 +81,34 @@ function users_extension_main_god ($god = true) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
$ip_origin = db_get_value_sql(sprintf("SELECT ip_origen $ip_origin = db_get_value_sql(sprintf("SELECT ip_origen
FROM tsesion FROM tsesion
WHERE id_usuario = '%s' WHERE id_usuario = '%s'
AND descripcion = '" . io_safe_input('Logged in') . "' AND descripcion = '" . io_safe_input('Logged in') . "'
ORDER BY fecha DESC",$row["id_user"])); ORDER BY fecha DESC",$row["id_user"]));
break; break;
case "oracle": case "oracle":
$ip_origin = db_get_value_sql(sprintf("SELECT ip_origen $ip_origin = db_get_value_sql(sprintf("SELECT ip_origen
FROM tsesion FROM tsesion
WHERE id_usuario = '%s' WHERE id_usuario = '%s'
AND to_char(descripcion) = '" . io_safe_input('Logged in') . "' AND to_char(descripcion) = '" . io_safe_input('Logged in') . "'
ORDER BY fecha DESC",$row["id_user"])); ORDER BY fecha DESC",$row["id_user"]));
break; break;
} }
if ($rowPair) if ($rowPair)
$table->rowclass[$iterator] = 'rowPair'; $table->rowclass[$iterator] = 'rowPair';
else else
$table->rowclass[$iterator] = 'rowOdd'; $table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair; $rowPair = !$rowPair;
$iterator++; $iterator++;
$data = array (); $data = array ();
$data[0] = '<a href="index.php?sec=gusuarios&amp;sec2=godmode/users/configure_user&amp;id='.$row["id_user"].'">'.$row["id_user"].'</a>'; $data[0] = '<a href="index.php?sec=gusuarios&amp;sec2=godmode/users/configure_user&amp;id='.$row["id_user"].'">'.$row["id_user"].'</a>';
$data[1] = $ip_origin; $data[1] = $ip_origin;
$data[2] = date($config["date_format"], $row['last_connect']); $data[2] = date($config["date_format"], $row['last_connect']);
array_push ($table->data, $data); array_push ($table->data, $data);
} }
html_print_table ($table); html_print_table ($table);
} }
} }

View File

@ -34,9 +34,10 @@ config_check();
<td rowspan="2"> <td rowspan="2">
<a href="index.php?sec=main"> <a href="index.php?sec=main">
<?php <?php
if (!defined ('PANDORA_ENTERPRISE')){ if (!defined ('PANDORA_ENTERPRISE')) {
echo html_print_image('images/pandora_header_logo.png', true, array("alt" => 'Pandora FMS Opensource', "border" => '0')); echo html_print_image('images/pandora_header_logo.png', true, array("alt" => 'Pandora FMS Opensource', "border" => '0'));
} else { }
else {
echo html_print_image('images/pandora_header_logo_enterprise.png', true, array("alt" => 'Pandora FMS Enterprise', "border" => '0')); echo html_print_image('images/pandora_header_logo_enterprise.png', true, array("alt" => 'Pandora FMS Enterprise', "border" => '0'));
} }
?> ?>
@ -95,14 +96,14 @@ config_check();
echo ui_print_help_icon ("main_help", true); echo ui_print_help_icon ("main_help", true);
if ($config['metaconsole'] == 1) { if ($config['metaconsole'] == 1) {
echo "&nbsp;"; echo "&nbsp;";
echo "&nbsp;"; echo "&nbsp;";
html_print_image("images/application_double.png", false, array("alt" => __('Metaconsole activated'), "class" => 'bot', "title" => __('You are using metaconsole'))); html_print_image("images/application_double.png", false, array("alt" => __('Metaconsole activated'), "class" => 'bot', "title" => __('You are using metaconsole')));
} }
?>
echo '</td>'; </td>
echo '<td width="20%">'; <td width="20%">
<?php
if ($config["metaconsole"] == 0){ if ($config["metaconsole"] == 0) {
echo '<a class="white_bold" href="index.php?sec=gservers&amp;sec2=godmode/servers/modificar_server&amp;refr=60">'; echo '<a class="white_bold" href="index.php?sec=gservers&amp;sec2=godmode/servers/modificar_server&amp;refr=60">';
$servers["all"] = (int) db_get_value ('COUNT(id_server)','tserver'); $servers["all"] = (int) db_get_value ('COUNT(id_server)','tserver');
@ -123,8 +124,7 @@ config_check();
unset ($servers); // Since this is the header, we don't like to trickle down variables. unset ($servers); // Since this is the header, we don't like to trickle down variables.
echo '</a>'; echo '</a>';
} }
?>
?>
</td> </td>
<td width="20%"> <td width="20%">
<?php <?php
@ -140,82 +140,76 @@ config_check();
$ignored_params['refr'] = ''; $ignored_params['refr'] = '';
echo '<a id="autorefresh" class="white_bold" href="' . ui_get_url_refresh ($ignored_params).'">' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . '&nbsp;'. __('Autorefresh').'</a>'; echo '<a id="autorefresh" class="white_bold" href="' . ui_get_url_refresh ($ignored_params).'">' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . '&nbsp;'. __('Autorefresh').'</a>';
$values = array ( $values = array (
'5' => '5 '.__('seconds'), '5' => __('5 seconds'),
'10' => '10 '.__('seconds'), '10' => __('10 seconds'),
'15' => '15 '.__('seconds'), '15' => __('15 seconds'),
'30' => '30 '.__('seconds'), '30' => __('30 seconds'),
'60' => '1 '.__('minute'), (string)SECONDS_1MINUTE => __('1 minute'),
'120' => '2 '.__('minutes'), (string)SECONDS_2MINUTES => __('2 minutes'),
'300' => '5 '.__('minutes'), (string)SECONDS_5MINUTES => __('5 minutes'),
'900' => '15 '.__('minutes'), (string)SECONDS_15MINUTES => __('15 minutes'),
'1800' => '30 '.__('minutes'), (string)SECONDS_30MINUTES => __('30 minutes'),
'3600' => '1 '.__('hour')); (string)SECONDS_1HOUR => __('1 hour'));
echo '<span id="combo_refr" style="display: none">'; echo '<span id="combo_refr" style="display: none">';
html_print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false); html_print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false);
unset ($values); unset ($values);
echo '</span>'; echo '</span>';
} }
echo "</td>"; ?>
echo "<td width='20%' rowspan='2'>"; </td>
echo "<a href='index.php?sec=main'>"; <td width='20%' rowspan='2'>
if (isset($config["custom_logo"])) <?php
echo html_print_image("images/custom_logo/" . $config["custom_logo"], true,array("height" => '60', "width" => '139', "alt" => 'Logo')); echo "<a href='index.php?sec=main'>";
echo "</a>"; if (isset($config["custom_logo"]))
?> echo html_print_image("images/custom_logo/" . $config["custom_logo"], true,array("height" => '60', "width" => '139', "alt" => 'Logo'));
echo "</a>";
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<?php <?php
if ($config["metaconsole"] == 0){ if ($config["metaconsole"] == 0) {
?> ?>
<form method="get" style="" name="quicksearch" action=""> <form method="get" style="" name="quicksearch" action="">
<script type="text/javascript"> <script type="text/javascript">
var fieldKeyWordEmpty = true; var fieldKeyWordEmpty = true;
</script> </script>
<input type="text" id="keywords" name="keywords" <input type="text" id="keywords" name="keywords"
<?php
if (!isset($config['search_keywords']))
echo "value='" . __("Enter keywords to search") . "'";
else if (strlen($config['search_keywords']) == 0)
echo "value='" . __("Enter keywords to search") . "'";
else echo "value='" . $config['search_keywords'] . "'";
?>
onfocus="javascript: if (fieldKeyWordEmpty) $('#keywords').val('');"
size="100" style="background: white url('images/lupa_15x15.png') no-repeat right; padding: 0; padding-left:0px; margin: 0; width: 90%; height: 19px; margin-bottom: 5px; margin-left: 2px;" />
<!-- onClick="javascript: document.quicksearch.submit()" -->
<input type='hidden' name='head_search_keywords' value='abc' />
<?php <?php
if (!isset($config['search_keywords'])) ui_print_help_tip (__("Blank characters are used as AND conditions"));
echo "value='" . __("Enter keywords to search") . "'";
else if (strlen($config['search_keywords']) == 0)
echo "value='" . __("Enter keywords to search") . "'";
else echo "value='" . $config['search_keywords'] . "'";
?> ?>
onfocus="javascript: if (fieldKeyWordEmpty) $('#keywords').val('');" </form>
size="100" style="background: white url('images/lupa_15x15.png') no-repeat right; padding: 0; padding-left:0px; margin: 0; width: 90%; height: 19px; margin-bottom: 5px; margin-left: 2px;" />
<!-- onClick="javascript: document.quicksearch.submit()" -->
<input type='hidden' name='head_search_keywords' value='abc' />
<?php
ui_print_help_tip (__("Blank characters are used as AND conditions"));
?>
</form>
<?php <?php
} }
?> ?>
</td> </td>
<td> <td>
<?php <?php
if ($config["metaconsole"] == 0){ if ($config["metaconsole"] == 0){
echo '<a class="white_bold" href="index.php?sec=eventos&amp;sec2=operation/events/events">' . html_print_image("images/lightning_go.png", true, array("alt" => 'lightning_go', "class" => 'bot')) . '&nbsp;'.__('Events').'</a>'; echo '<a class="white_bold" href="index.php?sec=eventos&amp;sec2=operation/events/events">' . html_print_image("images/lightning_go.png", true, array("alt" => 'lightning_go', "class" => 'bot')) . '&nbsp;'.__('Events').'</a>';
} }
?> ?>
</td> </td>
</tr> </tr>
</table> </table>
<?php <?php
ui_require_jquery_file ('countdown'); ui_require_jquery_file ('countdown');
ui_require_css_file ('jquery-ui-1.8.17.custom'); ui_require_css_file ('jquery-ui-1.8.17.custom');
ui_require_jquery_file('jquery-ui-1.8.17.custom.min'); ui_require_jquery_file('jquery-ui-1.8.17.custom.min');
?> ?>
<!--
<script type="text/javascript" src="include/javascript/jquery.ui.dialog.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.draggable.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.droppable.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.resizable.js "></script>
-->
<script type="text/javascript" src="include/javascript/webchat.js "></script> <script type="text/javascript" src="include/javascript/webchat.js "></script>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
var new_chat = <?php echo (int)$_SESSION['new_chat'];?>; var new_chat = <?php echo (int)$_SESSION['new_chat'];?>;
@ -230,13 +224,28 @@ if ($config["metaconsole"] == 0){
$("#agent_access").css("display",""); $("#agent_access").css("display","");
}); });
<?php if ($msg_cnt > 0): ?>
<?php
if ($msg_cnt > 0) {
?>
$("#yougotmail").pulsate (); $("#yougotmail").pulsate ();
<?php endif; ?> <?php
<?php if ($config["alert_cnt"] > 0): ?> }
?>
<?php
if ($config["alert_cnt"] > 0) {
?>
$("#yougotalert").pulsate (); $("#yougotalert").pulsate ();
<?php endif; ?> <?php
<?php if ($config["refr"]): ?> }
?>
<?php
if ($config["refr"]) {
?>
t = new Date(); t = new Date();
t.setTime (t.getTime () + <?php echo $config["refr"] * 1000; ?>); t.setTime (t.getTime () + <?php echo $config["refr"] * 1000; ?>);
$("#refrcounter").countdown ({until: t, $("#refrcounter").countdown ({until: t,
@ -246,7 +255,10 @@ if ($config["metaconsole"] == 0){
$(this).text ("..."); $(this).text ("...");
} }
}); });
<?php else: ?> <?php
}
else {
?>
$("a#autorefresh").click (function () { $("a#autorefresh").click (function () {
var a = this; var a = this;
@ -259,7 +271,9 @@ if ($config["metaconsole"] == 0){
return false; return false;
}); });
<?php endif; ?> <?php
}
?>
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -62,7 +62,7 @@ $maximo = 0;
$minimo = 0; $minimo = 0;
$nombre_agente = ""; $nombre_agente = "";
$direccion_agente = get_parameter ('direccion', ''); $direccion_agente = get_parameter ('direccion', '');
$intervalo = 300; $intervalo = SECONDS_5MINUTES;
$ff_interval = 0; $ff_interval = 0;
$id_server = ""; $id_server = "";
$max_alerts = 0; $max_alerts = 0;
@ -131,7 +131,7 @@ if ($create_agent) {
$nombre_agente = (string) get_parameter_post ("agente",''); $nombre_agente = (string) get_parameter_post ("agente",'');
$direccion_agente = (string) get_parameter_post ("direccion",''); $direccion_agente = (string) get_parameter_post ("direccion",'');
$grupo = (int) get_parameter_post ("grupo"); $grupo = (int) get_parameter_post ("grupo");
$intervalo = (string) get_parameter_post ("intervalo", 300); $intervalo = (string) get_parameter_post ("intervalo", SECONDS_5MINUTES);
$comentarios = (string) get_parameter_post ("comentarios", ''); $comentarios = (string) get_parameter_post ("comentarios", '');
$modo = (int) get_parameter_post ("modo"); $modo = (int) get_parameter_post ("modo");
$id_parent = (string) get_parameter_post ("id_parent",''); $id_parent = (string) get_parameter_post ("id_parent",'');
@ -144,25 +144,26 @@ if ($create_agent) {
$icon_path = (string) get_parameter_post ("icon_path",''); $icon_path = (string) get_parameter_post ("icon_path",'');
$update_gis_data = (int) get_parameter_post("update_gis_data", 0); $update_gis_data = (int) get_parameter_post("update_gis_data", 0);
$url_description = (string) get_parameter("url_description"); $url_description = (string) get_parameter("url_description");
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array(); if ($fields === false) $fields = array();
$field_values = array(); $field_values = array();
foreach($fields as $field) { foreach ($fields as $field) {
$field_values[$field['id_field']] = (string) get_parameter_post ('customvalue_'.$field['id_field'], ''); $field_values[$field['id_field']] = (string) get_parameter_post ('customvalue_'.$field['id_field'], '');
} }
// Check if agent exists (BUG WC-50518-2) // Check if agent exists (BUG WC-50518-2)
if ($nombre_agente == "") { if ($nombre_agente == "") {
$agent_creation_error = __('No agent name specified'); $agent_creation_error = __('No agent name specified');
$agent_created_ok = 0; $agent_created_ok = 0;
} }
elseif (agents_get_agent_id ($nombre_agente)) { elseif (agents_get_agent_id ($nombre_agente)) {
$agent_creation_error = __('There is already an agent in the database with this name'); $agent_creation_error =
__('There is already an agent in the database with this name');
$agent_created_ok = 0; $agent_created_ok = 0;
} }
else { else {
@ -181,7 +182,7 @@ if ($create_agent) {
enterprise_hook ('update_agent', array ($id_agente)); enterprise_hook ('update_agent', array ($id_agente));
if ($id_agente !== false) { if ($id_agente !== false) {
// Create custom fields for this agent // Create custom fields for this agent
foreach($field_values as $key => $value) { foreach ($field_values as $key => $value) {
db_process_sql_insert ('tagent_custom_data', db_process_sql_insert ('tagent_custom_data',
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value)); array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
} }
@ -189,7 +190,7 @@ if ($create_agent) {
agents_add_address ($id_agente, $direccion_agente); agents_add_address ($id_agente, $direccion_agente);
$agent_created_ok = true; $agent_created_ok = true;
$info = 'Name: ' . $nombre_agente . ' IP: ' . $direccion_agente . $info = 'Name: ' . $nombre_agente . ' IP: ' . $direccion_agente .
' Group: ' . $grupo . ' Interval: ' . $intervalo . ' Group: ' . $grupo . ' Interval: ' . $intervalo .
' Comments: ' . $comentarios . ' Mode: ' . $modo . ' Comments: ' . $comentarios . ' Mode: ' . $modo .
@ -217,72 +218,71 @@ if ($id_agente) {
/* View tab */ /* View tab */
$viewtab['text'] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">' $viewtab['text'] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/zoom.png", true, array ("title" =>__('View'))) . html_print_image ("images/zoom.png", true, array ("title" =>__('View')))
. '</a>'; . '</a>';
if($tab == 'view') if ($tab == 'view')
$viewtab['active'] = true; $viewtab['active'] = true;
else else
$viewtab['active'] = false; $viewtab['active'] = false;
/* Main tab */ /* Main tab */
$maintab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;id_agente='.$id_agente.'">' $maintab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/cog.png", true, array ("title" =>__('Setup'))) . html_print_image ("images/cog.png", true, array ("title" =>__('Setup')))
. '</a>'; . '</a>';
if($tab == 'main') if ($tab == 'main')
$maintab['active'] = true; $maintab['active'] = true;
else else
$maintab['active'] = false; $maintab['active'] = false;
/* Module tab */ /* Module tab */
$moduletab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">' $moduletab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/brick.png", true, array ("title" =>__('Modules'))) . html_print_image ("images/brick.png", true, array ("title" =>__('Modules')))
. '</a>'; . '</a>';
if($tab == 'module') if($tab == 'module')
$moduletab['active'] = true; $moduletab['active'] = true;
else else
$moduletab['active'] = false; $moduletab['active'] = false;
/* Alert tab */ /* Alert tab */
$alerttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">' $alerttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/bell.png", true, array ("title" =>__('Alerts'))) . html_print_image ("images/bell.png", true, array ("title" =>__('Alerts')))
. '</a>'; . '</a>';
if($tab == 'alert') if ($tab == 'alert')
$alerttab['active'] = true; $alerttab['active'] = true;
else else
$alerttab['active'] = false; $alerttab['active'] = false;
/* Template tab */ /* Template tab */
$templatetab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=template&amp;id_agente='.$id_agente.'">' $templatetab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=template&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/network.png", true, array ("title" =>__('Module templates'))) . html_print_image ("images/network.png", true, array ("title" =>__('Module templates')))
. '</a>'; . '</a>';
if($tab == 'template') if ($tab == 'template')
$templatetab['active'] = true; $templatetab['active'] = true;
else else
$templatetab['active'] = false; $templatetab['active'] = false;
/* Inventory */ /* Inventory */
$inventorytab = enterprise_hook ('inventory_tab'); $inventorytab = enterprise_hook ('inventory_tab');
if ($inventorytab == -1) if ($inventorytab == -1)
$inventorytab = ""; $inventorytab = "";
/* Collection */ /* Collection */
$collectiontab = enterprise_hook('collection_tab'); $collectiontab = enterprise_hook('collection_tab');
if ($collectiontab == -1) if ($collectiontab == -1)
$collectiontab = ""; $collectiontab = "";
/* Group tab */ /* Group tab */
$grouptab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group.'">' $grouptab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group.'">'
. html_print_image ("images/agents_group.png", true, array( "title" => __('Group'))) . html_print_image ("images/agents_group.png", true, array( "title" => __('Group')))
. '</a>'; . '</a>';
$grouptab['active'] = false; $grouptab['active'] = false;
@ -294,7 +294,7 @@ if ($id_agente) {
$gistab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente.'">' $gistab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente.'">'
. html_print_image ("images/world.png", true, array ( "title" => __('GIS data'))) . html_print_image ("images/world.png", true, array ( "title" => __('GIS data')))
. '</a>'; . '</a>';
if ($tab == "gis") if ($tab == "gis")
$gistab['active'] = true; $gistab['active'] = true;
else else
@ -304,27 +304,34 @@ if ($id_agente) {
$total_incidents = agents_get_count_incidents($id_agente); $total_incidents = agents_get_count_incidents($id_agente);
/* Incident tab */ /* Incident tab */
if ($config['integria_enabled'] == 0 and $total_incidents > 0){ if ($config['integria_enabled'] == 0 and $total_incidents > 0) {
$incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=incident&amp;id_agente='.$id_agente.'">' $incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=incident&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents'))) . html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>'; . '</a>';
if($tab == 'incident') if ($tab == 'incident')
$incidenttab['active'] = true; $incidenttab['active'] = true;
else else
$incidenttab['active'] = false; $incidenttab['active'] = false;
} }
$onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab, $onheader = array('view' => $viewtab,
'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab, 'separator' => "",
'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab); 'main' => $maintab,
'module' => $moduletab,
'alert' => $alerttab,
'template' => $templatetab,
'inventory' => $inventorytab,
'collection'=> $collectiontab,
'group' => $grouptab,
'gis' => $gistab);
// Only if the agent has incidents associated show incidents tab // Only if the agent has incidents associated show incidents tab
if ($total_incidents){ if ($total_incidents) {
$onheader['incident'] = $incidenttab; $onheader['incident'] = $incidenttab;
} }
foreach($config['extensions'] as $extension) { foreach ($config['extensions'] as $extension) {
if (isset($extension['extension_god_tab'])) { if (isset($extension['extension_god_tab'])) {
$image = $extension['extension_god_tab']['icon']; $image = $extension['extension_god_tab']['icon'];
$name = $extension['extension_god_tab']['name']; $name = $extension['extension_god_tab']['name'];
@ -343,7 +350,7 @@ if ($id_agente) {
$extension_tab = array('text' => '<a href="' . $url .'">' . html_print_image ($image, true, array ( "title" => $name)) . '</a>', 'active' => $active); $extension_tab = array('text' => '<a href="' . $url .'">' . html_print_image ($image, true, array ( "title" => $name)) . '</a>', 'active' => $active);
$onheader = $onheader + array($id => $extension_tab); $onheader = $onheader + array($id => $extension_tab);
} }
} }
@ -357,7 +364,7 @@ if ($id_agente) {
break; break;
case "inventory": case "inventory":
$tab_description = '- ' . __('Inventory') . ui_print_help_icon('inventory_tab', true); $tab_description = '- ' . __('Inventory') . ui_print_help_icon('inventory_tab', true);
break; break;
case "module": case "module":
$tab_description = '- '. __('Modules'); $tab_description = '- '. __('Modules');
break; break;
@ -366,19 +373,20 @@ if ($id_agente) {
break; break;
case "template": case "template":
$tab_description = '- ' . __('Templates') . ui_print_help_icon('template_tab', true); $tab_description = '- ' . __('Templates') . ui_print_help_icon('template_tab', true);
break; break;
case "gis": case "gis":
$tab_description = '- ' . __('Gis') . ui_print_help_icon('gis_tab', true); $tab_description = '- ' . __('Gis') . ui_print_help_icon('gis_tab', true);
break; break;
case "incident": case "incident":
$tab_description = '- ' . __('Incidents'); $tab_description = '- ' . __('Incidents');
break; break;
case "extension": case "extension":
$id_extension = get_parameter('id_extension', ''); $id_extension = get_parameter('id_extension', '');
switch ($id_extension){ switch ($id_extension) {
case "snmp_explorer": case "snmp_explorer":
$tab_description = '- ' . __('SNMP explorer') . ui_print_help_icon('snmp_explorer', true); $tab_description = '- ' . __('SNMP explorer') . ui_print_help_icon('snmp_explorer', true);
} break;
}
break; break;
default: default:
break; break;
@ -401,12 +409,12 @@ if ($delete_conf_file) {
if (isset ($config["remote_config"])) { if (isset ($config["remote_config"])) {
$agent_md5 = md5 (agents_get_name ($id_agente,'none'), FALSE); $agent_md5 = md5 (agents_get_name ($id_agente,'none'), FALSE);
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { if (file_exists ($config["remote_config"] . "/md5/" . $agent_md5 . ".md5")) {
// Agent remote configuration editor // Agent remote configuration editor
$file_name = $config["remote_config"]."/conf/".$agent_md5.".conf"; $file_name = $config["remote_config"] . "/conf/" . $agent_md5 . ".conf";
$correct = @unlink ($file_name); $correct = @unlink ($file_name);
$file_name = $config["remote_config"]."/md5/".$agent_md5.".md5"; $file_name = $config["remote_config"] . "/md5/" . $agent_md5 . ".md5";
$correct = @unlink ($file_name); $correct = @unlink ($file_name);
} }
} }
@ -440,7 +448,7 @@ if (isset( $_GET["fix_module"])) {
} }
else { else {
$result = false; $result = false;
$error = " - ".__('No data to normalize'); $error = " - " . __('No data to normalize');
} }
ui_print_result_message ($result, ui_print_result_message ($result,
@ -465,7 +473,7 @@ if ($update_agent) { // if modified some agent paramenter
$direccion_agente = $address_list; $direccion_agente = $address_list;
} }
$grupo = (int) get_parameter_post ("grupo", 0); $grupo = (int) get_parameter_post ("grupo", 0);
$intervalo = (int) get_parameter_post ("intervalo", 300); $intervalo = (int) get_parameter_post ("intervalo", SECONDS_5MINUTES);
$comentarios = str_replace('`','&lsquo;',(string) get_parameter_post ("comentarios", "")); $comentarios = str_replace('`','&lsquo;',(string) get_parameter_post ("comentarios", ""));
$modo = (bool) get_parameter_post ("modo", 0); //Mode: Learning or Normal $modo = (bool) get_parameter_post ("modo", 0); //Mode: Learning or Normal
$id_os = (int) get_parameter_post ("id_os"); $id_os = (int) get_parameter_post ("id_os");
@ -481,42 +489,45 @@ if ($update_agent) { // if modified some agent paramenter
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array(); if ($fields === false) $fields = array();
$field_values = array(); $field_values = array();
foreach($fields as $field) { foreach ($fields as $field) {
$field_values[$field['id_field']] = (string) get_parameter_post ('customvalue_'.$field['id_field'], ''); $field_values[$field['id_field']] = (string) get_parameter_post ('customvalue_'.$field['id_field'], '');
} }
foreach($field_values as $key => $value) { foreach ($field_values as $key => $value) {
$old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agente, 'id_field' => $key)); $old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agente, 'id_field' => $key));
if($old_value === false) { if ($old_value === false) {
// Create custom field if not exist // Create custom field if not exist
db_process_sql_insert ('tagent_custom_data', db_process_sql_insert ('tagent_custom_data',
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value)); array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
} }
else { else {
db_process_sql_update ('tagent_custom_data', db_process_sql_update ('tagent_custom_data',
array('description' => $value), array('description' => $value),
array('id_field' => $key,'id_agent' => $id_agente)); array('id_field' => $key,'id_agent' => $id_agente));
} }
} }
//Verify if there is another agent with the same name but different ID //Verify if there is another agent with the same name but different ID
if ($nombre_agente == "") { if ($nombre_agente == "") {
echo '<h3 class="error">'.__('No agent name specified').'</h3>'; ui_print_error_message(__('No agent name specified'));
//If there is an agent with the same name, but a different ID //If there is an agent with the same name, but a different ID
} }
elseif (agents_get_agent_id ($nombre_agente) > 0 && agents_get_agent_id ($nombre_agente) != $id_agente) { elseif (agents_get_agent_id ($nombre_agente) > 0 &&
echo '<h3 class="error">'.__('There is already an agent in the database with this name').'</h3>'; agents_get_agent_id ($nombre_agente) != $id_agente) {
ui_print_error_message(__('There is already an agent in the database with this name'));
} }
else { else {
//If different IP is specified than previous, add the IP //If different IP is specified than previous, add the IP
if ($direccion_agente != '' && $direccion_agente != agents_get_address ($id_agente)) if ($direccion_agente != '' &&
$direccion_agente != agents_get_address ($id_agente)) {
agents_add_address ($id_agente, $direccion_agente); agents_add_address ($id_agente, $direccion_agente);
}
//If IP is set for deletion, delete first //If IP is set for deletion, delete first
if (isset ($_POST["delete_ip"])) { if (isset ($_POST["delete_ip"])) {
@ -543,7 +554,8 @@ if ($update_agent) { // if modified some agent paramenter
array ('id_agente' => $id_agente)); array ('id_agente' => $id_agente));
if ($result === false) { if ($result === false) {
ui_print_error_message (__('There was a problem updating the agent')); ui_print_error_message(
__('There was a problem updating the agent'));
} }
else { else {
$info = 'Group: ' . $grupo . ' Interval: ' . $intervalo . $info = 'Group: ' . $grupo . ' Interval: ' . $intervalo .
@ -558,7 +570,6 @@ if ($update_agent) { // if modified some agent paramenter
ui_print_success_message (__('Successfully updated')); ui_print_success_message (__('Successfully updated'));
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Updated agent $nombre_agente", false, false, $info); "Updated agent $nombre_agente", false, false, $info);
} }
} }
} }
@ -569,8 +580,8 @@ if ($id_agente) {
//This has been done in the beginning of the page, but if an agent was created, this id might change //This has been done in the beginning of the page, but if an agent was created, this id might change
$id_grupo = agents_get_agent_group ($id_agente); $id_grupo = agents_get_agent_group ($id_agente);
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
if($is_extra === ENTERPRISE_NOT_HOOK) { if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false; $is_extra = false;
} }
if (!check_acl ($config["id_user"], $id_grupo, "AW") && !$is_extra) { if (!check_acl ($config["id_user"], $id_grupo, "AW") && !$is_extra) {
@ -616,8 +627,8 @@ if ($update_module || $create_module) {
$id_grupo = agents_get_agent_group ($id_agente); $id_grupo = agents_get_agent_group ($id_agente);
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
if($is_extra === ENTERPRISE_NOT_HOOK) { if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false; $is_extra = false;
} }
@ -632,7 +643,7 @@ if ($update_module || $create_module) {
$description = (string) get_parameter ('description'); $description = (string) get_parameter ('description');
$id_module_group = (int) get_parameter ('id_module_group'); $id_module_group = (int) get_parameter ('id_module_group');
$flag = (bool) get_parameter ('flag'); $flag = (bool) get_parameter ('flag');
// Don't read as (float) because it lost it's decimals when put into MySQL // Don't read as (float) because it lost it's decimals when put into MySQL
// where are very big and PHP uses scientific notation, p.e: // where are very big and PHP uses scientific notation, p.e:
// 1.23E-10 is 0.000000000123 // 1.23E-10 is 0.000000000123
@ -652,35 +663,35 @@ if ($update_module || $create_module) {
$tcp_port = (int) get_parameter ('tcp_port'); $tcp_port = (int) get_parameter ('tcp_port');
$configuration_data = (string) get_parameter ('configuration_data'); $configuration_data = (string) get_parameter ('configuration_data');
$old_configuration_data = (string) get_parameter ('old_configuration_data'); $old_configuration_data = (string) get_parameter ('old_configuration_data');
$custom_string_1 = (string) get_parameter ('custom_string_1'); $custom_string_1 = (string) get_parameter ('custom_string_1');
$custom_string_2 = (string) get_parameter ('custom_string_2'); $custom_string_2 = (string) get_parameter ('custom_string_2');
$custom_string_3 = (string) get_parameter ('custom_string_3'); $custom_string_3 = (string) get_parameter ('custom_string_3');
$custom_integer_1 = (int) get_parameter ('prediction_module'); $custom_integer_1 = (int) get_parameter ('prediction_module');
$custom_integer_2 = (int) get_parameter ('custom_integer_2'); $custom_integer_2 = (int) get_parameter ('custom_integer_2');
// Services are an enterprise feature, // Services are an enterprise feature,
// so we got the parameters using this function. // so we got the parameters using this function.
enterprise_hook ('get_service_synthetic_parameters'); enterprise_hook ('get_service_synthetic_parameters');
$agent_name = (string) get_parameter('agent_name',agents_get_name ($id_agente)); $agent_name = (string) get_parameter('agent_name',agents_get_name ($id_agente));
$snmp_community = (string) get_parameter ('snmp_community'); $snmp_community = (string) get_parameter ('snmp_community');
$snmp_oid = (string) get_parameter ('snmp_oid'); $snmp_oid = (string) get_parameter ('snmp_oid');
if (empty ($snmp_oid)) { if (empty ($snmp_oid)) {
/* The user did not set any OID manually but did a SNMP walk */ /* The user did not set any OID manually but did a SNMP walk */
$snmp_oid = (string) get_parameter ('select_snmp_oid'); $snmp_oid = (string) get_parameter ('select_snmp_oid');
} }
if ($id_module_type >= 15 && $id_module_type <= 18){ if ($id_module_type >= 15 && $id_module_type <= 18) {
// New support for snmp v3 // New support for snmp v3
$tcp_send = (string) get_parameter ('snmp_version'); $tcp_send = (string) get_parameter ('snmp_version');
$plugin_user = (string) get_parameter ('snmp3_auth_user'); $plugin_user = (string) get_parameter ('snmp3_auth_user');
$plugin_pass = (string) get_parameter ('snmp3_auth_pass'); $plugin_pass = (string) get_parameter ('snmp3_auth_pass');
$plugin_parameter = (string) get_parameter ('snmp3_auth_method'); $plugin_parameter = (string) get_parameter ('snmp3_auth_method');
$custom_string_1 = (string) get_parameter ('snmp3_privacy_method'); $custom_string_1 = (string) get_parameter ('snmp3_privacy_method');
$custom_string_2 = (string) get_parameter ('snmp3_privacy_pass'); $custom_string_2 = (string) get_parameter ('snmp3_privacy_pass');
$custom_string_3 = (string) get_parameter ('snmp3_security_level'); $custom_string_3 = (string) get_parameter ('snmp3_security_level');
@ -691,10 +702,9 @@ if ($update_module || $create_module) {
$plugin_pass = (int) get_parameter ('plugin_pass'); $plugin_pass = (int) get_parameter ('plugin_pass');
else else
$plugin_pass = (string) get_parameter ('plugin_pass'); $plugin_pass = (string) get_parameter ('plugin_pass');
$plugin_parameter = (string) get_parameter ('plugin_parameter'); $plugin_parameter = (string) get_parameter ('plugin_parameter');
} }
$ip_target = (string) get_parameter ('ip_target'); $ip_target = (string) get_parameter ('ip_target');
$custom_id = (string) get_parameter ('custom_id'); $custom_id = (string) get_parameter ('custom_id');
$history_data = (int) get_parameter('history_data'); $history_data = (int) get_parameter('history_data');
@ -709,14 +719,14 @@ if ($update_module || $create_module) {
$id_tag = (array) get_parameter('id_tag_selected'); $id_tag = (array) get_parameter('id_tag_selected');
$serialize_ops = (string) get_parameter('serialize_ops'); $serialize_ops = (string) get_parameter('serialize_ops');
if($prediction_module != 3) { if ($prediction_module != 3) {
unset($serialize_ops); unset($serialize_ops);
enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module)); enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module));
} }
$active_snmp_v3 = get_parameter('active_snmp_v3'); $active_snmp_v3 = get_parameter('active_snmp_v3');
if ($active_snmp_v3) { if ($active_snmp_v3) {
// //LOST CODE?
} }
// Make changes in the conf file if necessary // Make changes in the conf file if necessary
@ -730,45 +740,45 @@ if ($update_module) {
$id_agent_module = (int) get_parameter ('id_agent_module'); $id_agent_module = (int) get_parameter ('id_agent_module');
$values = array ('descripcion' => $description, $values = array ('descripcion' => $description,
'id_module_group' => $id_module_group, 'id_module_group' => $id_module_group,
'nombre' => $name, 'nombre' => $name,
'max' => $max, 'max' => $max,
'min' => $min, 'min' => $min,
'module_interval' => $interval, 'module_interval' => $interval,
'module_ff_interval' => $ff_interval, 'module_ff_interval' => $ff_interval,
'tcp_port' => $tcp_port, 'tcp_port' => $tcp_port,
'tcp_send' => $tcp_send, 'tcp_send' => $tcp_send,
'tcp_rcv' => $tcp_rcv, 'tcp_rcv' => $tcp_rcv,
'snmp_community' => $snmp_community, 'snmp_community' => $snmp_community,
'snmp_oid' => $snmp_oid, 'snmp_oid' => $snmp_oid,
'ip_target' => $ip_target, 'ip_target' => $ip_target,
'flag' => $flag, 'flag' => $flag,
'disabled' => $disabled, 'disabled' => $disabled,
'id_export' => $id_export, 'id_export' => $id_export,
'plugin_user' => $plugin_user, 'plugin_user' => $plugin_user,
'plugin_pass' => $plugin_pass, 'plugin_pass' => $plugin_pass,
'plugin_parameter' => $plugin_parameter, 'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin, 'id_plugin' => $id_plugin,
'post_process' => $post_process, 'post_process' => $post_process,
'prediction_module' => $prediction_module, 'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout, 'max_timeout' => $max_timeout,
'custom_id' => $custom_id, 'custom_id' => $custom_id,
'history_data' => $history_data, 'history_data' => $history_data,
'min_warning' => $min_warning, 'min_warning' => $min_warning,
'max_warning' => $max_warning, 'max_warning' => $max_warning,
'str_warning' => $str_warning, 'str_warning' => $str_warning,
'min_critical' => $min_critical, 'min_critical' => $min_critical,
'max_critical' => $max_critical, 'max_critical' => $max_critical,
'str_critical' => $str_critical, 'str_critical' => $str_critical,
'custom_string_1' => $custom_string_1, 'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2, 'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3, 'custom_string_3' => $custom_string_3,
'custom_integer_1' => $custom_integer_1, 'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2, 'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event, 'min_ff_event' => $ff_event,
'unit' => $unit); 'unit' => $unit);
if($prediction_module == 3 && $serialize_ops == '') { if ($prediction_module == 3 && $serialize_ops == '') {
$result = false; $result = false;
} }
else { else {
@ -777,26 +787,24 @@ if ($update_module) {
} }
if (is_error($result)) { if (is_error($result)) {
$msg = __('There was a problem updating module').'. ';
switch($result) { switch($result) {
case ERR_EXIST: case ERR_EXIST:
$msg .= __('Another module already exists with the same name').'.'; $msg = __('There was a problem updating module. Another module already exists with the same name.');
break; break;
case ERR_INCOMPLETE: case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')'; $msg = __('There was a problem updating module. Some required fields are missed: (name)');
break; break;
case ERR_NOCHANGES: case ERR_NOCHANGES:
$msg .= __('"No change"'); $msg = __('There was a problem updating module. "No change"');
break; break;
case ERR_DB: case ERR_DB:
case ERR_GENERIC: case ERR_GENERIC:
default: default:
$msg .= __('Processing error'); $msg = __('There was a problem updating module. Processing error');
break; break;
} }
$result = false; $result = false;
echo '<h3 class="error">'.$msg.'</h3>'; ui_print_error_message($msg);
$edit_module = true; $edit_module = true;
@ -804,15 +812,15 @@ if ($update_module) {
"Fail to try update module '$name' for agent ".$agent["nombre"]); "Fail to try update module '$name' for agent ".$agent["nombre"]);
} }
else { else {
if($prediction_module == 3) { if ($prediction_module == 3) {
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops)); enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
} }
echo '<h3 class="suc">'.__('Module successfully updated').'</h3>'; ui_print_success_message(__('Module successfully updated'));
$id_agent_module = false; $id_agent_module = false;
$edit_module = false; $edit_module = false;
$agent = db_get_row ('tagente', 'id_agente', $id_agente); $agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Updated module '$name' for agent ".$agent["nombre"], false, false, json_encode($values)); "Updated module '$name' for agent ".$agent["nombre"], false, false, json_encode($values));
} }
@ -824,7 +832,7 @@ if ($create_module) {
if (isset ($_POST["combo_snmp_oid"])) { if (isset ($_POST["combo_snmp_oid"])) {
$combo_snmp_oid = get_parameter_post ("combo_snmp_oid"); $combo_snmp_oid = get_parameter_post ("combo_snmp_oid");
} }
if ($snmp_oid == ""){ if ($snmp_oid == "") {
$snmp_oid = $combo_snmp_oid; $snmp_oid = $combo_snmp_oid;
} }
@ -833,50 +841,50 @@ if ($create_module) {
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "oracle": case "oracle":
if (empty($description) || !isset($description)) { if (empty($description) || !isset($description)) {
$description=' '; $description=' ';
} }
break; break;
} }
$values = array ('id_tipo_modulo' => $id_module_type, $values = array ('id_tipo_modulo' => $id_module_type,
'descripcion' => $description, 'descripcion' => $description,
'max' => $max, 'max' => $max,
'min' => $min, 'min' => $min,
'snmp_oid' => $snmp_oid, 'snmp_oid' => $snmp_oid,
'snmp_community' => $snmp_community, 'snmp_community' => $snmp_community,
'id_module_group' => $id_module_group, 'id_module_group' => $id_module_group,
'module_interval' => $interval, 'module_interval' => $interval,
'module_ff_interval' => $ff_interval, 'module_ff_interval' => $ff_interval,
'ip_target' => $ip_target, 'ip_target' => $ip_target,
'tcp_port' => $tcp_port, 'tcp_port' => $tcp_port,
'tcp_rcv' => $tcp_rcv, 'tcp_rcv' => $tcp_rcv,
'tcp_send' => $tcp_send, 'tcp_send' => $tcp_send,
'id_export' => $id_export, 'id_export' => $id_export,
'plugin_user' => $plugin_user, 'plugin_user' => $plugin_user,
'plugin_pass' => $plugin_pass, 'plugin_pass' => $plugin_pass,
'plugin_parameter' => $plugin_parameter, 'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin, 'id_plugin' => $id_plugin,
'post_process' => $post_process, 'post_process' => $post_process,
'prediction_module' => $prediction_module, 'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout, 'max_timeout' => $max_timeout,
'disabled' => $disabled, 'disabled' => $disabled,
'id_modulo' => $id_module, 'id_modulo' => $id_module,
'custom_id' => $custom_id, 'custom_id' => $custom_id,
'history_data' => $history_data, 'history_data' => $history_data,
'min_warning' => $min_warning, 'min_warning' => $min_warning,
'max_warning' => $max_warning, 'max_warning' => $max_warning,
'str_warning' => $str_warning, 'str_warning' => $str_warning,
'min_critical' => $min_critical, 'min_critical' => $min_critical,
'max_critical' => $max_critical, 'max_critical' => $max_critical,
'str_critical' => $str_critical, 'str_critical' => $str_critical,
'custom_string_1' => $custom_string_1, 'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2, 'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3, 'custom_string_3' => $custom_string_3,
'custom_integer_1' => $custom_integer_1, 'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2, 'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event, 'min_ff_event' => $ff_event,
'unit' => $unit 'unit' => $unit);
);
if($prediction_module == 3 && $serialize_ops == '') { if($prediction_module == 3 && $serialize_ops == '') {
$id_agent_module = false; $id_agent_module = false;
} }
@ -885,22 +893,21 @@ if ($create_module) {
} }
if (is_error($id_agent_module)) { if (is_error($id_agent_module)) {
$msg = __('There was a problem adding module').'. ';
switch($id_agent_module) { switch($id_agent_module) {
case ERR_EXIST: case ERR_EXIST:
$msg .= __('Another module already exists with the same name').'.'; $msg __('There was a problem adding module. Another module already exists with the same name.');
break; break;
case ERR_INCOMPLETE: case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')'; $msg __('There was a problem adding module. Some required fields are missed : (name)');
break; break;
case ERR_DB: case ERR_DB:
case ERR_GENERIC: case ERR_GENERIC:
default: default:
$msg .= __('Processing error'); $msg __('There was a problem adding module. Processing error');
break; break;
} }
$id_agent_module = false; $id_agent_module = false;
echo '<h3 class="error">'.$msg.'</h3>'; ui_print_error_message($msg);
$edit_module = true; $edit_module = true;
$moduletype = $id_module; $moduletype = $id_module;
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
@ -911,12 +918,12 @@ if ($create_module) {
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops)); enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
} }
echo '<h3 class="suc">'.__('Module added successfully').'</h3>'; ui_print_success_message(__('Module added successfully'));
$id_agent_module = false; $id_agent_module = false;
$edit_module = false; $edit_module = false;
$info = ''; $info = '';
$agent = db_get_row ('tagente', 'id_agente', $id_agente); $agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Added module '$name' for agent ".$agent["nombre"], false, false, json_encode($values)); "Added module '$name' for agent ".$agent["nombre"], false, false, json_encode($values));
@ -977,17 +984,17 @@ if ($delete_module) { // DELETE agent module !
$result = db_process_delete_temp('ttag_module', 'id_agente_modulo', $id_borrar_modulo); $result = db_process_delete_temp('ttag_module', 'id_agente_modulo', $id_borrar_modulo);
if ($result === false) if ($result === false)
$error++; $error++;
// Trick to detect if we are deleting a synthetic module (avg or arithmetic) // Trick to detect if we are deleting a synthetic module (avg or arithmetic)
// If result is empty then module doesn't have this type of submodules // If result is empty then module doesn't have this type of submodules
$ops_json = enterprise_hook('modules_get_synthetic_operations', array($id_borrar_modulo)); $ops_json = enterprise_hook('modules_get_synthetic_operations', array($id_borrar_modulo));
$result_ops_synthetic = json_decode($ops_json); $result_ops_synthetic = json_decode($ops_json);
if (!empty($result_ops_synthetic)){ if (!empty($result_ops_synthetic)) {
$result = enterprise_hook('modules_delete_synthetic_operations', array($id_borrar_modulo)); $result = enterprise_hook('modules_delete_synthetic_operations', array($id_borrar_modulo));
if ($result === false) if ($result === false)
$error++; $error++;
} // Trick to detect if we are deleting components of synthetics modules (avg or arithmetic) } // Trick to detect if we are deleting components of synthetics modules (avg or arithmetic)
else{ else {
$result_components = enterprise_hook('modules_get_synthetic_components', array($id_borrar_modulo)); $result_components = enterprise_hook('modules_get_synthetic_components', array($id_borrar_modulo));
$count_components = 1; $count_components = 1;
if (!empty($result_components)){ if (!empty($result_components)){
@ -996,29 +1003,31 @@ if ($delete_module) { // DELETE agent module !
$last_target_module = 0; $last_target_module = 0;
foreach ($result_components as $id_target_module){ foreach ($result_components as $id_target_module){
// Detects change of component or last component to update orders // Detects change of component or last component to update orders
if (($count_components == $num_components) or ($last_target_module != $id_target_module)) if (($count_components == $num_components) or
($last_target_module != $id_target_module)) {
$update_orders = true; $update_orders = true;
}
else else
$update_orders = false; $update_orders = false;
$result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_borrar_modulo, $update_orders)); $result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_borrar_modulo, $update_orders));
if ($result === false) if ($result === false)
$error++; $error++;
$count_components++; $count_components++;
$last_target_module = $id_target_module; $last_target_module = $id_target_module;
} }
} }
} }
//Check for errors //Check for errors
if ($error != 0) { if ($error != 0) {
db_process_sql_rollback (); db_process_sql_rollback ();
ui_print_error_message (__('There was a problem deleting the module')); ui_print_error_message(__('There was a problem deleting the module'));
} }
else { else {
db_process_sql_commit (); db_process_sql_commit ();
ui_print_success_message (__('Module deleted succesfully')); ui_print_success_message(__('Module deleted succesfully'));
$agent = db_get_row ('tagente', 'id_agente', $id_agente); $agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Deleted module '".$module_data["nombre"]."' for agent ".$agent["nombre"]); "Deleted module '".$module_data["nombre"]."' for agent ".$agent["nombre"]);
@ -1031,7 +1040,7 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
$id_duplicate_module = $duplicate_module; $id_duplicate_module = $duplicate_module;
$original_name = modules_get_agentmodule_name($id_duplicate_module); $original_name = modules_get_agentmodule_name($id_duplicate_module);
$copy_name = io_safe_input(__('copy of') . ' ') . $original_name; $copy_name = sprintf(__('copy of %s'), $original_name);
$cont = 0; $cont = 0;
$exists = true; $exists = true;
@ -1040,8 +1049,7 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
'nombre', $copy_name); 'nombre', $copy_name);
if ($exists) { if ($exists) {
$cont++; $cont++;
$copy_name = io_safe_input(__('copy of') . ' ') . $original_name $copy_name = sprintf(__('copy of %s (%d)'), $original_name, $cont);
. io_safe_input(' (' . $cont . ')');
} }
} }
@ -1085,7 +1093,7 @@ if ($updateGIS) {
"altitude" => $previusAgentGISData['stored_altitude'], "altitude" => $previusAgentGISData['stored_altitude'],
"start_timestamp" => $previusAgentGISData['start_timestamp'], "start_timestamp" => $previusAgentGISData['start_timestamp'],
"end_timestamp" => date( 'Y-m-d H:i:s'), "end_timestamp" => date( 'Y-m-d H:i:s'),
"description" => "Save by Pandora Console", "description" => __('Save by Pandora Console'),
"manual_placement" => $previusAgentGISData['manual_placement'], "manual_placement" => $previusAgentGISData['manual_placement'],
"number_of_packages" => $previusAgentGISData['number_of_packages'], "number_of_packages" => $previusAgentGISData['number_of_packages'],
"tagente_id_agente" => $previusAgentGISData['tagente_id_agente'] "tagente_id_agente" => $previusAgentGISData['tagente_id_agente']
@ -1100,7 +1108,7 @@ if ($updateGIS) {
"stored_altitude" => $lastAltitude, "stored_altitude" => $lastAltitude,
"start_timestamp" => date( 'Y-m-d H:i:s'), "start_timestamp" => date( 'Y-m-d H:i:s'),
"manual_placement" => 1, "manual_placement" => 1,
"description" => "Update by Pandora Console"), "description" => __('Update by Pandora Console')),
array("tagente_id_agente" => $idAgente)); array("tagente_id_agente" => $idAgente));
} }
else { else {
@ -1113,7 +1121,7 @@ if ($updateGIS) {
"stored_latitude" => $lastLatitude, "stored_latitude" => $lastLatitude,
"stored_altitude" => $lastAltitude, "stored_altitude" => $lastAltitude,
"manual_placement" => 1, "manual_placement" => 1,
"description" => "Insert by Pandora Console" "description" => __('Insert by Pandora Console')
)); ));
} }
db_process_sql_commit(); db_process_sql_commit();
@ -1165,13 +1173,15 @@ switch ($tab) {
} }
} }
if (!$found) { if (!$found) {
ui_print_error_message ("Invalid tab specified"); ui_print_error_message (__('Invalid tab specified'));
} }
break; break;
default: default:
if (enterprise_hook ('switch_agent_tab', array ($tab))) if (enterprise_hook ('switch_agent_tab', array ($tab))) {
//This will make sure that blank pages will have at least some //This will make sure that blank pages will have at least some
//debug info in them - do not translate debug //debug info in them - do not translate debug
ui_print_error_message ("Invalid tab specified"); ui_print_error_message (__('Invalid tab specified'));
}
break;
} }
?> ?>

View File

@ -236,7 +236,7 @@ $field2 = '';
$field3 = ''; $field3 = '';
$min_alerts = 0; $min_alerts = 0;
$max_alerts = 1; $max_alerts = 1;
$threshold = 300; $threshold = SECONDS_5MINUTES;
$recovery_notify = false; $recovery_notify = false;
$field2_recovery = ''; $field2_recovery = '';
$field3_recovery = ''; $field3_recovery = '';
@ -287,7 +287,8 @@ if ($create_compound) {
/* Go to previous step in case of error */ /* Go to previous step in case of error */
if ($result === false) { if ($result === false) {
$step = $step - 1; $step = $step - 1;
} else { }
else {
$id = $result; $id = $result;
$alerts = (array) get_parameter ('conditions'); $alerts = (array) get_parameter ('conditions');
$operations = (array) get_parameter ('operations'); $operations = (array) get_parameter ('operations');
@ -329,7 +330,8 @@ if ($step == 2) {
$table->style['other_label'] = 'display:none; font-weight: bold'; $table->style['other_label'] = 'display:none; font-weight: bold';
$table->style['other_input'] = 'display:none'; $table->style['other_input'] = 'display:none';
$threshold_selected = $threshold; $threshold_selected = $threshold;
} else { }
else {
$table->style['other_label'] = 'font-weight: bold'; $table->style['other_label'] = 'font-weight: bold';
$threshold_selected = -1; $threshold_selected = -1;
} }
@ -364,7 +366,7 @@ if ($step == 2) {
$table->data[0][1] .= html_print_checkbox ('saturday', 1, $saturday, true); $table->data[0][1] .= html_print_checkbox ('saturday', 1, $saturday, true);
$table->data[0][1] .= __('Sun'); $table->data[0][1] .= __('Sun');
$table->data[0][1] .= html_print_checkbox ('sunday', 1, $sunday, true); $table->data[0][1] .= html_print_checkbox ('sunday', 1, $sunday, true);
$table->data[0][2] = __('Use special days list'); $table->data[0][2] = __('Use special days list');
$table->data[0][3] = html_print_checkbox ('special_day', 1, $special_day, true); $table->data[0][3] = html_print_checkbox ('special_day', 1, $special_day, true);
@ -581,7 +583,7 @@ echo '</form>';
/* Show alert search when we're on the first step */ /* Show alert search when we're on the first step */
if ($step == 1) { if ($step == 1) {
echo '<h3>'.__('Add condition').'</h3>'; echo '<h3>'. __('Add condition') . '</h3>';
$id_group = (int) get_parameter ('id_group'); $id_group = (int) get_parameter ('id_group');

View File

@ -86,14 +86,15 @@ html_print_select ($modules, "origen_modulo[]", $module_selected, '', '', '0', f
echo '</div>'; //Left div echo '</div>'; //Left div
echo '<div style="float:left; width:\'98%\'; margin-left:20% "><b>'.__('Purge data out of these limits').'</b><br /><br />'; echo '<div style="float:left; width:\'98%\'; margin-left:20% ">
<b>'.__('Purge data out of these limits').'</b><br /><br />';
echo '<table><tr><td>'; echo '<table><tr><td>';
echo __('Minimum').': '; echo __('Minimum').': ';
echo '</td><td>'; echo '</td><td>';
html_print_input_text ("min", 0, __('Minimum'), 4, 0, false); html_print_input_text ("min", 0, __('Minimum'), 4, 0, false);
echo '</td></tr>'; echo '</td></tr>';
echo '<tr><td>'; echo '<tr><td>';
echo __('Maximum').': '; echo __('Maximum').': ';
echo '</td><td>'; echo '</td><td>';
html_print_input_text ("max", 0, __('Maximum'), 4, 0, false); html_print_input_text ("max", 0, __('Maximum'), 4, 0, false);
echo '</td></tr>'; echo '</td></tr>';

View File

@ -63,7 +63,7 @@ push_table_row($data, 'field_process');
return; return;
// Update an existing component // Update an existing component
if (! $id) { if (! $id) {
$module_interval = 300; $module_interval = SECONDS_5MINUTES;
$tcp_port = ""; $tcp_port = "";
$tcp_rcv = ""; $tcp_rcv = "";
$tcp_send = ""; $tcp_send = "";

View File

@ -51,7 +51,8 @@ $table->data[1][1] .= html_print_input_text ('date_format', $config["date_format
if($config['prominent_time'] == 'comparation') { if($config['prominent_time'] == 'comparation') {
$timestamp = false; $timestamp = false;
$comparation = true; $comparation = true;
} else if ($config['prominent_time'] == 'timestamp') { }
else if ($config['prominent_time'] == 'timestamp') {
$timestamp = true; $timestamp = true;
$comparation = false; $comparation = false;
} }
@ -111,11 +112,11 @@ $table->data[14][1] = html_print_select (list_files ('images/custom_logo', "png"
$values = array (); $values = array ();
$values[5] = human_time_description_raw (5); $values[5] = human_time_description_raw (5);
$values[30] = human_time_description_raw (30); $values[30] = human_time_description_raw (30);
$values[60] = human_time_description_raw (60); $values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE);
$values[120] = human_time_description_raw (120); $values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES);
$values[300] = human_time_description_raw (300); $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
$values[600] = human_time_description_raw (600); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
$values[1800] = human_time_description_raw (1800); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
$table->data[15][0] = __('Global default interval for refresh') . ui_print_help_tip(__('This interval will affect all pages'), true); $table->data[15][0] = __('Global default interval for refresh') . ui_print_help_tip(__('This interval will affect all pages'), true);
$table->data[15][1] = html_print_select ($values, 'refr', $config["refr"], '', 'N/A', 0, true, false, false); $table->data[15][1] = html_print_select ($values, 'refr', $config["refr"], '', 'N/A', 0, true, false, false);

View File

@ -43,7 +43,7 @@ else if (isset ($_GET["submit"])) {
$description = (string) get_parameter_post ("description"); $description = (string) get_parameter_post ("description");
$oid = (string) get_parameter_post ("oid"); $oid = (string) get_parameter_post ("oid");
$custom_value = (string) get_parameter_post ("custom_value"); $custom_value = (string) get_parameter_post ("custom_value");
$time_threshold = (int) get_parameter_post ("time_threshold", 300); $time_threshold = (int) get_parameter_post ("time_threshold", SECONDS_5MINUTES);
$time_other = (int) get_parameter_post ("time_other", -1); $time_other = (int) get_parameter_post ("time_other", -1);
$al_field1 = (string) get_parameter_post ("al_field1"); $al_field1 = (string) get_parameter_post ("al_field1");
$al_field2 = (string) get_parameter_post ("al_field2"); $al_field2 = (string) get_parameter_post ("al_field2");
@ -91,33 +91,39 @@ else if (isset ($_GET["submit"])) {
if (!$result) { if (!$result) {
db_pandora_audit("SNMP management", "Fail try to create snmp alert"); db_pandora_audit("SNMP management", "Fail try to create snmp alert");
echo '<h3 class="error">'.__('There was a problem creating the alert').'</h3>'; ui_print_error_message(__('There was a problem creating the alert'));
} }
else { else {
db_pandora_audit("SNMP management", "Create snmp alert #$result"); db_pandora_audit("SNMP management", "Create snmp alert #$result");
echo '<h3 class="suc">'.__('Successfully created').'</h3>'; ui_print_success_message(__('Successfully created'));
} }
} }
else { else {
$sql = sprintf ("UPDATE talert_snmp SET $sql = sprintf ("UPDATE talert_snmp SET
priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s', priority = %d, id_alert = %d, al_field1 = '%s',
oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s',
_snmp_f5_ = '%s', _snmp_f6_ = '%s', trap_type = %d, single_value = '%s' agent = '%s', custom_oid = '%s', oid = '%s',
WHERE id_as = %d", time_threshold = %d, max_alerts = %d, min_alerts = %d,
$priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s',
$oid, $time_threshold, $max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2, $custom_oid_data_3, _snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s',
$custom_oid_data_4, $custom_oid_data_5, $custom_oid_data_6, $trap_type, $single_value, $id_as); trap_type = %d, single_value = '%s'
WHERE id_as = %d",
$priority, $alert_type, $al_field1, $al_field2, $al_field3,
$description, $source_ip, $custom_value, $oid, $time_threshold,
$max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2,
$custom_oid_data_3, $custom_oid_data_4, $custom_oid_data_5,
$custom_oid_data_6, $trap_type, $single_value, $id_as);
$result = db_process_sql ($sql); $result = db_process_sql ($sql);
if (!$result) { if (!$result) {
db_pandora_audit("SNMP management", "Fail try to update snmp alert #$id_as"); db_pandora_audit("SNMP management", "Fail try to update snmp alert #$id_as");
echo '<h3 class="error">'.__('There was a problem updating the alert').'</h3>'; ui_print_error_message(__('There was a problem updating the alert'));
} }
else { else {
db_pandora_audit("SNMP management", "Update snmp alert #$id_as"); db_pandora_audit("SNMP management", "Update snmp alert #$id_as");
echo '<h3 class="suc">'.__('Successfully updated').'</h3>'; ui_print_success_message(__('Successfully updated'));
} }
} }
} }
@ -160,7 +166,7 @@ elseif (isset ($_GET["update_alert"])) {
$description = ""; $description = "";
$oid = ""; $oid = "";
$custom_value = ""; $custom_value = "";
$time_threshold = 300; $time_threshold = SECONDS_5MINUTES;
$al_field1 = ""; $al_field1 = "";
$al_field2 = ""; $al_field2 = "";
$al_field3 = ""; $al_field3 = "";
@ -187,11 +193,11 @@ if (isset ($_GET["delete_alert"])) { // Delete alert
$result = db_process_sql_delete('talert_snmp', array('id_as' => $alert_delete)); $result = db_process_sql_delete('talert_snmp', array('id_as' => $alert_delete));
if ($result === false) { if ($result === false) {
db_pandora_audit("SNMP management", "Fail try to delete snmp alert #$alert_delete"); db_pandora_audit("SNMP management", "Fail try to delete snmp alert #$alert_delete");
echo '<h3 class="error">'.__('There was a problem deleting the alert').'</h3>'; ui_print_error_message(__('There was a problem deleting the alert'));
} }
else { else {
db_pandora_audit("SNMP management", "Delete snmp alert #$alert_delete"); db_pandora_audit("SNMP management", "Delete snmp alert #$alert_delete");
echo '<h3 class="suc">'.__('Successfully deleted').'</h3>'; ui_print_success_message(__('Successfully deleted'));
} }
} }

View File

@ -39,7 +39,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
return false; return false;
if (empty ($ip_address)) if (empty ($ip_address))
return false; return false;
$interval = safe_int ($interval,1, 300); $interval = safe_int ($interval,1, SECONDS_5MINUTES);
if (empty ($interval)) if (empty ($interval))
return false; return false;
if (! is_array ($values)) if (! is_array ($values))
@ -76,16 +76,16 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
} }
$result = db_process_sql_insert ('tagente_estado', $result = db_process_sql_insert ('tagente_estado',
array ('id_agente_modulo' => $id_agent_module, array ('id_agente_modulo' => $id_agent_module,
'datos' => '', 'datos' => '',
'timestamp' => 0, 'timestamp' => 0,
'estado' => 0, 'estado' => 0,
'id_agente' => $id_agent, 'id_agente' => $id_agent,
'last_try' => 0, 'last_try' => 0,
'utimestamp' => 0, 'utimestamp' => 0,
'current_interval' => 0, 'current_interval' => 0,
'running_by' => 0, 'running_by' => 0,
'last_execution_try' => 0)); 'last_execution_try' => 0));
if ($result === false) { if ($result === false) {
db_process_sql_rollback (); db_process_sql_rollback ();
@ -95,7 +95,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
db_process_sql_commit (); db_process_sql_commit ();
db_pandora_audit ("Agent management", "New agent '$name' created"); db_pandora_audit ("Agent management", "New agent '$name' created");
return $id_agent; return $id_agent;
} }
@ -115,7 +115,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '',
$allModules = false, $orderby = false, $idGroup = false, $count = false) { $allModules = false, $orderby = false, $idGroup = false, $count = false) {
global $config; global $config;
if (is_array($filter)) { if (is_array($filter)) {
$disabled = $filter['disabled']; $disabled = $filter['disabled'];
if (isset($filter['standby'])) { if (isset($filter['standby'])) {
@ -129,7 +129,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
$filter = ''; $filter = '';
$disabled = $filter; $disabled = $filter;
} }
switch ($disabled) { switch ($disabled) {
case "notfired": case "notfired":
$filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0'; $filter .= ' AND times_fired = 0 AND talert_template_modules.disabled = 0';
@ -145,8 +145,9 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
break; break;
default: default:
$filter .= ''; $filter .= '';
break;
} }
if (is_array ($options)) { if (is_array ($options)) {
$filter .= db_format_array_where_clause_sql ($options); $filter .= db_format_array_where_clause_sql ($options);
} }
@ -176,7 +177,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
$subQuery = implode (",", $id_modules); $subQuery = implode (",", $id_modules);
} }
$orderbyText = ''; $orderbyText = '';
if ($orderby !== false) { if ($orderby !== false) {
if (is_array($orderby)) { if (is_array($orderby)) {
@ -191,26 +192,26 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
if ($count !== false) { if ($count !== false) {
$selectText = 'COUNT(talert_template_modules.id) AS count'; $selectText = 'COUNT(talert_template_modules.id) AS count';
} }
// TODO: Clean extra_sql // TODO: Clean extra_sql
$extra_sql = ''; $extra_sql = '';
$sql = sprintf ("SELECT %s $sql = sprintf ("SELECT %s
FROM talert_template_modules FROM talert_template_modules
INNER JOIN tagente_modulo t2 INNER JOIN tagente_modulo t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente t3 INNER JOIN tagente t3
ON t2.id_agente = t3.id_agente ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates t4 INNER JOIN talert_templates t4
ON talert_template_modules.id_alert_template = t4.id ON talert_template_modules.id_alert_template = t4.id
WHERE (%s id_agent_module in (%s)) %s %s %s", WHERE (%s id_agent_module in (%s)) %s %s %s",
$selectText, $extra_sql, $subQuery, $where, $filter, $orderbyText); $selectText, $extra_sql, $subQuery, $where, $filter, $orderbyText);
$alerts = db_get_all_rows_sql ($sql); $alerts = db_get_all_rows_sql ($sql);
if ($alerts === false) if ($alerts === false)
return array (); return array ();
if ($count !== false) { if ($count !== false) {
return $alerts[0]['count']; return $alerts[0]['count'];
} }
@ -254,7 +255,8 @@ function agents_get_alerts_compound ($id_agent = false, $filter = '', $options =
if (($id_agent !== false) && ($idGroup !== false)) { if (($id_agent !== false) && ($idGroup !== false)) {
if ($idGroup != 0) { //All group if ($idGroup != 0) { //All group
$subQuery = 'SELECT id_agente FROM tagente WHERE id_grupo = ' . $idGroup; $subQuery = 'SELECT id_agente
FROM tagente WHERE id_grupo = ' . $idGroup;
} }
else { else {
$subQuery = 'SELECT id_agente FROM tagente'; $subQuery = 'SELECT id_agente FROM tagente';
@ -275,7 +277,8 @@ function agents_get_alerts_compound ($id_agent = false, $filter = '', $options =
$selectText = 'COUNT(id) AS count'; $selectText = 'COUNT(id) AS count';
} }
$sql = sprintf ("SELECT %s FROM talert_compound $sql = sprintf ("SELECT %s
FROM talert_compound
WHERE id_agent IN (%s) %s %s", WHERE id_agent IN (%s) %s %s",
$selectText, $subQuery, $where, $filter); $selectText, $subQuery, $where, $filter);
@ -307,67 +310,72 @@ function agents_get_alerts_compound ($id_agent = false, $filter = '', $options =
* @return mixed An array with all alerts defined for an agent or false in case no allowed groups are specified. * @return mixed An array with all alerts defined for an agent or false in case no allowed groups are specified.
*/ */
function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $order = array('field' => 'nombre', 'order' => 'ASC'), $return = false) { function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $order = array('field' => 'nombre', 'order' => 'ASC'), $return = false) {
global $config; global $config;
if (! is_array ($filter)) { if (! is_array ($filter)) {
$filter = array (); $filter = array ();
} }
if(isset($filter['search'])) { if (isset($filter['search'])) {
$search = $filter['search']; $search = $filter['search'];
unset($filter['search']); unset($filter['search']);
} }
else{ else {
$search = ''; $search = '';
} }
if(isset($filter['offset'])) { if (isset($filter['offset'])) {
$offset = $filter['offset']; $offset = $filter['offset'];
unset($filter['offset']); unset($filter['offset']);
} }
if(isset($filter['limit'])) { if (isset($filter['limit'])) {
$limit = $filter['limit']; $limit = $filter['limit'];
unset($filter['limit']); unset($filter['limit']);
} }
$status_sql = ' 1 = 1'; $status_sql = ' 1 = 1';
if(isset($filter['status'])) { if (isset($filter['status'])) {
$normal_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $normal_modules = 'SELECT tagente.id_agente
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 0 AND tagente_modulo.disabled = 0 AND estado = 0
AND (utimestamp != 0)' /*OR tagente_modulo.id_tipo_modulo IN (21,22,23)) AND (utimestamp != 0)' /*OR tagente_modulo.id_tipo_modulo IN (21,22,23))
AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2)) AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'*/; OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'*/;
$warning_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $warning_modules = 'SELECT tagente.id_agente
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 2 AND tagente_estado.utimestamp != 0'; AND tagente_modulo.disabled = 0 AND estado = 2 AND tagente_estado.utimestamp != 0';
/* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2)) /* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';*/ OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';*/
$critical_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $critical_modules = 'SELECT tagente.id_agente
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.utimestamp != 0'; AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.utimestamp != 0';
/* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2)) /* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'; */ OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'; */
$unknown_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $unknown_modules = 'SELECT tagente.id_agente
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 3 AND utimestamp != 0' /*AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100) AND tagente_modulo.disabled = 0 AND estado = 3 AND utimestamp != 0' /*AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)
AND utimestamp < ( UNIX_TIMESTAMP() - (current_interval * 2)) AND utimestamp != 0'*/; AND utimestamp < ( UNIX_TIMESTAMP() - (current_interval * 2)) AND utimestamp != 0'*/;
$notinit_modules = 'SELECT tagente_estado.id_agente FROM tagente_estado, tagente, tagente_modulo $notinit_modules = 'SELECT tagente_estado.id_agente
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23) AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23)
AND utimestamp = 0'; AND utimestamp = 0';
switch ($filter['status']) { switch ($filter['status']) {
// Normal // Normal
case 0: case 0:
@ -384,7 +392,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$status_sql = "id_agente IN ($critical_modules)"; $status_sql = "id_agente IN ($critical_modules)";
break; break;
// Unknown // Unknown
case 3: case 3:
$status_sql = "id_agente IN ($unknown_modules) && $status_sql = "id_agente IN ($unknown_modules) &&
id_agente NOT IN ($critical_modules) && id_agente NOT IN ($warning_modules)"; id_agente NOT IN ($critical_modules) && id_agente NOT IN ($warning_modules)";
break; break;
@ -399,19 +407,18 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$status_sql = "id_agente NOT IN ($warning_modules) && $status_sql = "id_agente NOT IN ($warning_modules) &&
id_agente NOT IN ($critical_modules) && id_agente NOT IN ($unknown_modules) && id_agente NOT IN ($normal_modules)"; id_agente NOT IN ($critical_modules) && id_agente NOT IN ($unknown_modules) && id_agente NOT IN ($normal_modules)";
break; break;
} }
unset($filter['status']); unset($filter['status']);
} }
unset($filter['order']); unset($filter['order']);
$filter_nogroup = $filter; $filter_nogroup = $filter;
//Get user groups //Get user groups
$groups = array_keys (users_get_groups ($config["id_user"], $access, false)); $groups = array_keys (users_get_groups ($config["id_user"], $access, false));
//If no group specified, get all user groups //If no group specified, get all user groups
if (empty ($filter['id_grupo'])) { if (empty ($filter['id_grupo'])) {
$all_groups = true; $all_groups = true;
@ -461,32 +468,35 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
} }
$where = db_format_array_where_clause_sql ($filter, 'AND', ''); $where = db_format_array_where_clause_sql ($filter, 'AND', '');
$where_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', ''); $where_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', '');
if ($where_nogroup == '') { if ($where_nogroup == '') {
$where_nogroup = '1 = 1'; $where_nogroup = '1 = 1';
} }
$extra = false; $extra = false;
// TODO: CLEAN extra_sql // TODO: CLEAN extra_sql
$sql_extra = ''; $sql_extra = '';
if ($all_groups){ if ($all_groups) {
$where_nogroup = '1 = 1'; $where_nogroup = '1 = 1';
} }
if($extra) { if($extra) {
$where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search); $where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search);
} else { }
else {
$where = sprintf('%s AND %s AND (%s) %s', $where, $where_nogroup, $status_sql, $search); $where = sprintf('%s AND %s AND (%s) %s', $where, $where_nogroup, $status_sql, $search);
} }
$sql = sprintf('SELECT %s FROM tagente WHERE %s %s', implode(',',$fields), $where, $order); $sql = sprintf('SELECT %s
FROM tagente
WHERE %s %s', implode(',',$fields), $where, $order);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$limit_sql = ''; $limit_sql = '';
if(isset($offset) && isset($limit)) { if (isset($offset) && isset($limit)) {
$limit_sql = " LIMIT $offset, $limit "; $limit_sql = " LIMIT $offset, $limit ";
} }
$sql = sprintf("%s %s", $sql, $limit_sql); $sql = sprintf("%s %s", $sql, $limit_sql);
@ -498,7 +508,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
break; break;
case "postgresql": case "postgresql":
$limit_sql = ''; $limit_sql = '';
if(isset($offset) && isset($limit)) { if (isset($offset) && isset($limit)) {
$limit_sql = " OFFSET $offset LIMIT $limit "; $limit_sql = " OFFSET $offset LIMIT $limit ";
} }
$sql = sprintf("%s %s", $sql, $limit_sql); $sql = sprintf("%s %s", $sql, $limit_sql);
@ -510,7 +520,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
break; break;
case "oracle": case "oracle":
$set = array(); $set = array();
if(isset($offset) && isset($limit)) { if (isset($offset) && isset($limit)) {
$set['limit'] = $limit; $set['limit'] = $limit;
$set['offset'] = $offset; $set['offset'] = $offset;
} }
@ -556,7 +566,7 @@ function agents_get_alerts ($id_agent = false, $filter = false, $options = false
*/ */
function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false, $target_alerts = false) { function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false, $target_alerts = false) {
global $config; global $config;
if (empty ($source_id_agent)) { if (empty ($source_id_agent)) {
echo '<h3 class="error">'.__('No source agent to copy').'</h3>'; echo '<h3 class="error">'.__('No source agent to copy').'</h3>';
return false; return false;
@ -588,7 +598,7 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
if (empty ($target_modules)) { if (empty ($target_modules)) {
if (! $copy_alerts) { if (! $copy_alerts) {
echo '<h3 class="error">'.__('No modules have been selected').'</h3>'; ui_print_error_message(__('No modules have been selected'));
return false; return false;
} }
$target_modules = array (); $target_modules = array ();
@ -615,30 +625,28 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
break; break;
} }
$error = false; $error = false;
$repeated_modules = array(); $repeated_modules = array();
foreach ($destiny_id_agents as $id_destiny_agent) { foreach ($destiny_id_agents as $id_destiny_agent) {
foreach ($target_modules as $id_agent_module) { foreach ($target_modules as $id_agent_module) {
// Check the module name exists in target // Check the module name exists in target
$module = modules_get_agentmodule ($id_agent_module); $module = modules_get_agentmodule ($id_agent_module);
if ($module === false) if ($module === false)
return false; return false;
$modules = agents_get_modules ($id_destiny_agent, false, $modules = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => false)); array ('nombre' => $module['nombre'], 'disabled' => false));
// Keep all modules repeated // Keep all modules repeated
if (! empty ($modules)) { if (! empty ($modules)) {
$modules_repeated = array_pop (array_keys ($modules)); $modules_repeated = array_pop (array_keys ($modules));
$result = $modules_repeated; $result = $modules_repeated;
$repeated_modules[] = $modules_repeated; $repeated_modules[] = $modules_repeated;
} }
else { else {
$result = modules_copy_agent_module_to_agent ($id_agent_module, $result = modules_copy_agent_module_to_agent ($id_agent_module,
$id_destiny_agent); $id_destiny_agent);
if ($result === false) { if ($result === false) {
$error = true; $error = true;
break; break;
@ -694,7 +702,8 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
} }
if ($error) { if ($error) {
echo '<h3 class="error">'.__('There was an error copying the agent configuration, the copy has been cancelled').'</h3>'; ui_print_error_message(
__('There was an error copying the agent configuration, the copy has been cancelled'));
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
@ -704,8 +713,9 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
db_process_sql_rollback(); db_process_sql_rollback();
break; break;
} }
} else { }
echo '<h3 class="suc">'.__('Successfully copied').'</h3>'; else {
ui_print_success_message(__('Successfully copied'));
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
@ -725,8 +735,9 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
} }
function agents_get_next_contact($idAgent, $maxModules = false) { function agents_get_next_contact($idAgent, $maxModules = false) {
$agent = db_get_row_sql("SELECT *
$agent = db_get_row_sql("SELECT * FROM tagente WHERE id_agente = " . $idAgent); FROM tagente
WHERE id_agente = " . $idAgent);
$difference = get_system_time () - strtotime ($agent["ultimo_contacto"]); $difference = get_system_time () - strtotime ($agent["ultimo_contacto"]);
@ -734,7 +745,9 @@ function agents_get_next_contact($idAgent, $maxModules = false) {
$max = $agent["intervalo"]; $max = $agent["intervalo"];
if ($maxModules) { if ($maxModules) {
$sql = sprintf ("SELECT MAX(module_interval) FROM tagente_modulo WHERE id_agente = %d", $id_agente); $sql = sprintf ("SELECT MAX(module_interval)
FROM tagente_modulo
WHERE id_agente = %d", $id_agente);
$maxModules = (int) db_get_sql ($sql); $maxModules = (int) db_get_sql ($sql);
if ($maxModules > 0) if ($maxModules > 0)
$max = $maxModules; $max = $maxModules;
@ -775,7 +788,7 @@ function agents_get_next_contact($idAgent, $maxModules = false) {
*/ */
function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed = true, $get_not_init_modules = true) { function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed = true, $get_not_init_modules = true) {
$id_agent = safe_int ($id_agent, 1); $id_agent = safe_int ($id_agent, 1);
$where = ''; $where = '';
if (! empty ($id_agent)) { if (! empty ($id_agent)) {
$where = sprintf (' WHERE t2.id_agent_module = t1.id_agente_modulo AND delete_pending = 0 $where = sprintf (' WHERE t2.id_agent_module = t1.id_agente_modulo AND delete_pending = 0
@ -851,17 +864,17 @@ function agents_common_modules_with_alerts ($id_agent, $filter = false, $indexed
*/ */
function agents_common_modules ($id_agent, $filter = false, $indexed = true, $get_not_init_modules = true) { function agents_common_modules ($id_agent, $filter = false, $indexed = true, $get_not_init_modules = true) {
$id_agent = safe_int ($id_agent, 1); $id_agent = safe_int ($id_agent, 1);
$where = ''; $where = '';
if (! empty ($id_agent)) { if (! empty ($id_agent)) {
$where = sprintf (' WHERE delete_pending = 0 AND id_agente IN (%s) $where = sprintf (' WHERE delete_pending = 0 AND id_agente IN (%s)
AND ( AND (
SELECT count(nombre) SELECT count(nombre)
FROM tagente_modulo t2 FROM tagente_modulo t2
WHERE delete_pending = 0 AND t1.nombre = t2.nombre WHERE delete_pending = 0 AND t1.nombre = t2.nombre
AND id_agente IN (%s)) = (%s)', implode (",", (array) $id_agent), implode (",", (array) $id_agent), count($id_agent)); AND id_agente IN (%s)) = (%s)', implode (",", (array) $id_agent), implode (",", (array) $id_agent), count($id_agent));
} }
if (! empty ($filter)) { if (! empty ($filter)) {
$where .= ' AND '; $where .= ' AND ';
if (is_array ($filter)) { if (is_array ($filter)) {
@ -913,10 +926,10 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge
*/ */
function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower", $noACL = false, $childGroups = false, $extra_access = true) { function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower", $noACL = false, $childGroups = false, $extra_access = true) {
global $config; global $config;
if (!$noACL) { if (!$noACL) {
$id_group = groups_safe_acl($config["id_user"], $id_group, "AR"); $id_group = groups_safe_acl($config["id_user"], $id_group, "AR");
if (empty ($id_group)) { if (empty ($id_group)) {
//An empty array means the user doesn't have access //An empty array means the user doesn't have access
return array (); return array ();
@ -934,7 +947,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
} }
$id_group = array_keys(users_get_groups(false, "AR", true, false, (array)$id_group)); $id_group = array_keys(users_get_groups(false, "AR", true, false, (array)$id_group));
} }
if (is_array($id_group)) { if (is_array($id_group)) {
$all_groups = false; $all_groups = false;
$search_group_sql = sprintf ('id_grupo IN (%s)', implode (",", $id_group)); $search_group_sql = sprintf ('id_grupo IN (%s)', implode (",", $id_group));
@ -947,7 +960,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
$all_groups = false; $all_groups = false;
$search_group_sql = sprintf ('id_grupo = %d', $id_group); $search_group_sql = sprintf ('id_grupo = %d', $id_group);
} }
$search_sql = '1 = 1'; $search_sql = '1 = 1';
if ($search === true) { if ($search === true) {
@ -974,10 +987,10 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
$search_sql .= ' AND (UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR direccion LIKE upper(\'%'.$string.'%\'))'; $search_sql .= ' AND (UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR direccion LIKE upper(\'%'.$string.'%\'))';
break; break;
} }
unset ($search["string"]); unset ($search["string"]);
} }
if (isset ($search["name"])) { if (isset ($search["name"])) {
$name = io_safe_input ($search["name"]); $name = io_safe_input ($search["name"]);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
@ -1152,7 +1165,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
$operatorDistin = true; $operatorDistin = true;
} }
} }
if ($value[0] == '%') { if ($value[0] == '%') {
switch ($config['dbtype']){ switch ($config['dbtype']){
case "mysql": case "mysql":
@ -1266,14 +1279,14 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
} }
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
if (empty ($result)) { if (empty ($result)) {
return array (); return array ();
} }
if (! $indexed) if (! $indexed)
return $result; return $result;
$modules = array (); $modules = array ();
foreach ($result as $module) { foreach ($result as $module) {
if ($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) { if ($get_not_init_modules || modules_get_agentmodule_is_init($module['id_agente_modulo'])) {
@ -1337,6 +1350,7 @@ function agents_get_name ($id_agent, $case = "none") {
case "none": case "none":
default: default:
return ($agent); return ($agent);
break;
} }
} }
@ -1352,17 +1366,17 @@ function agents_get_name ($id_agent, $case = "none") {
*/ */
function agents_get_modules_data_count ($id_agent = 0) { function agents_get_modules_data_count ($id_agent = 0) {
$id_agent = safe_int ($id_agent, 1); $id_agent = safe_int ($id_agent, 1);
if (empty ($id_agent)) { if (empty ($id_agent)) {
$id_agent = array (); $id_agent = array ();
} }
else { else {
$id_agent = (array) $id_agent; $id_agent = (array) $id_agent;
} }
$count = array (); $count = array ();
$count["total"] = 0; $count["total"] = 0;
$query[0] = "SELECT COUNT(*) FROM tagente_datos"; $query[0] = "SELECT COUNT(*) FROM tagente_datos";
foreach ($id_agent as $agent_id) { foreach ($id_agent as $agent_id) {
@ -1378,7 +1392,7 @@ function agents_get_modules_data_count ($id_agent = 0) {
//Add total agent count to total count //Add total agent count to total count
$count["total"] += $count[$agent_id]; $count["total"] += $count[$agent_id];
} }
if ($count["total"] == 0) { if ($count["total"] == 0) {
foreach ($query as $sql) { foreach ($query as $sql) {
$count["total"] += (int) db_get_sql ($sql, 0, true); $count["total"] += (int) db_get_sql ($sql, 0, true);
@ -1401,7 +1415,7 @@ function agents_check_alert_fired ($id_agent) {
WHERE talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo WHERE talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
AND times_fired > 0 AND id_agente = %d", AND times_fired > 0 AND id_agente = %d",
$id_agent); $id_agent);
$value = db_get_sql ($sql); $value = db_get_sql ($sql);
if ($value > 0) if ($value > 0)
return true; return true;
@ -1450,7 +1464,7 @@ function agents_give_agentmodule_flag ($id_agent_module) {
*/ */
function agents_add_address ($id_agent, $ip_address) { function agents_add_address ($id_agent, $ip_address) {
global $config; global $config;
// Check if already is attached to agent // Check if already is attached to agent
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
@ -1468,15 +1482,15 @@ function agents_add_address ($id_agent, $ip_address) {
$current_address = db_get_sql ($sql); $current_address = db_get_sql ($sql);
if ($current_address > 0) if ($current_address > 0)
return; return;
// Look for a record with this IP Address // Look for a record with this IP Address
$id_address = (int) db_get_value ('id_a', 'taddress', 'ip', $ip_address); $id_address = (int) db_get_value ('id_a', 'taddress', 'ip', $ip_address);
if ($id_address === 0) { if ($id_address === 0) {
// Create IP address in tadress table // Create IP address in tadress table
$id_address = db_process_sql_insert('taddress', array('ip' => $ip_address)); $id_address = db_process_sql_insert('taddress', array('ip' => $ip_address));
} }
// Add address to agent // Add address to agent
$values = array('id_a' => $id_address, 'id_agent' => $id_agent); $values = array('id_a' => $id_address, 'id_agent' => $id_agent);
db_process_sql_insert('taddress_agent', $values); db_process_sql_insert('taddress_agent', $values);
@ -1490,8 +1504,9 @@ function agents_add_address ($id_agent, $ip_address) {
*/ */
function agents_delete_address ($id_agent, $ip_address) { function agents_delete_address ($id_agent, $ip_address) {
global $config; global $config;
$sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress $sql = sprintf ("SELECT id_ag
FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a AND ip = '%s' WHERE taddress_agent.id_a = taddress.id_a AND ip = '%s'
AND id_agent = %d", $ip_address, $id_agent); AND id_agent = %d", $ip_address, $id_agent);
$id_ag = db_get_sql ($sql); $id_ag = db_get_sql ($sql);
@ -1501,7 +1516,7 @@ function agents_delete_address ($id_agent, $ip_address) {
$agent_name = agents_get_name($id_agent, ""); $agent_name = agents_get_name($id_agent, "");
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Deleted IP $ip_address from agent '$agent_name'"); "Deleted IP $ip_address from agent '$agent_name'");
// Need to change main address? // Need to change main address?
if (agents_get_address ($id_agent) == $ip_address) { if (agents_get_address ($id_agent) == $ip_address) {
$new_ips = agents_get_addresses ($id_agent); $new_ips = agents_get_addresses ($id_agent);
@ -1550,7 +1565,7 @@ function agents_get_agent_with_ip ($ip_address) {
AND ip = \'%s\'', $ip_address); AND ip = \'%s\'', $ip_address);
break; break;
} }
return db_get_row_sql ($sql); return db_get_row_sql ($sql);
} }
@ -1566,18 +1581,18 @@ function agents_get_addresses ($id_agent) {
FROM taddress_agent, taddress FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a WHERE taddress_agent.id_a = taddress.id_a
AND id_agent = %d", $id_agent); AND id_agent = %d", $id_agent);
$ips = db_get_all_rows_sql ($sql); $ips = db_get_all_rows_sql ($sql);
if ($ips === false) { if ($ips === false) {
$ips = array (); $ips = array ();
} }
$ret_arr = array (); $ret_arr = array ();
foreach ($ips as $row) { foreach ($ips as $row) {
$ret_arr[$row["ip"]] = $row["ip"]; $ret_arr[$row["ip"]] = $row["ip"];
} }
return $ret_arr; return $ret_arr;
} }
@ -1593,7 +1608,7 @@ function agents_get_addresses ($id_agent) {
function agents_get_status($id_agent = 0, $noACLs = false) { function agents_get_status($id_agent = 0, $noACLs = false) {
global $config; global $config;
if (!$noACLs){ if (!$noACLs) {
$modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false); $modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false);
} }
else{ else{
@ -1602,29 +1617,29 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
$filter_modules['delete_pending'] = 0; $filter_modules['delete_pending'] = 0;
// Get all non disabled modules of the agent // Get all non disabled modules of the agent
$all_modules = db_get_all_rows_filter('tagente_modulo', $filter_modules, 'id_agente_modulo'); $all_modules = db_get_all_rows_filter('tagente_modulo', $filter_modules, 'id_agente_modulo');
$result_modules = array(); $result_modules = array();
// Skip non init modules // Skip non init modules
foreach ($all_modules as $module){ foreach ($all_modules as $module){
if (modules_get_agentmodule_is_init($module['id_agente_modulo'])){ if (modules_get_agentmodule_is_init($module['id_agente_modulo'])){
$modules[] = $module['id_agente_modulo']; $modules[] = $module['id_agente_modulo'];
} }
} }
} }
$modules_status = array(); $modules_status = array();
$modules_async = 0; $modules_async = 0;
foreach($modules as $module) { foreach($modules as $module) {
$modules_status[] = modules_get_agentmodule_status($module); $modules_status[] = modules_get_agentmodule_status($module);
$module_type = modules_get_agentmodule_type($module); $module_type = modules_get_agentmodule_type($module);
if(($module_type >= 21 && $module_type <= 23) || $module_type == 100) { if(($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
$modules_async++; $modules_async++;
} }
} }
// If all the modules are asynchronous or keep alive, the group cannot be unknown // If all the modules are asynchronous or keep alive, the group cannot be unknown
if($modules_async < count($modules)) { if ($modules_async < count($modules)) {
$time = get_system_time (); $time = get_system_time ();
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
@ -1647,26 +1662,26 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)) > ' . $time)); 'ceil((to_date(ultimo_contacto, \'YYYY-MM-DD HH24:MI:SS\') - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)) > ' . $time));
break; break;
} }
if (! $status) if (! $status)
return -1; return -1;
} }
// Status is 0 for normal, 1 for critical, 2 for warning and 3 for unknown. 4 for alert fired // Status is 0 for normal, 1 for critical, 2 for warning and 3 for unknown. 4 for alert fired
// Checking if any module has alert fired (4) // Checking if any module has alert fired (4)
if(is_int(array_search(4,$modules_status))){ if (is_int(array_search(4,$modules_status))) {
return 4; return 4;
} }
// Checking if any module has critical status (1) // Checking if any module has critical status (1)
elseif(is_int(array_search(1,$modules_status))){ elseif (is_int(array_search(1,$modules_status))) {
return 1; return 1;
} }
// Checking if any module has warning status (2) // Checking if any module has warning status (2)
elseif(is_int(array_search(2,$modules_status))){ elseif (is_int(array_search(2,$modules_status))) {
return 2; return 2;
} }
// Checking if any module has unknown status (3) // Checking if any module has unknown status (3)
elseif(is_int(array_search(3,$modules_status))){ elseif (is_int(array_search(3,$modules_status))) {
return 3; return 3;
} }
else { else {
@ -1685,34 +1700,34 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
*/ */
function agents_delete_agent ($id_agents, $disableACL = false) { function agents_delete_agent ($id_agents, $disableACL = false) {
global $config; global $config;
$error = false; $error = false;
//Convert single values to an array //Convert single values to an array
if (! is_array ($id_agents)) if (! is_array ($id_agents))
$id_agents = (array) $id_agents; $id_agents = (array) $id_agents;
//Start transaction //Start transaction
db_process_sql_begin (); db_process_sql_begin ();
foreach ($id_agents as $id_agent) { foreach ($id_agents as $id_agent) {
$id_agent = (int) $id_agent; //Cast as integer $id_agent = (int) $id_agent; //Cast as integer
if ($id_agent < 1) if ($id_agent < 1)
continue; continue;
$agent_name = agents_get_name($id_agent, ""); $agent_name = agents_get_name($id_agent, "");
/* Check for deletion permissions */ /* Check for deletion permissions */
$id_group = agents_get_agent_group ($id_agent); $id_group = agents_get_agent_group ($id_agent);
if ((! check_acl ($config['id_user'], $id_group, "AW")) && !$disableACL) { if ((! check_acl ($config['id_user'], $id_group, "AW")) && !$disableACL) {
db_process_sql_rollback (); db_process_sql_rollback ();
return false; return false;
} }
//A variable where we store that long subquery thing for //A variable where we store that long subquery thing for
//modules //modules
$where_modules = "ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agent.")"; $where_modules = "ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agent.")";
//IP address //IP address
$sql = sprintf ("SELECT id_ag $sql = sprintf ("SELECT id_ag
FROM taddress_agent, taddress FROM taddress_agent, taddress
@ -1720,68 +1735,68 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
AND id_agent = %d", AND id_agent = %d",
$id_agent); $id_agent);
$addresses = db_get_all_rows_sql ($sql); $addresses = db_get_all_rows_sql ($sql);
if ($addresses === false) { if ($addresses === false) {
$addresses = array (); $addresses = array ();
} }
foreach ($addresses as $address) { foreach ($addresses as $address) {
db_process_delete_temp ("taddress_agent", "id_ag", $address["id_ag"]); db_process_delete_temp ("taddress_agent", "id_ag", $address["id_ag"]);
} }
// We cannot delete tagente_datos and tagente_datos_string here // We cannot delete tagente_datos and tagente_datos_string here
// because it's a huge ammount of time. tagente_module has a special // because it's a huge ammount of time. tagente_module has a special
// field to mark for delete each module of agent deleted and in // field to mark for delete each module of agent deleted and in
// daily maintance process, all data for that modules are deleted // daily maintance process, all data for that modules are deleted
//Alert //Alert
db_process_delete_temp ("talert_compound", "id_agent", $id_agent); db_process_delete_temp ("talert_compound", "id_agent", $id_agent);
db_process_delete_temp ("talert_template_modules", "id_agent_module", $where_modules); db_process_delete_temp ("talert_template_modules", "id_agent_module", $where_modules);
//Events (up/down monitors) //Events (up/down monitors)
// Dont delete here, could be very time-exausting, let the daily script // Dont delete here, could be very time-exausting, let the daily script
// delete them after XXX days // delete them after XXX days
// db_process_delete_temp ("tevento", "id_agente", $id_agent); // db_process_delete_temp ("tevento", "id_agente", $id_agent);
//Graphs, layouts & reports //Graphs, layouts & reports
db_process_delete_temp ("tgraph_source", "id_agent_module", $where_modules); db_process_delete_temp ("tgraph_source", "id_agent_module", $where_modules);
db_process_delete_temp ("tlayout_data", "id_agente_modulo", $where_modules); db_process_delete_temp ("tlayout_data", "id_agente_modulo", $where_modules);
db_process_delete_temp ("treport_content", "id_agent_module", $where_modules); db_process_delete_temp ("treport_content", "id_agent_module", $where_modules);
//Planned Downtime //Planned Downtime
db_process_delete_temp ("tplanned_downtime_agents", "id_agent", $id_agent); db_process_delete_temp ("tplanned_downtime_agents", "id_agent", $id_agent);
//The status of the module //The status of the module
db_process_delete_temp ("tagente_estado", "id_agente", $id_agent); db_process_delete_temp ("tagente_estado", "id_agente", $id_agent);
//The actual modules, don't put anything based on //The actual modules, don't put anything based on
// DONT Delete this, just mark for deletion // DONT Delete this, just mark for deletion
// db_process_delete_temp ("tagente_modulo", "id_agente", $id_agent); // db_process_delete_temp ("tagente_modulo", "id_agente", $id_agent);
db_process_sql_update ('tagente_modulo', db_process_sql_update ('tagente_modulo',
array ('delete_pending' => 1, 'disabled' => 1, 'nombre' => 'pendingdelete'), array ('delete_pending' => 1, 'disabled' => 1, 'nombre' => 'pendingdelete'),
'id_agente = '. $id_agent); 'id_agente = '. $id_agent);
// Access entries // Access entries
// Dont delete here, this records are deleted in daily script // Dont delete here, this records are deleted in daily script
// db_process_delete_temp ("tagent_access", "id_agent", $id_agent); // db_process_delete_temp ("tagent_access", "id_agent", $id_agent);
// Delete agent policies // Delete agent policies
enterprise_hook('policies_delete_agent', array($id_agent)); enterprise_hook('policies_delete_agent', array($id_agent));
// tagente_datos_inc // tagente_datos_inc
// Dont delete here, this records are deleted later, in database script // Dont delete here, this records are deleted later, in database script
// db_process_delete_temp ("tagente_datos_inc", "id_agente_modulo", $where_modules); // db_process_delete_temp ("tagente_datos_inc", "id_agente_modulo", $where_modules);
// Delete remote configuration // Delete remote configuration
if (isset ($config["remote_config"])) { if (isset ($config["remote_config"])) {
$agent_md5 = md5 ($agent_name, FALSE); $agent_md5 = md5 ($agent_name, FALSE);
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) { if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) {
// Agent remote configuration editor // Agent remote configuration editor
$file_name = $config["remote_config"]."/conf/".$agent_md5.".conf"; $file_name = $config["remote_config"]."/conf/".$agent_md5.".conf";
$error = !@unlink ($file_name); $error = !@unlink ($file_name);
if (!$error) { if (!$error) {
$file_name = $config["remote_config"]."/md5/".$agent_md5.".md5"; $file_name = $config["remote_config"]."/md5/".$agent_md5.".md5";
$error = !@unlink ($file_name); $error = !@unlink ($file_name);
@ -1793,19 +1808,19 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
} }
} }
} }
//And at long last, the agent //And at long last, the agent
db_process_delete_temp ("tagente", "id_agente", $id_agent); db_process_delete_temp ("tagente", "id_agente", $id_agent);
db_pandora_audit( "Agent management", db_pandora_audit( "Agent management",
"Deleted agent '$agent_name'"); "Deleted agent '$agent_name'");
/* Break the loop on error */ /* Break the loop on error */
if ($error) if ($error)
break; break;
} }
if ($error) { if ($error) {
db_process_sql_rollback (); db_process_sql_rollback ();
return false; return false;
@ -1909,18 +1924,19 @@ function agents_get_alerts_fired ($id_agent, $filter="") {
return 0; return 0;
} }
$mod_clause = "(".implode(",", $modules_agent).")"; $mod_clause = "(".implode(",", $modules_agent).")";
return db_get_sql ("SELECT COUNT(times_fired) FROM talert_template_modules WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause); return db_get_sql ("SELECT COUNT(times_fired) FROM talert_template_modules WHERE times_fired != 0 AND id_agent_module IN ".$mod_clause);
} }
//Returns the alert image to display tree view //Returns the alert image to display tree view
function agents_tree_view_alert_img ($alert_fired) { function agents_tree_view_alert_img ($alert_fired) {
if ($alert_fired) { if ($alert_fired) {
return ui_print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true); return ui_print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true);
} else { }
else {
return ui_print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true); return ui_print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
} }
} }
@ -1940,8 +1956,6 @@ function agetns_tree_view_status_img ($critical, $warning, $unknown) {
} }
else { else {
return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true); return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
} }
} }
?>
?>

View File

@ -4643,7 +4643,8 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$sql_post .= " AND utimestamp <= " . $utimestamp_bottom; $sql_post .= " AND utimestamp <= " . $utimestamp_bottom;
if ($event_view_hr > 0) { if ($event_view_hr > 0) {
$unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds //Put hours in seconds
$unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR);
$sql_post .= " AND (utimestamp > " . $unixtime . " OR estado = 2)"; $sql_post .= " AND (utimestamp > " . $unixtime . " OR estado = 2)";
} }

View File

@ -326,11 +326,11 @@ function config_process_config () {
// Load user session // Load user session
if (isset ($_SESSION['id_usuario'])) if (isset ($_SESSION['id_usuario']))
$config["id_user"] = $_SESSION["id_usuario"]; $config["id_user"] = $_SESSION["id_usuario"];
if (!isset ($config["round_corner"])) { if (!isset ($config["round_corner"])) {
config_update_value ('round_corner', false); config_update_value ('round_corner', false);
} }
if (!isset ($config["agentaccess"])) { if (!isset ($config["agentaccess"])) {
config_update_value ('agentaccess', true); config_update_value ('agentaccess', true);
} }
@ -338,39 +338,39 @@ function config_process_config () {
if (!isset ($config["timezone"])) { if (!isset ($config["timezone"])) {
config_update_value ('timezone', "Europe/Berlin"); config_update_value ('timezone', "Europe/Berlin");
} }
if (!isset ($config["stats_interval"])) { if (!isset ($config["stats_interval"])) {
config_update_value ('stats_interval', 300); config_update_value ('stats_interval', SECONDS_5MINUTES);
} }
if (!isset ($config["realtimestats"])) { if (!isset ($config["realtimestats"])) {
config_update_value ('realtimestats', 1); config_update_value ('realtimestats', 1);
} }
if (!isset ($config["event_purge"])) { if (!isset ($config["event_purge"])) {
config_update_value ('event_purge', 15); config_update_value ('event_purge', 15);
} }
if (!isset ($config["trap_purge"])) { if (!isset ($config["trap_purge"])) {
config_update_value ('trap_purge', 7); config_update_value ('trap_purge', 7);
} }
if (!isset ($config["string_purge"])) { if (!isset ($config["string_purge"])) {
config_update_value ('string_purge', 14); config_update_value ('string_purge', 14);
} }
if (!isset ($config["audit_purge"])) { if (!isset ($config["audit_purge"])) {
config_update_value ('audit_purge', 30); config_update_value ('audit_purge', 30);
} }
if (!isset ($config["acl_enterprise"])) { if (!isset ($config["acl_enterprise"])) {
config_update_value ('acl_enterprise', 0); config_update_value ('acl_enterprise', 0);
} }
if (!isset ($config["metaconsole"])) { if (!isset ($config["metaconsole"])) {
config_update_value ('metaconsole', 0); config_update_value ('metaconsole', 0);
} }
if (!isset ($config["gis_purge"])) { if (!isset ($config["gis_purge"])) {
config_update_value ('gis_purge', 7); config_update_value ('gis_purge', 7);
} }
@ -415,55 +415,55 @@ function config_process_config () {
if (!isset ($config['fontpath'])) { if (!isset ($config['fontpath'])) {
config_update_value ( 'fontpath', $config['homedir'].'/include/fonts/smallfont.ttf'); config_update_value ( 'fontpath', $config['homedir'].'/include/fonts/smallfont.ttf');
} }
if (!isset ($config['style'])) { if (!isset ($config['style'])) {
config_update_value ( 'style', 'pandora'); config_update_value ( 'style', 'pandora');
} }
if (!isset ($config['flash_charts'])) { if (!isset ($config['flash_charts'])) {
config_update_value ( 'flash_charts', true); config_update_value ( 'flash_charts', true);
} }
if (!isset ($config["custom_logo"])){ if (!isset ($config["custom_logo"])) {
config_update_value ('custom_logo', 'none.png'); config_update_value ('custom_logo', 'none.png');
} }
if (!isset ($config['history_db_enabled'])) { if (!isset ($config['history_db_enabled'])) {
config_update_value ( 'history_db_enabled', false); config_update_value ( 'history_db_enabled', false);
} }
if (!isset ($config['history_db_host'])) { if (!isset ($config['history_db_host'])) {
config_update_value ( 'history_db_host', ''); config_update_value ( 'history_db_host', '');
} }
if (!isset ($config['history_db_port'])) { if (!isset ($config['history_db_port'])) {
config_update_value ( 'history_db_port', 3306); config_update_value ( 'history_db_port', 3306);
} }
if (!isset ($config['history_db_name'])) { if (!isset ($config['history_db_name'])) {
config_update_value ( 'history_db_name', 'pandora'); config_update_value ( 'history_db_name', 'pandora');
} }
if (!isset ($config['history_db_user'])) { if (!isset ($config['history_db_user'])) {
config_update_value ( 'history_db_user', 'pandora'); config_update_value ( 'history_db_user', 'pandora');
} }
if (!isset ($config['history_db_pass'])) { if (!isset ($config['history_db_pass'])) {
config_update_value ( 'history_db_pass', ''); config_update_value ( 'history_db_pass', '');
} }
if (!isset ($config['history_db_days'])) { if (!isset ($config['history_db_days'])) {
config_update_value ( 'history_db_days', 0); config_update_value ( 'history_db_days', 0);
} }
if (!isset ($config['history_db_step'])) { if (!isset ($config['history_db_step'])) {
config_update_value ( 'history_db_step', 0); config_update_value ( 'history_db_step', 0);
} }
if (!isset ($config['history_db_delay'])) { if (!isset ($config['history_db_delay'])) {
config_update_value ( 'history_db_delay', 0); config_update_value ( 'history_db_delay', 0);
} }
if (!isset ($config['activate_gis'])) { if (!isset ($config['activate_gis'])) {
config_update_value ( 'activate_gis', 0); config_update_value ( 'activate_gis', 0);
} }
@ -471,135 +471,135 @@ function config_process_config () {
if (!isset ($config['activate_netflow'])) { if (!isset ($config['activate_netflow'])) {
config_update_value ( 'activate_netflow', 0); config_update_value ( 'activate_netflow', 0);
} }
if (!isset ($config['netflow_path'])) { if (!isset ($config['netflow_path'])) {
config_update_value ( 'netflow_path', '/var/spool/pandora/data_in/netflow'); config_update_value ( 'netflow_path', '/var/spool/pandora/data_in/netflow');
} }
if (!isset ($config['netflow_interval'])) { if (!isset ($config['netflow_interval'])) {
config_update_value ( 'netflow_interval', 300); config_update_value ( 'netflow_interval', SECONDS_5MINUTES);
} }
if (!isset ($config['netflow_daemon'])) { if (!isset ($config['netflow_daemon'])) {
config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd'); config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd');
} }
if (!isset ($config['auth'])) { if (!isset ($config['auth'])) {
config_update_value ( 'auth', 'mysql'); config_update_value ( 'auth', 'mysql');
} }
if (!isset ($config['autocreate_remote_users'])) { if (!isset ($config['autocreate_remote_users'])) {
config_update_value ('autocreate_remote_users', 0); config_update_value ('autocreate_remote_users', 0);
} }
if (!isset ($config['autocreate_blacklist'])) { if (!isset ($config['autocreate_blacklist'])) {
config_update_value ('autocreate_blacklist', ''); config_update_value ('autocreate_blacklist', '');
} }
if (!isset ($config['default_remote_profile'])) { if (!isset ($config['default_remote_profile'])) {
config_update_value ('default_remote_profile', 0); config_update_value ('default_remote_profile', 0);
} }
if (!isset ($config['default_remote_group'])) { if (!isset ($config['default_remote_group'])) {
config_update_value ('default_remote_group', 0); config_update_value ('default_remote_group', 0);
} }
if (!isset ($config['ldap_server'])) { if (!isset ($config['ldap_server'])) {
config_update_value ( 'ldap_server', 'localhost'); config_update_value ( 'ldap_server', 'localhost');
} }
if (!isset ($config['ldap_port'])) { if (!isset ($config['ldap_port'])) {
config_update_value ( 'ldap_port', 389); config_update_value ( 'ldap_port', 389);
} }
if (!isset ($config['ldap_version'])) { if (!isset ($config['ldap_version'])) {
config_update_value ( 'ldap_version', '3'); config_update_value ( 'ldap_version', '3');
} }
if (!isset ($config['ldap_start_tls'])) { if (!isset ($config['ldap_start_tls'])) {
config_update_value ( 'ldap_start_tls', 0); config_update_value ( 'ldap_start_tls', 0);
} }
if (!isset ($config['ldap_base_dn'])) { if (!isset ($config['ldap_base_dn'])) {
config_update_value ( 'ldap_base_dn', 'ou=People,dc=edu,dc=example,dc=org'); config_update_value ( 'ldap_base_dn', 'ou=People,dc=edu,dc=example,dc=org');
} }
if (!isset ($config['ldap_login_attr'])) { if (!isset ($config['ldap_login_attr'])) {
config_update_value ( 'ldap_login_attr', 'uid'); config_update_value ( 'ldap_login_attr', 'uid');
} }
if (!isset ($config['ad_server'])) { if (!isset ($config['ad_server'])) {
config_update_value ( 'ad_server', 'localhost'); config_update_value ( 'ad_server', 'localhost');
} }
if (!isset ($config['ad_port'])) { if (!isset ($config['ad_port'])) {
config_update_value ( 'ad_port', 389); config_update_value ( 'ad_port', 389);
} }
if (!isset ($config['ad_start_tls'])) { if (!isset ($config['ad_start_tls'])) {
config_update_value ( 'ad_start_tls', 0); config_update_value ( 'ad_start_tls', 0);
} }
if (!isset ($config['ad_domain'])) { if (!isset ($config['ad_domain'])) {
config_update_value ( 'ad_domain', ''); config_update_value ( 'ad_domain', '');
} }
if (!isset ($config['rpandora_server'])) { if (!isset ($config['rpandora_server'])) {
config_update_value ( 'rpandora_server', 'localhost'); config_update_value ( 'rpandora_server', 'localhost');
} }
if (!isset ($config['rpandora_port'])) { if (!isset ($config['rpandora_port'])) {
config_update_value ( 'rpandora_port', 3306); config_update_value ( 'rpandora_port', 3306);
} }
if (!isset ($config['rpandora_dbname'])) { if (!isset ($config['rpandora_dbname'])) {
config_update_value ( 'rpandora_dbname', 'pandora'); config_update_value ( 'rpandora_dbname', 'pandora');
} }
if (!isset ($config['rpandora_user'])) { if (!isset ($config['rpandora_user'])) {
config_update_value ( 'rpandora_user', 'pandora'); config_update_value ( 'rpandora_user', 'pandora');
} }
if (!isset ($config['rpandora_pass'])) { if (!isset ($config['rpandora_pass'])) {
config_update_value ( 'rpandora_pass', ''); config_update_value ( 'rpandora_pass', '');
} }
if (!isset ($config['rbabel_server'])) { if (!isset ($config['rbabel_server'])) {
config_update_value ( 'rbabel_server', 'localhost'); config_update_value ( 'rbabel_server', 'localhost');
} }
if (!isset ($config['rbabel_port'])) { if (!isset ($config['rbabel_port'])) {
config_update_value ( 'rbabel_port', 3306); config_update_value ( 'rbabel_port', 3306);
} }
if (!isset ($config['rbabel_dbname'])) { if (!isset ($config['rbabel_dbname'])) {
config_update_value ( 'rbabel_dbname', 'babel'); config_update_value ( 'rbabel_dbname', 'babel');
} }
if (!isset ($config['rbabel_user'])) { if (!isset ($config['rbabel_user'])) {
config_update_value ( 'rbabel_user', 'babel'); config_update_value ( 'rbabel_user', 'babel');
} }
if (!isset ($config['rbabel_pass'])) { if (!isset ($config['rbabel_pass'])) {
config_update_value ( 'rbabel_pass', ''); config_update_value ( 'rbabel_pass', '');
} }
if (!isset ($config['rintegria_server'])) { if (!isset ($config['rintegria_server'])) {
config_update_value ( 'rintegria_server', 'localhost'); config_update_value ( 'rintegria_server', 'localhost');
} }
if (!isset ($config['rintegria_port'])) { if (!isset ($config['rintegria_port'])) {
config_update_value ( 'rintegria_port', 3306); config_update_value ( 'rintegria_port', 3306);
} }
if (!isset ($config['rintegria_dbname'])) { if (!isset ($config['rintegria_dbname'])) {
config_update_value ( 'rintegria_dbname', 'integria'); config_update_value ( 'rintegria_dbname', 'integria');
} }
if (!isset ($config['rintegria_user'])) { if (!isset ($config['rintegria_user'])) {
config_update_value ( 'rintegria_user', 'integria'); config_update_value ( 'rintegria_user', 'integria');
} }
if (!isset ($config['rintegria_pass'])) { if (!isset ($config['rintegria_pass'])) {
config_update_value ( 'rintegria_pass', ''); config_update_value ( 'rintegria_pass', '');
} }

View File

@ -46,8 +46,8 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
// Prevents bad behaviour over image error // Prevents bad behaviour over image error
else if (!is_array($module_data) and preg_match('/^<img(.)*$/', $module_data)) { else if (!is_array($module_data) and preg_match('/^<img(.)*$/', $module_data)) {
return; return;
} }
// Data initialization // Data initialization
$sum_obs = 0; $sum_obs = 0;
$sum_xi = 0; $sum_xi = 0;
@ -55,14 +55,14 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$sum_xi_yi = 0; $sum_xi_yi = 0;
$sum_xi2 = 0; $sum_xi2 = 0;
$sum_yi2 = 0; $sum_yi2 = 0;
$sum_diff_dates = 0; $sum_diff_dates = 0;
$last_timestamp = get_system_time(); $last_timestamp = get_system_time();
$agent_interval = 300; $agent_interval = SECONDS_5MINUTES;
$cont = 1; $cont = 1;
$data = array(); $data = array();
//$table->data = array(); //$table->data = array();
// Creates data for calculation // Creates data for calculation
foreach ($module_data as $utimestamp => $row) { foreach ($module_data as $utimestamp => $row) {
if ($utimestamp == '') { if ($utimestamp == '') {
continue; continue;
@ -76,12 +76,12 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$data[5] = $utimestamp * $row['sum']; $data[5] = $utimestamp * $row['sum'];
$data[6] = $utimestamp * $utimestamp; $data[6] = $utimestamp * $utimestamp;
$data[7] = $row['sum'] * $row['sum']; $data[7] = $row['sum'] * $row['sum'];
if ($cont == 1){ if ($cont == 1) {
$data[8] = 0; $data[8] = 0;
} }
else { else {
$data[8] = $utimestamp - $last_timestamp; $data[8] = $utimestamp - $last_timestamp;
} }
$sum_obs = $sum_obs + $cont; $sum_obs = $sum_obs + $cont;
$sum_xi = $sum_xi + $utimestamp; $sum_xi = $sum_xi + $utimestamp;
@ -89,13 +89,11 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$sum_xi_yi = $sum_xi_yi + $data[5]; $sum_xi_yi = $sum_xi_yi + $data[5];
$sum_xi2 = $sum_xi2 + $data[6]; $sum_xi2 = $sum_xi2 + $data[6];
$sum_yi2 = $sum_yi2 + $data[7]; $sum_yi2 = $sum_yi2 + $data[7];
$sum_diff_dates = $sum_diff_dates + $data[8]; $sum_diff_dates = $sum_diff_dates + $data[8];
$last_timestamp = $utimestamp; $last_timestamp = $utimestamp;
$cont++; $cont++;
}
//array_push($table->data, $data);
}
$cont--; $cont--;
// Calculation over data above: // Calculation over data above:
@ -117,12 +115,17 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x)); $dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x));
$dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y)); $dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y));
// Prevents division by zero // Prevents division by zero
if ($dev_x != 0 and $dev_y != 0){ if ($dev_x != 0 and $dev_y != 0) {
$linear_coef = $covariance / ($dev_x * $dev_y); $linear_coef = $covariance / ($dev_x * $dev_y);
} }
// Agent interval could be zero, 300 is the predefined // Agent interval could be zero, 300 is the predefined
($sum_obs == 0)? $agent_interval = 300 : $agent_interval = $sum_diff_dates / $sum_obs; if ($sum_obs == 0) {
$agent_interval = SECONDS_5MINUTES;
}
else {
$agent_interval = $sum_diff_dates / $sum_obs;
}
// Could be a inverse correlation coefficient // Could be a inverse correlation coefficient
// if $linear_coef < 0.0 // if $linear_coef < 0.0
// if $linear_coef >= -1.0 and $linear_coef <= -0.8999 // if $linear_coef >= -1.0 and $linear_coef <= -0.8999
@ -141,15 +144,16 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi)); $b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi));
$b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi)); $b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi));
if ($b_den == 0) return; if ($b_den == 0)
return;
$b = $b_num / $b_den; $b = $b_num / $b_den;
$a_num = ($sum_yi) - ($b * $sum_xi); $a_num = ($sum_yi) - ($b * $sum_xi);
$a = $a_num / $cont; $a = $a_num / $cont;
// Data inicialization // Data inicialization
$output_data = array(); $output_data = array();
if ($prediction_period != false){ if ($prediction_period != false) {
$limit_timestamp = $last_timestamp + $prediction_period; $limit_timestamp = $last_timestamp + $prediction_period;
} }
$current_ts = $last_timestamp; $current_ts = $last_timestamp;
@ -160,17 +164,17 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
if ($period < $prediction_period) if ($period < $prediction_period)
$temp_range = $prediction_period; $temp_range = $prediction_period;
if ($temp_range <= 21600) { if ($temp_range <= SECONDS_6HOURS) {
$time_format = 'H:i:s'; $time_format = 'H:i:s';
} }
elseif ($temp_range < 86400) { elseif ($temp_range < SECONDS_1DAY) {
$time_format = 'H:i'; $time_format = 'H:i';
} }
elseif ($temp_range < 1296000) { elseif ($temp_range < SECONDS_15DAYS) {
$time_format = 'M d'; $time_format = 'M d';
$time_format_2 = 'H\h'; $time_format_2 = 'H\h';
} }
elseif ($temp_range <= 2592000) { elseif ($temp_range <= SECONDS_1MONTH) {
$time_format = 'M d'; $time_format = 'M d';
$time_format_2 = 'H\h'; $time_format_2 = 'H\h';
} }
@ -182,38 +186,39 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$output_data = array(); $output_data = array();
$idx = 0; $idx = 0;
// Create data in graph format like // Create data in graph format like
while ($in_range){ while ($in_range) {
$timestamp_f = date($time_format, $current_ts); $timestamp_f = date($time_format, $current_ts);
//$timestamp_f = date($time_format, $current_ts); //$timestamp_f = date($time_format, $current_ts);
$timestamp_f = graph_get_formatted_date($current_ts, $time_format, $time_format_2); $timestamp_f = graph_get_formatted_date($current_ts, $time_format, $time_format_2);
if ($csv){ if ($csv) {
$output_data[$idx]['date'] = $current_ts; $output_data[$idx]['date'] = $current_ts;
$output_data[$idx]['data'] = ($a + ($b * $current_ts)); $output_data[$idx]['data'] = ($a + ($b * $current_ts));
} }
else{ else {
$output_data[$timestamp_f] = ($a + ($b * $current_ts)); $output_data[$timestamp_f] = ($a + ($b * $current_ts));
} }
// Using this function for prediction_date // Using this function for prediction_date
if ($prediction_period == false){ if ($prediction_period == false) {
// These statements stop the prediction when interval is greater than 2 years // These statements stop the prediction when interval is greater than 2 years
if ($current_ts - $last_timestamp >= 94608000){ if ($current_ts - $last_timestamp >= 94608000) {
return false; return false;
} }
//html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]); //html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]);
// Found it // Found it
if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){ if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){
return $current_ts; return $current_ts;
} }
}else if ($current_ts > $limit_timestamp){ }
else if ($current_ts > $limit_timestamp) {
$in_range = false; $in_range = false;
} }
$current_ts = $current_ts + $agent_interval; $current_ts = $current_ts + $agent_interval;
$idx++; $idx++;
} }
return $output_data; return $output_data;
} }
@ -229,9 +234,9 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
*/ */
function forecast_prediction_date ($module_id, $period = 5184000, $max_value = 0, $min_value = 0){ function forecast_prediction_date ($module_id, $period = 5184000, $max_value = 0, $min_value = 0){
// Checks interval // Checks interval
if ($min_value > $max_value){ if ($min_value > $max_value) {
return false; return false;
} }
return forecast_projection_graph($module_id, $period, false, $max_value, $min_value); return forecast_projection_graph($module_id, $period, false, $max_value, $min_value);
} }

View File

@ -20,10 +20,10 @@ check_login();
if (isset($_GET["id_agente"])){ if (isset($_GET["id_agente"])){
$id_agente = $_GET["id_agente"]; $id_agente = $_GET["id_agente"];
} }
include_once($config['homedir'] . "/include/functions_modules.php"); include_once($config['homedir'] . "/include/functions_modules.php");
// View last data packet // View last data packet
// Get timestamp of last packet // Get timestamp of last packet
$agent = db_get_row ('tagente', 'id_agente', $id_agente, $agent = db_get_row ('tagente', 'id_agente', $id_agente,
array ('ultimo_contacto_remoto', array ('ultimo_contacto_remoto',
@ -180,12 +180,12 @@ $extra_sql = '';
// Build the order sql // Build the order sql
if(!empty($order)) { if (!empty($order)) {
$order_sql = ' ORDER BY '; $order_sql = ' ORDER BY ';
} }
$first = true; $first = true;
foreach($order as $ord) { foreach ($order as $ord) {
if($first) { if ($first) {
$first = false; $first = false;
} }
else { else {
@ -232,20 +232,20 @@ switch ($config["dbtype"]) {
case "postgresql": case "postgresql":
$limit_sql = " LIMIT $limit OFFSET $offset "; $limit_sql = " LIMIT $limit OFFSET $offset ";
case "mysql": case "mysql":
if(!isset($limit_sql)) { if (!isset($limit_sql)) {
$limit_sql = " LIMIT $offset, $limit "; $limit_sql = " LIMIT $offset, $limit ";
} }
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC'); $order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
$sql = sprintf("SELECT %s FROM tagente_modulo, tagente_estado WHERE %s (%s %s) %s %s", $sql = sprintf("SELECT %s FROM tagente_modulo, tagente_estado WHERE %s (%s %s) %s %s",
$params, $basic_where, $extra_sql, $where, $order_sql, $limit_sql); $params, $basic_where, $extra_sql, $where, $order_sql, $limit_sql);
$modules = db_get_all_rows_sql($sql); $modules = db_get_all_rows_sql($sql);
break; break;
case "oracle": case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC'); $order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC');
$set = array(); $set = array();
$set['limit'] = $limit; $set['limit'] = $limit;
$set['offset'] = $offset; $set['offset'] = $offset;
@ -276,16 +276,16 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
echo "<th><span title='" . __('Policy') . "'>".__('P.')."</span></th>"; echo "<th><span title='" . __('Policy') . "'>".__('P.')."</span></th>";
} }
echo "<th>".__('Module name') . ' ' . echo "<th>".__('Module name') . ' ' .
'<a href="' . $url . '&amp;sort_field=name&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' . '<a href="' . $url . '&amp;sort_field=name&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&amp;sort_field=name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>'; '<a href="' . $url . '&amp;sort_field=name&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</a>';
echo "</th>"; echo "</th>";
echo "<th>".__('Type') . ' ' . echo "<th>".__('Type') . ' ' .
'<a href="' . $url . '&amp;sort_field=type&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectTypeUp, "alt" => "up")) . '</a>' . '<a href="' . $url . '&amp;sort_field=type&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectTypeUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&amp;sort_field=type&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTypeDown, "alt" => "down")) . '</a>'; '<a href="' . $url . '&amp;sort_field=type&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTypeDown, "alt" => "down")) . '</a>';
echo "</th>"; echo "</th>";
echo "<th>".__('int') . ' ' . echo "<th>".__('int') . ' ' .
'<a href="' . $url . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' . '<a href="' . $url . '&amp;sort_field=interval&amp;sort=up">' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp, "alt" => "up")) . '</a>' .
'<a href="' . $url . '&amp;sort_field=interval&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . '</a>'; '<a href="' . $url . '&amp;sort_field=interval&amp;sort=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . '</a>';
echo "</th>"; echo "</th>";
echo "<th>".__('Description') . "</th>"; echo "<th>".__('Description') . "</th>";
echo "<th>".__('Data') . ' ' . echo "<th>".__('Data') . ' ' .
@ -303,7 +303,7 @@ $color = 1;
$write = check_acl ($config['id_user'], $agent['id_grupo'], "AW"); $write = check_acl ($config['id_user'], $agent['id_grupo'], "AW");
foreach ($modules as $module) { foreach ($modules as $module) {
// Calculate table line color // Calculate table line color
if ($color == 1){ if ($color == 1) {
$tdcolor = "datos"; $tdcolor = "datos";
$color = 0; $color = 0;
} }
@ -312,7 +312,7 @@ foreach ($modules as $module) {
$color = 1; $color = 1;
} }
if ($module["id_module_group"] != $last_modulegroup ){ if ($module["id_module_group"] != $last_modulegroup ) {
// Render module group names (fixed code) // Render module group names (fixed code)
$nombre_grupomodulo = modules_get_modulegroup_name ($module["id_module_group"]); $nombre_grupomodulo = modules_get_modulegroup_name ($module["id_module_group"]);
$last_modulegroup = $module["id_module_group"]; $last_modulegroup = $module["id_module_group"];
@ -338,7 +338,7 @@ foreach ($modules as $module) {
echo "</td>"; echo "</td>";
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
if($module["id_policy_module"] != 0) { if ($module["id_policy_module"] != 0) {
$linked = policies_is_module_linked($module['id_agente_modulo']); $linked = policies_is_module_linked($module['id_agente_modulo']);
$id_policy = db_get_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]); $id_policy = db_get_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]);
$name_policy = db_get_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy); $name_policy = db_get_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy);
@ -382,7 +382,7 @@ foreach ($modules as $module) {
} }
} }
$nombre_grupomodulo = modules_get_modulegroup_name ($module["id_module_group"]); $nombre_grupomodulo = modules_get_modulegroup_name ($module["id_module_group"]);
if ($nombre_grupomodulo != ""){ if ($nombre_grupomodulo != "") {
if (($label_group == 0) || ($last_label != $nombre_grupomodulo)){ // Show label module group if (($label_group == 0) || ($last_label != $nombre_grupomodulo)){ // Show label module group
$label_group = -1; $label_group = -1;
$last_label = $nombre_grupomodulo; $last_label = $nombre_grupomodulo;
@ -416,7 +416,7 @@ foreach ($modules as $module) {
echo ui_print_truncate_text(io_safe_output($module["descripcion"]), 'description', false); echo ui_print_truncate_text(io_safe_output($module["descripcion"]), 'description', false);
echo "</td>"; echo "</td>";
} }
else{ else {
echo "<td></td>"; echo "<td></td>";
} }
@ -454,7 +454,7 @@ foreach ($modules as $module) {
io_safe_output(io_safe_output($module["datos"]), 45, false); io_safe_output(io_safe_output($module["datos"]), 45, false);
} }
echo "</td>"; echo "</td>";
$handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"]; $handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"];
$url = 'include/procesos.php?agente='.$module["id_agente_modulo"]; $url = 'include/procesos.php?agente='.$module["id_agente_modulo"];
$win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"])); $win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
@ -504,4 +504,4 @@ foreach ($modules as $module) {
} }
echo '</table>'; echo '</table>';
?> ?>

View File

@ -59,7 +59,8 @@ $filename_map .= "_".$id_networkmap.".map";
$filename_img .= "_".$id_networkmap.".png"; $filename_img .= "_".$id_networkmap.".png";
$filename_dot .= "_".$id_networkmap.".dot"; $filename_dot .= "_".$id_networkmap.".dot";
if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) { if ($regen != 1 && file_exists ($filename_img) &&
filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) {
$result = true; $result = true;
} }
else { else {

View File

@ -37,6 +37,7 @@ $graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size
if ($graph === false) { if ($graph === false) {
ui_print_error_message (__('Map could not be generated')); ui_print_error_message (__('Map could not be generated'));
echo '<div class="nf">' . __('No agents found') . '</div>'; echo '<div class="nf">' . __('No agents found') . '</div>';
return; return;
} }
@ -59,7 +60,8 @@ $filename_map .= "_".$id_networkmap.".map";
$filename_img .= "_".$id_networkmap.".png"; $filename_img .= "_".$id_networkmap.".png";
$filename_dot .= "_".$id_networkmap.".dot"; $filename_dot .= "_".$id_networkmap.".dot";
if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) { if ($regen != 1 && file_exists ($filename_img) &&
filemtime ($filename_img) > get_system_time () - SECONDS_5MINUTES) {
$result = true; $result = true;
} }
else { else {
@ -83,6 +85,7 @@ if ($result !== false) {
echo "<div class='warn'>Apparently something went wrong reading the output.</div>"; echo "<div class='warn'>Apparently something went wrong reading the output.</div>";
echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?"; echo "<br />Is ".$config["attachment_store"]." readable by the webserver process?";
echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?"; echo "<br /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
return; return;
} }
html_print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); html_print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
@ -95,6 +98,7 @@ else {
echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?"; echo "<br />Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)"; echo "<br /><br /> Is your webserver restricted from executing command line tools through the <code>system()</code> call (PHP Safe Mode or SELinux)";
echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown &lt;apache user&gt; ".$config["attachment_store"]; echo "<br /><br /> Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown &lt;apache user&gt; ".$config["attachment_store"];
return; return;
} }

View File

@ -80,11 +80,11 @@ visual_map_print_visual_map ($id_layout, true, true, null, null, '../../');
$values = array (); $values = array ();
$values[5] = human_time_description_raw (5); $values[5] = human_time_description_raw (5);
$values[30] = human_time_description_raw (30); $values[30] = human_time_description_raw (30);
$values[60] = human_time_description_raw (60); $values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE);
$values[120] = human_time_description_raw (120); $values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES);
$values[300] = human_time_description_raw (300); $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
$values[600] = human_time_description_raw (600); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
$values[1800] = human_time_description_raw (1800); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
$table->width = '90%'; $table->width = '90%';
$table->data = array (); $table->data = array ();
@ -92,9 +92,9 @@ $table->style = array ();
$table->style[2] = 'text-align: center'; $table->style[2] = 'text-align: center';
$table->data[0][0] = __('Autorefresh time'); $table->data[0][0] = __('Autorefresh time');
if (empty($config["vc_refr"])){ if (empty($config["vc_refr"])) {
$vc_refr = true; $vc_refr = true;
$config["vc_refr"] = $refr; $config["vc_refr"] = $refr;
} }
$table->data[0][1] = html_print_select ($values, 'refr', $config["vc_refr"], '', 'N/A', 0, true, false, false); $table->data[0][1] = html_print_select ($values, 'refr', $config["vc_refr"], '', 'N/A', 0, true, false, false);
@ -130,17 +130,21 @@ ui_require_javascript_file ('pandora_visual_console');
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
$(document).ready (function () { $(document).ready (function () {
$("#refr").change(function () { $("#refr").change(function () {
$("#hidden-vc_refr").val($("#refr option:selected").val()); $("#hidden-vc_refr").val($("#refr option:selected").val());
}); });
<?php if ($config["pure"] && $config["refr"] > 0): ?> <?php
t = new Date(); if ($config["pure"] && $config["refr"] > 0) {
t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>); ?>
$("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'}); t = new Date();
t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>);
$("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'});
<?php endif; ?> <?php
}
?>
draw_lines (lines, 'layout_map'); draw_lines (lines, 'layout_map');
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -88,11 +88,11 @@ visual_map_print_visual_map ($id_layout);
$values = array (); $values = array ();
$values[5] = human_time_description_raw (5); $values[5] = human_time_description_raw (5);
$values[30] = human_time_description_raw (30); $values[30] = human_time_description_raw (30);
$values[60] = human_time_description_raw (60); $values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE);
$values[120] = human_time_description_raw (120); $values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES);
$values[300] = human_time_description_raw (300); $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
$values[600] = human_time_description_raw (600); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
$values[1800] = human_time_description_raw (1800); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
$table->width = '90%'; $table->width = '90%';
$table->data = array (); $table->data = array ();
@ -100,17 +100,17 @@ $table->style = array ();
$table->style[2] = 'text-align: center'; $table->style[2] = 'text-align: center';
$table->data[0][0] = __('Autorefresh time'); $table->data[0][0] = __('Autorefresh time');
if (empty($config["vc_refr"])){ if (empty($config["vc_refr"])) {
$vc_refr = true; $vc_refr = true;
$config["vc_refr"] = $refr; $config["vc_refr"] = $refr;
} }
$table->data[0][1] = html_print_select ($values, 'refr', $config["vc_refr"], '', 'N/A', 0, true, false, false); $table->data[0][1] = html_print_select ($values, 'refr', $config["vc_refr"], '', 'N/A', 0, true, false, false);
$table->data[0][2] = html_print_submit_button (__('Refresh'), '', false, 'class="sub next"', true); $table->data[0][2] = html_print_submit_button (__('Refresh'), '', false, 'class="sub next"', true);
$table->data[0][2] .= html_print_input_hidden ('vc_refr', $config["vc_refr"], true); $table->data[0][2] .= html_print_input_hidden ('vc_refr', $config["vc_refr"], true);
if ($vc_refr){ if ($vc_refr) {
$config["vc_refr"] = 0; $config["vc_refr"] = 0;
} }
echo '<div style="height:30px">&nbsp;</div>'; echo '<div style="height:30px">&nbsp;</div>';
@ -137,17 +137,21 @@ ui_require_javascript_file ('pandora_visual_console');
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
$(document).ready (function () { $(document).ready (function () {
$("#refr").change(function () { $("#refr").change(function () {
$("#hidden-vc_refr").val($("#refr option:selected").val()); $("#hidden-vc_refr").val($("#refr option:selected").val());
}); });
<?php if ($config["pure"] && $config["refr"] > 0): ?> <?php
t = new Date(); if ($config["pure"] && $config["refr"] > 0) {
t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>); ?>
$("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'}); t = new Date();
t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>);
$("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'});
<?php endif; ?> <?php
}
?>
draw_lines (lines, 'layout_map'); draw_lines (lines, 'layout_map');
}); });
/* ]]> */ /* ]]> */
</script> </script>