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 a437aba1c0
commit 23cccf20ed
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>
* operation/tree.php: Removed trace.

View File

@ -24,7 +24,7 @@ function mainAgentsAlerts() {
// Load global vars
require_once ("include/config.php");
require_once ("include/functions_reporting.php");
check_login ();
// ACL Check
if (! check_acl ($config['id_user'], 0, "AR")) {
@ -33,7 +33,7 @@ function mainAgentsAlerts() {
require ("general/noaccess.php");
exit;
}
// Update network modules for this group
// Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side
@ -50,7 +50,7 @@ function mainAgentsAlerts() {
exit;
}
}
if ($config["realtimestats"] == 0) {
$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;
$refr = get_parameter('refr', 30); // By default 30 seconds
$group_id = get_parameter('group_id', 0);
$offset = get_parameter('offset', 0);
$hor_offset = get_parameter('hor_offset', 0);
$block = 20;
$groups = users_get_groups ();
$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 .= '<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>";
if ($config["pure"] == 0) {
@ -92,38 +98,41 @@ function mainAgentsAlerts() {
}
$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;
}
// Header
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
// Prepare old-style table
$filter = array ('offset' => (int) $offset,
'limit' => (int) $config['block_size']);
'limit' => (int) $config['block_size']);
$filter_count = array();
if($group_id > 0) {
if ($group_id > 0) {
$filter['id_grupo'] = $group_id;
$filter_count['id_grupo'] = $group_id;
}
// Get the id of all agents with alerts
$sql = 'SELECT DISTINCT(id_agente) FROM tagente_modulo WHERE id_agente_modulo IN
(SELECT id_agent_module FROM talert_template_modules)';
$sql = 'SELECT DISTINCT(id_agente)
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);
if($agents_with_alerts_raw === false) {
if ($agents_with_alerts_raw === false) {
$agents_with_alerts_raw = 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'];
}
@ -131,11 +140,11 @@ function mainAgentsAlerts() {
$filter_count['id_agente'] = $agents_with_alerts;
$agents = agents_get_agents ($filter);
$nagents = count(agents_get_agents ($filter_count));
if($agents == false) {
echo "<div class='nf'>".__('There are no agents with alerts')."</div>";
if ($agents == false) {
echo "<div class='nf'>" . __('There are no agents with alerts')."</div>";
return;
}
@ -147,7 +156,7 @@ function mainAgentsAlerts() {
$templates = array();
$agent_alerts = array();
foreach($all_alerts as $alert) {
foreach ($all_alerts as $alert) {
$templates[$alert['id_alert_template']] = '';
$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 "<th width='140px' height='25px'>".__("Agents")." / ".__("Alert templates")."</th>";
if($hor_offset > 0) {
if ($hor_offset > 0) {
$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>";
}
if(!empty($templates)) {
$sql = sprintf('SELECT id, name FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates)));
if (!empty($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);
}
$alerts = array();
$ntemplates = 0;
foreach($templates_raw as $temp) {
if(isset($templates[$temp['id']]) && $templates[$temp['id']] == '') {
foreach ($templates_raw as $temp) {
if (isset($templates[$temp['id']]) && $templates[$temp['id']] == '') {
$ntemplates++;
if($ntemplates <= $hor_offset || $ntemplates > ($hor_offset+$block)) {
if ($ntemplates <= $hor_offset || $ntemplates > ($hor_offset+$block)) {
continue;
}
$templates[$temp['id']] = $temp['name'];
}
}
foreach($templates as $tid => $tname) {
if($tname == '') {
foreach ($templates as $tid => $tname) {
if ($tname == '') {
continue;
}
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;
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>';
// Name of the agent
echo '<td style="font-weight:bold;">'.$agent['nombre'].'</td>';
// Alerts of the agent
$anyfired = false;
foreach($templates as $tid => $tname) {
if($tname == '') {
foreach ($templates as $tid => $tname) {
if ($tname == '') {
continue;
}
if(isset($agent_alerts[$agent['nombre']][$tid])) {
if (isset($agent_alerts[$agent['nombre']][$tid])) {
foreach($agent_alerts[$agent['nombre']][$tid] as $alert) {
if($alert["times_fired"] > 0) {
$anyfired = true;
@ -247,7 +257,7 @@ function print_alerts_summary_modal_window($id, $alerts) {
$table->width = '98%';
$table->class = "databox";
$table->data = array ();
$table->head[0] = __('Module');
$table->head[1] = __('Action');
$table->head[2] = __('Last fired');

View File

@ -24,7 +24,7 @@ function mainAgentsModules() {
// Load global vars
require_once ("include/config.php");
require_once ("include/functions_reporting.php");
check_login ();
// ACL Check
if (! check_acl ($config['id_user'], 0, "AR")) {
@ -33,7 +33,7 @@ function mainAgentsModules() {
require ("general/noaccess.php");
exit;
}
// Update network modules for this group
// Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side
@ -50,8 +50,8 @@ function mainAgentsModules() {
exit;
}
}
if ($config["realtimestats"] == 0) {
$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;
$modulegroup = get_parameter('modulegroup', 0);
$refr = get_parameter('refr', 30); // By default 30 seconds
$group_id = get_parameter('group_id', 0);
$offset = get_parameter('offset', 0);
$hor_offset = get_parameter('hor_offset', 0);
$block = 20;
$groups = users_get_groups ();
$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 .= 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 .= '<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>";
if ($config["pure"] == 0) {
@ -100,37 +106,37 @@ function mainAgentsModules() {
}
$onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen,
'combo_module_groups' => $filter_module_groups,
'combo_groups' => $filter_groups);
'combo_module_groups' => $filter_module_groups,
'combo_groups' => $filter_groups);
if($config['pure'] == 1) {
if ($config['pure'] == 1) {
$onheader['combo_refr'] = $comborefr;
}
// Header
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
// Prepare old-style table
$agents = '';
if($group_id > 0) {
if ($group_id > 0) {
$agents = agents_get_group_agents($group_id);
$agents = array_keys($agents);
}
$filter_module_groups = false;
if($modulegroup > 0) {
if ($modulegroup > 0) {
$filter_module_groups['id_module_group'] = $modulegroup;
}
$all_modules = agents_get_modules($agents, false, $filter_module_groups, true, false);
$modules_by_name = array();
$name = '';
$cont = 0;
foreach($all_modules as $key => $module) {
if($module == $name) {
$modules_by_name[$cont-1]['id'][] = $key;
@ -146,10 +152,10 @@ function mainAgentsModules() {
if($config["pure"] == 1) {
$block = count($modules_by_name);
}
$filter_groups = array ('offset' => (int) $offset,
'limit' => (int) $config['block_size']);
'limit' => (int) $config['block_size']);
if($group_id > 0) {
$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>";
}
$nmodules = 0;
foreach($modules_by_name as $module) {
foreach ($modules_by_name as $module) {
$nmodules++;
if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) {
if ($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) {
continue;
}
@ -265,9 +271,9 @@ function mainAgentsModules() {
echo '</a>';
echo "</td>";
$match = true;
}
}
}
if(!$match) {
echo "<td></td>";
}
@ -275,7 +281,7 @@ function mainAgentsModules() {
echo "</tr>";
}
echo "</table>";
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_main_function('mainAgentsModules');
?>
?>

View File

@ -29,28 +29,31 @@ function users_extension_main_god ($god = true) {
// Header
ui_print_page_header (__("Users connected"), "images/group.png", false, "", $god);
// Get user conected last 5 minutes
switch ($config["dbtype"]) {
case "mysql":
$sql = "SELECT id_user, last_connect
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;
case "postgresql":
$sql = "SELECT id_user, last_connect
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;
case "oracle":
$sql = "SELECT id_user, last_connect
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;
}
$rows = db_get_all_rows_sql ($sql);
if (empty ($rows)) {
$rows = array ();
echo "<div class='nf'>".__('No other users connected')."</div>";
@ -63,14 +66,14 @@ function users_extension_main_god ($god = true) {
$table->size = array ();
$table->data = array ();
$table->head = array ();
$table->head[0] = __('User');
$table->head[1] = __('IP');
$table->head[2] = __('Date');
$rowPair = true;
$iterator = 0;
// Get data
foreach ($rows as $row) {
// Get ip_origin of the last login of the user
@ -78,34 +81,34 @@ function users_extension_main_god ($god = true) {
case "mysql":
case "postgresql":
$ip_origin = db_get_value_sql(sprintf("SELECT ip_origen
FROM tsesion
WHERE id_usuario = '%s'
AND descripcion = '" . io_safe_input('Logged in') . "'
ORDER BY fecha DESC",$row["id_user"]));
FROM tsesion
WHERE id_usuario = '%s'
AND descripcion = '" . io_safe_input('Logged in') . "'
ORDER BY fecha DESC",$row["id_user"]));
break;
case "oracle":
$ip_origin = db_get_value_sql(sprintf("SELECT ip_origen
FROM tsesion
WHERE id_usuario = '%s'
AND to_char(descripcion) = '" . io_safe_input('Logged in') . "'
ORDER BY fecha DESC",$row["id_user"]));
FROM tsesion
WHERE id_usuario = '%s'
AND to_char(descripcion) = '" . io_safe_input('Logged in') . "'
ORDER BY fecha DESC",$row["id_user"]));
break;
}
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$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[1] = $ip_origin;
$data[2] = date($config["date_format"], $row['last_connect']);
array_push ($table->data, $data);
}
html_print_table ($table);
}
}

View File

@ -34,9 +34,10 @@ config_check();
<td rowspan="2">
<a href="index.php?sec=main">
<?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'));
} else {
}
else {
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);
if ($config['metaconsole'] == 1) {
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')));
}
echo '</td>';
echo '<td width="20%">';
if ($config["metaconsole"] == 0){
}
?>
</td>
<td width="20%">
<?php
if ($config["metaconsole"] == 0) {
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');
@ -123,8 +124,7 @@ config_check();
unset ($servers); // Since this is the header, we don't like to trickle down variables.
echo '</a>';
}
?>
?>
</td>
<td width="20%">
<?php
@ -140,82 +140,76 @@ config_check();
$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>';
$values = array (
'5' => '5 '.__('seconds'),
'10' => '10 '.__('seconds'),
'15' => '15 '.__('seconds'),
'30' => '30 '.__('seconds'),
'60' => '1 '.__('minute'),
'120' => '2 '.__('minutes'),
'300' => '5 '.__('minutes'),
'900' => '15 '.__('minutes'),
'1800' => '30 '.__('minutes'),
'3600' => '1 '.__('hour'));
'5' => __('5 seconds'),
'10' => __('10 seconds'),
'15' => __('15 seconds'),
'30' => __('30 seconds'),
(string)SECONDS_1MINUTE => __('1 minute'),
(string)SECONDS_2MINUTES => __('2 minutes'),
(string)SECONDS_5MINUTES => __('5 minutes'),
(string)SECONDS_15MINUTES => __('15 minutes'),
(string)SECONDS_30MINUTES => __('30 minutes'),
(string)SECONDS_1HOUR => __('1 hour'));
echo '<span id="combo_refr" style="display: none">';
html_print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false);
unset ($values);
echo '</span>';
}
echo "</td>";
echo "<td width='20%' rowspan='2'>";
echo "<a href='index.php?sec=main'>";
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 width='20%' rowspan='2'>
<?php
echo "<a href='index.php?sec=main'>";
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>
</tr>
<tr>
<td colspan="2">
<?php
if ($config["metaconsole"] == 0){
if ($config["metaconsole"] == 0) {
?>
<form method="get" style="" name="quicksearch" action="">
<script type="text/javascript">
var fieldKeyWordEmpty = true;
</script>
<input type="text" id="keywords" name="keywords"
<form method="get" style="" name="quicksearch" action="">
<script type="text/javascript">
var fieldKeyWordEmpty = true;
</script>
<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
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'] . "'";
ui_print_help_tip (__("Blank characters are used as AND conditions"));
?>
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
ui_print_help_tip (__("Blank characters are used as AND conditions"));
?>
</form>
</form>
<?php
}
?>
</td>
<td>
<?php
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>';
}
?>
<?php
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>';
}
?>
</td>
</tr>
</table>
<?php
ui_require_jquery_file ('countdown');
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 ('countdown');
ui_require_css_file ('jquery-ui-1.8.17.custom');
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">
/* <![CDATA[ */
var new_chat = <?php echo (int)$_SESSION['new_chat'];?>;
@ -230,13 +224,28 @@ if ($config["metaconsole"] == 0){
$("#agent_access").css("display","");
});
<?php if ($msg_cnt > 0): ?>
<?php
if ($msg_cnt > 0) {
?>
$("#yougotmail").pulsate ();
<?php endif; ?>
<?php if ($config["alert_cnt"] > 0): ?>
<?php
}
?>
<?php
if ($config["alert_cnt"] > 0) {
?>
$("#yougotalert").pulsate ();
<?php endif; ?>
<?php if ($config["refr"]): ?>
<?php
}
?>
<?php
if ($config["refr"]) {
?>
t = new Date();
t.setTime (t.getTime () + <?php echo $config["refr"] * 1000; ?>);
$("#refrcounter").countdown ({until: t,
@ -246,7 +255,10 @@ if ($config["metaconsole"] == 0){
$(this).text ("...");
}
});
<?php else: ?>
<?php
}
else {
?>
$("a#autorefresh").click (function () {
var a = this;
@ -259,7 +271,9 @@ if ($config["metaconsole"] == 0){
return false;
});
<?php endif; ?>
<?php
}
?>
});
/* ]]> */
</script>
</script>

View File

@ -62,7 +62,7 @@ $maximo = 0;
$minimo = 0;
$nombre_agente = "";
$direccion_agente = get_parameter ('direccion', '');
$intervalo = 300;
$intervalo = SECONDS_5MINUTES;
$ff_interval = 0;
$id_server = "";
$max_alerts = 0;
@ -131,7 +131,7 @@ if ($create_agent) {
$nombre_agente = (string) get_parameter_post ("agente",'');
$direccion_agente = (string) get_parameter_post ("direccion",'');
$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", '');
$modo = (int) get_parameter_post ("modo");
$id_parent = (string) get_parameter_post ("id_parent",'');
@ -144,25 +144,26 @@ if ($create_agent) {
$icon_path = (string) get_parameter_post ("icon_path",'');
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
$url_description = (string) get_parameter("url_description");
$fields = db_get_all_fields_in_table('tagent_custom_fields');
if($fields === false) $fields = array();
if ($fields === false) $fields = 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'], '');
}
// Check if agent exists (BUG WC-50518-2)
if ($nombre_agente == "") {
$agent_creation_error = __('No agent name specified');
$agent_created_ok = 0;
}
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;
}
else {
@ -181,7 +182,7 @@ if ($create_agent) {
enterprise_hook ('update_agent', array ($id_agente));
if ($id_agente !== false) {
// 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',
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
}
@ -189,7 +190,7 @@ if ($create_agent) {
agents_add_address ($id_agente, $direccion_agente);
$agent_created_ok = true;
$info = 'Name: ' . $nombre_agente . ' IP: ' . $direccion_agente .
' Group: ' . $grupo . ' Interval: ' . $intervalo .
' Comments: ' . $comentarios . ' Mode: ' . $modo .
@ -217,72 +218,71 @@ if ($id_agente) {
/* View tab */
$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')))
. '</a>';
if($tab == 'view')
. html_print_image ("images/zoom.png", true, array ("title" =>__('View')))
. '</a>';
if ($tab == 'view')
$viewtab['active'] = true;
else
$viewtab['active'] = false;
/* Main tab */
$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')))
. '</a>';
if($tab == 'main')
. html_print_image ("images/cog.png", true, array ("title" =>__('Setup')))
. '</a>';
if ($tab == 'main')
$maintab['active'] = true;
else
$maintab['active'] = false;
/* Module tab */
$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')))
. '</a>';
. html_print_image ("images/brick.png", true, array ("title" =>__('Modules')))
. '</a>';
if($tab == 'module')
$moduletab['active'] = true;
else
$moduletab['active'] = false;
/* Alert tab */
$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')))
. '</a>';
. html_print_image ("images/bell.png", true, array ("title" =>__('Alerts')))
. '</a>';
if($tab == 'alert')
if ($tab == 'alert')
$alerttab['active'] = true;
else
$alerttab['active'] = false;
/* Template tab */
$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')))
. '</a>';
. html_print_image ("images/network.png", true, array ("title" =>__('Module templates')))
. '</a>';
if($tab == 'template')
if ($tab == 'template')
$templatetab['active'] = true;
else
$templatetab['active'] = false;
$templatetab['active'] = false;
/* Inventory */
$inventorytab = enterprise_hook ('inventory_tab');
if ($inventorytab == -1)
$inventorytab = "";
/* Collection */
$collectiontab = enterprise_hook('collection_tab');
if ($collectiontab == -1)
$collectiontab = "";
/* Group tab */
$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')))
. '</a>';
. html_print_image ("images/agents_group.png", true, array( "title" => __('Group')))
. '</a>';
$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.'">'
. html_print_image ("images/world.png", true, array ( "title" => __('GIS data')))
. '</a>';
if ($tab == "gis")
$gistab['active'] = true;
else
@ -304,27 +304,34 @@ if ($id_agente) {
$total_incidents = agents_get_count_incidents($id_agente);
/* 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.'">'
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>';
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>';
if($tab == 'incident')
if ($tab == 'incident')
$incidenttab['active'] = true;
else
$incidenttab['active'] = false;
}
}
$onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab,
'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab,
'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab);
$onheader = array('view' => $viewtab,
'separator' => "",
'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
if ($total_incidents){
if ($total_incidents) {
$onheader['incident'] = $incidenttab;
}
foreach($config['extensions'] as $extension) {
foreach ($config['extensions'] as $extension) {
if (isset($extension['extension_god_tab'])) {
$image = $extension['extension_god_tab']['icon'];
$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);
$onheader = $onheader + array($id => $extension_tab);
$onheader = $onheader + array($id => $extension_tab);
}
}
@ -357,7 +364,7 @@ if ($id_agente) {
break;
case "inventory":
$tab_description = '- ' . __('Inventory') . ui_print_help_icon('inventory_tab', true);
break;
break;
case "module":
$tab_description = '- '. __('Modules');
break;
@ -366,19 +373,20 @@ if ($id_agente) {
break;
case "template":
$tab_description = '- ' . __('Templates') . ui_print_help_icon('template_tab', true);
break;
break;
case "gis":
$tab_description = '- ' . __('Gis') . ui_print_help_icon('gis_tab', true);
break;
case "incident":
$tab_description = '- ' . __('Incidents');
break;
break;
case "extension":
$id_extension = get_parameter('id_extension', '');
switch ($id_extension){
switch ($id_extension) {
case "snmp_explorer":
$tab_description = '- ' . __('SNMP explorer') . ui_print_help_icon('snmp_explorer', true);
}
break;
}
break;
default:
break;
@ -401,12 +409,12 @@ if ($delete_conf_file) {
if (isset ($config["remote_config"])) {
$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
$file_name = $config["remote_config"]."/conf/".$agent_md5.".conf";
$file_name = $config["remote_config"] . "/conf/" . $agent_md5 . ".conf";
$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);
}
}
@ -440,7 +448,7 @@ if (isset( $_GET["fix_module"])) {
}
else {
$result = false;
$error = " - ".__('No data to normalize');
$error = " - " . __('No data to normalize');
}
ui_print_result_message ($result,
@ -465,7 +473,7 @@ if ($update_agent) { // if modified some agent paramenter
$direccion_agente = $address_list;
}
$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", ""));
$modo = (bool) get_parameter_post ("modo", 0); //Mode: Learning or Normal
$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');
if($fields === false) $fields = array();
if ($fields === false) $fields = 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'], '');
}
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));
if($old_value === false) {
if ($old_value === false) {
// Create custom field if not exist
db_process_sql_insert ('tagent_custom_data',
array('id_field' => $key,'id_agent' => $id_agente, 'description' => $value));
}
else {
else {
db_process_sql_update ('tagent_custom_data',
array('description' => $value),
array('id_field' => $key,'id_agent' => $id_agente));
array('description' => $value),
array('id_field' => $key,'id_agent' => $id_agente));
}
}
//Verify if there is another agent with the same name but different ID
if ($nombre_agente == "") {
echo '<h3 class="error">'.__('No agent name specified').'</h3>';
//If there is an agent with the same name, but a different ID
if ($nombre_agente == "") {
ui_print_error_message(__('No agent name specified'));
//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) {
echo '<h3 class="error">'.__('There is already an agent in the database with this name').'</h3>';
elseif (agents_get_agent_id ($nombre_agente) > 0 &&
agents_get_agent_id ($nombre_agente) != $id_agente) {
ui_print_error_message(__('There is already an agent in the database with this name'));
}
else {
//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);
}
//If IP is set for deletion, delete first
if (isset ($_POST["delete_ip"])) {
@ -543,7 +554,8 @@ if ($update_agent) { // if modified some agent paramenter
array ('id_agente' => $id_agente));
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 {
$info = 'Group: ' . $grupo . ' Interval: ' . $intervalo .
@ -558,7 +570,6 @@ if ($update_agent) { // if modified some agent paramenter
ui_print_success_message (__('Successfully updated'));
db_pandora_audit("Agent management",
"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
$id_grupo = agents_get_agent_group ($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;
}
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);
$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;
}
@ -632,7 +643,7 @@ if ($update_module || $create_module) {
$description = (string) get_parameter ('description');
$id_module_group = (int) get_parameter ('id_module_group');
$flag = (bool) get_parameter ('flag');
// 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:
// 1.23E-10 is 0.000000000123
@ -652,35 +663,35 @@ if ($update_module || $create_module) {
$tcp_port = (int) get_parameter ('tcp_port');
$configuration_data = (string) get_parameter ('configuration_data');
$old_configuration_data = (string) get_parameter ('old_configuration_data');
$custom_string_1 = (string) get_parameter ('custom_string_1');
$custom_string_2 = (string) get_parameter ('custom_string_2');
$custom_string_3 = (string) get_parameter ('custom_string_3');
$custom_integer_1 = (int) get_parameter ('prediction_module');
$custom_integer_2 = (int) get_parameter ('custom_integer_2');
// 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');
$agent_name = (string) get_parameter('agent_name',agents_get_name ($id_agente));
$snmp_community = (string) get_parameter ('snmp_community');
$snmp_oid = (string) get_parameter ('snmp_oid');
if (empty ($snmp_oid)) {
/* The user did not set any OID manually but did a SNMP walk */
$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
$tcp_send = (string) get_parameter ('snmp_version');
$plugin_user = (string) get_parameter ('snmp3_auth_user');
$plugin_pass = (string) get_parameter ('snmp3_auth_pass');
$plugin_parameter = (string) get_parameter ('snmp3_auth_method');
$custom_string_1 = (string) get_parameter ('snmp3_privacy_method');
$custom_string_2 = (string) get_parameter ('snmp3_privacy_pass');
$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');
else
$plugin_pass = (string) get_parameter ('plugin_pass');
$plugin_parameter = (string) get_parameter ('plugin_parameter');
}
$ip_target = (string) get_parameter ('ip_target');
$custom_id = (string) get_parameter ('custom_id');
$history_data = (int) get_parameter('history_data');
@ -709,14 +719,14 @@ if ($update_module || $create_module) {
$id_tag = (array) get_parameter('id_tag_selected');
$serialize_ops = (string) get_parameter('serialize_ops');
if($prediction_module != 3) {
if ($prediction_module != 3) {
unset($serialize_ops);
enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module));
}
$active_snmp_v3 = get_parameter('active_snmp_v3');
if ($active_snmp_v3) {
//
//LOST CODE?
}
// Make changes in the conf file if necessary
@ -730,45 +740,45 @@ if ($update_module) {
$id_agent_module = (int) get_parameter ('id_agent_module');
$values = array ('descripcion' => $description,
'id_module_group' => $id_module_group,
'nombre' => $name,
'max' => $max,
'min' => $min,
'module_interval' => $interval,
'module_ff_interval' => $ff_interval,
'tcp_port' => $tcp_port,
'tcp_send' => $tcp_send,
'tcp_rcv' => $tcp_rcv,
'snmp_community' => $snmp_community,
'snmp_oid' => $snmp_oid,
'ip_target' => $ip_target,
'flag' => $flag,
'disabled' => $disabled,
'id_export' => $id_export,
'plugin_user' => $plugin_user,
'plugin_pass' => $plugin_pass,
'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin,
'post_process' => $post_process,
'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout,
'custom_id' => $custom_id,
'history_data' => $history_data,
'min_warning' => $min_warning,
'max_warning' => $max_warning,
'str_warning' => $str_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'str_critical' => $str_critical,
'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3,
'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event,
'unit' => $unit);
'id_module_group' => $id_module_group,
'nombre' => $name,
'max' => $max,
'min' => $min,
'module_interval' => $interval,
'module_ff_interval' => $ff_interval,
'tcp_port' => $tcp_port,
'tcp_send' => $tcp_send,
'tcp_rcv' => $tcp_rcv,
'snmp_community' => $snmp_community,
'snmp_oid' => $snmp_oid,
'ip_target' => $ip_target,
'flag' => $flag,
'disabled' => $disabled,
'id_export' => $id_export,
'plugin_user' => $plugin_user,
'plugin_pass' => $plugin_pass,
'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin,
'post_process' => $post_process,
'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout,
'custom_id' => $custom_id,
'history_data' => $history_data,
'min_warning' => $min_warning,
'max_warning' => $max_warning,
'str_warning' => $str_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'str_critical' => $str_critical,
'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3,
'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event,
'unit' => $unit);
if($prediction_module == 3 && $serialize_ops == '') {
if ($prediction_module == 3 && $serialize_ops == '') {
$result = false;
}
else {
@ -777,26 +787,24 @@ if ($update_module) {
}
if (is_error($result)) {
$msg = __('There was a problem updating module').'. ';
switch($result) {
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;
case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')';
$msg = __('There was a problem updating module. Some required fields are missed: (name)');
break;
case ERR_NOCHANGES:
$msg .= __('"No change"');
$msg = __('There was a problem updating module. "No change"');
break;
case ERR_DB:
case ERR_GENERIC:
default:
$msg .= __('Processing error');
$msg = __('There was a problem updating module. Processing error');
break;
}
$result = false;
echo '<h3 class="error">'.$msg.'</h3>';
ui_print_error_message($msg);
$edit_module = true;
@ -804,15 +812,15 @@ if ($update_module) {
"Fail to try update module '$name' for agent ".$agent["nombre"]);
}
else {
if($prediction_module == 3) {
if ($prediction_module == 3) {
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;
$edit_module = false;
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"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"])) {
$combo_snmp_oid = get_parameter_post ("combo_snmp_oid");
}
if ($snmp_oid == ""){
if ($snmp_oid == "") {
$snmp_oid = $combo_snmp_oid;
}
@ -833,50 +841,50 @@ if ($create_module) {
switch ($config["dbtype"]) {
case "oracle":
if (empty($description) || !isset($description)) {
$description=' ';
}
$description=' ';
}
break;
}
$values = array ('id_tipo_modulo' => $id_module_type,
'descripcion' => $description,
'max' => $max,
'min' => $min,
'snmp_oid' => $snmp_oid,
'snmp_community' => $snmp_community,
'id_module_group' => $id_module_group,
'module_interval' => $interval,
'module_ff_interval' => $ff_interval,
'ip_target' => $ip_target,
'tcp_port' => $tcp_port,
'tcp_rcv' => $tcp_rcv,
'tcp_send' => $tcp_send,
'id_export' => $id_export,
'plugin_user' => $plugin_user,
'plugin_pass' => $plugin_pass,
'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin,
'post_process' => $post_process,
'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout,
'disabled' => $disabled,
'id_modulo' => $id_module,
'custom_id' => $custom_id,
'history_data' => $history_data,
'min_warning' => $min_warning,
'max_warning' => $max_warning,
'str_warning' => $str_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'str_critical' => $str_critical,
'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3,
'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event,
'unit' => $unit
);
'descripcion' => $description,
'max' => $max,
'min' => $min,
'snmp_oid' => $snmp_oid,
'snmp_community' => $snmp_community,
'id_module_group' => $id_module_group,
'module_interval' => $interval,
'module_ff_interval' => $ff_interval,
'ip_target' => $ip_target,
'tcp_port' => $tcp_port,
'tcp_rcv' => $tcp_rcv,
'tcp_send' => $tcp_send,
'id_export' => $id_export,
'plugin_user' => $plugin_user,
'plugin_pass' => $plugin_pass,
'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin,
'post_process' => $post_process,
'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout,
'disabled' => $disabled,
'id_modulo' => $id_module,
'custom_id' => $custom_id,
'history_data' => $history_data,
'min_warning' => $min_warning,
'max_warning' => $max_warning,
'str_warning' => $str_warning,
'min_critical' => $min_critical,
'max_critical' => $max_critical,
'str_critical' => $str_critical,
'custom_string_1' => $custom_string_1,
'custom_string_2' => $custom_string_2,
'custom_string_3' => $custom_string_3,
'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event,
'unit' => $unit);
if($prediction_module == 3 && $serialize_ops == '') {
$id_agent_module = false;
}
@ -885,22 +893,21 @@ if ($create_module) {
}
if (is_error($id_agent_module)) {
$msg = __('There was a problem adding module').'. ';
switch($id_agent_module) {
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;
case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')';
$msg __('There was a problem adding module. Some required fields are missed : (name)');
break;
case ERR_DB:
case ERR_GENERIC:
default:
$msg .= __('Processing error');
$msg __('There was a problem adding module. Processing error');
break;
}
$id_agent_module = false;
echo '<h3 class="error">'.$msg.'</h3>';
ui_print_error_message($msg);
$edit_module = true;
$moduletype = $id_module;
db_pandora_audit("Agent management",
@ -911,12 +918,12 @@ if ($create_module) {
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;
$edit_module = false;
$info = '';
$agent = db_get_row ('tagente', 'id_agente', $id_agente);
db_pandora_audit("Agent management",
"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);
if ($result === false)
$error++;
// 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
$ops_json = enterprise_hook('modules_get_synthetic_operations', array($id_borrar_modulo));
$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));
if ($result === false)
$error++;
} // 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));
$count_components = 1;
if (!empty($result_components)){
@ -996,29 +1003,31 @@ if ($delete_module) { // DELETE agent module !
$last_target_module = 0;
foreach ($result_components as $id_target_module){
// 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;
}
else
$update_orders = false;
$result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_borrar_modulo, $update_orders));
if ($result === false)
$error++;
$error++;
$count_components++;
$last_target_module = $id_target_module;
}
}
}
//Check for errors
if ($error != 0) {
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 {
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);
db_pandora_audit("Agent management",
"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;
$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;
$exists = true;
@ -1040,8 +1049,7 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
'nombre', $copy_name);
if ($exists) {
$cont++;
$copy_name = io_safe_input(__('copy of') . ' ') . $original_name
. io_safe_input(' (' . $cont . ')');
$copy_name = sprintf(__('copy of %s (%d)'), $original_name, $cont);
}
}
@ -1085,7 +1093,7 @@ if ($updateGIS) {
"altitude" => $previusAgentGISData['stored_altitude'],
"start_timestamp" => $previusAgentGISData['start_timestamp'],
"end_timestamp" => date( 'Y-m-d H:i:s'),
"description" => "Save by Pandora Console",
"description" => __('Save by Pandora Console'),
"manual_placement" => $previusAgentGISData['manual_placement'],
"number_of_packages" => $previusAgentGISData['number_of_packages'],
"tagente_id_agente" => $previusAgentGISData['tagente_id_agente']
@ -1100,7 +1108,7 @@ if ($updateGIS) {
"stored_altitude" => $lastAltitude,
"start_timestamp" => date( 'Y-m-d H:i:s'),
"manual_placement" => 1,
"description" => "Update by Pandora Console"),
"description" => __('Update by Pandora Console')),
array("tagente_id_agente" => $idAgente));
}
else {
@ -1113,7 +1121,7 @@ if ($updateGIS) {
"stored_latitude" => $lastLatitude,
"stored_altitude" => $lastAltitude,
"manual_placement" => 1,
"description" => "Insert by Pandora Console"
"description" => __('Insert by Pandora Console')
));
}
db_process_sql_commit();
@ -1165,13 +1173,15 @@ switch ($tab) {
}
}
if (!$found) {
ui_print_error_message ("Invalid tab specified");
ui_print_error_message (__('Invalid tab specified'));
}
break;
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
//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 = '';
$min_alerts = 0;
$max_alerts = 1;
$threshold = 300;
$threshold = SECONDS_5MINUTES;
$recovery_notify = false;
$field2_recovery = '';
$field3_recovery = '';
@ -287,7 +287,8 @@ if ($create_compound) {
/* Go to previous step in case of error */
if ($result === false) {
$step = $step - 1;
} else {
}
else {
$id = $result;
$alerts = (array) get_parameter ('conditions');
$operations = (array) get_parameter ('operations');
@ -329,7 +330,8 @@ if ($step == 2) {
$table->style['other_label'] = 'display:none; font-weight: bold';
$table->style['other_input'] = 'display:none';
$threshold_selected = $threshold;
} else {
}
else {
$table->style['other_label'] = 'font-weight: bold';
$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] .= __('Sun');
$table->data[0][1] .= html_print_checkbox ('sunday', 1, $sunday, true);
$table->data[0][2] = __('Use special days list');
$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 */
if ($step == 1) {
echo '<h3>'.__('Add condition').'</h3>';
echo '<h3>'. __('Add condition') . '</h3>';
$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 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 __('Minimum').': ';
echo '</td><td>';
html_print_input_text ("min", 0, __('Minimum'), 4, 0, false);
echo '</td></tr>';
echo '<tr><td>';
echo __('Maximum').': ';
echo __('Maximum').': ';
echo '</td><td>';
html_print_input_text ("max", 0, __('Maximum'), 4, 0, false);
echo '</td></tr>';

View File

@ -63,7 +63,7 @@ push_table_row($data, 'field_process');
return;
// Update an existing component
if (! $id) {
$module_interval = 300;
$module_interval = SECONDS_5MINUTES;
$tcp_port = "";
$tcp_rcv = "";
$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') {
$timestamp = false;
$comparation = true;
} else if ($config['prominent_time'] == 'timestamp') {
}
else if ($config['prominent_time'] == 'timestamp') {
$timestamp = true;
$comparation = false;
}
@ -111,11 +112,11 @@ $table->data[14][1] = html_print_select (list_files ('images/custom_logo', "png"
$values = array ();
$values[5] = human_time_description_raw (5);
$values[30] = human_time_description_raw (30);
$values[60] = human_time_description_raw (60);
$values[120] = human_time_description_raw (120);
$values[300] = human_time_description_raw (300);
$values[600] = human_time_description_raw (600);
$values[1800] = human_time_description_raw (1800);
$values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE);
$values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES);
$values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
$values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
$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][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");
$oid = (string) get_parameter_post ("oid");
$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);
$al_field1 = (string) get_parameter_post ("al_field1");
$al_field2 = (string) get_parameter_post ("al_field2");
@ -91,33 +91,39 @@ else if (isset ($_GET["submit"])) {
if (!$result) {
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 {
db_pandora_audit("SNMP management", "Create snmp alert #$result");
echo '<h3 class="suc">'.__('Successfully created').'</h3>';
ui_print_success_message(__('Successfully created'));
}
}
else {
$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',
oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s',
_snmp_f5_ = '%s', _snmp_f6_ = '%s', 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);
priority = %d, id_alert = %d, al_field1 = '%s',
al_field2 = '%s', al_field3 = '%s', description = '%s',
agent = '%s', custom_oid = '%s', oid = '%s',
time_threshold = %d, max_alerts = %d, min_alerts = %d,
_snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s',
_snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s',
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);
if (!$result) {
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 {
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 = "";
$oid = "";
$custom_value = "";
$time_threshold = 300;
$time_threshold = SECONDS_5MINUTES;
$al_field1 = "";
$al_field2 = "";
$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));
if ($result === false) {
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 {
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;
if (empty ($ip_address))
return false;
$interval = safe_int ($interval,1, 300);
$interval = safe_int ($interval,1, SECONDS_5MINUTES);
if (empty ($interval))
return false;
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',
array ('id_agente_modulo' => $id_agent_module,
'datos' => '',
'timestamp' => 0,
'estado' => 0,
'id_agente' => $id_agent,
'last_try' => 0,
'utimestamp' => 0,
'current_interval' => 0,
'running_by' => 0,
'last_execution_try' => 0));
array ('id_agente_modulo' => $id_agent_module,
'datos' => '',
'timestamp' => 0,
'estado' => 0,
'id_agente' => $id_agent,
'last_try' => 0,
'utimestamp' => 0,
'current_interval' => 0,
'running_by' => 0,
'last_execution_try' => 0));
if ($result === false) {
db_process_sql_rollback ();
@ -95,7 +95,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
db_process_sql_commit ();
db_pandora_audit ("Agent management", "New agent '$name' created");
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 = '',
$allModules = false, $orderby = false, $idGroup = false, $count = false) {
global $config;
if (is_array($filter)) {
$disabled = $filter['disabled'];
if (isset($filter['standby'])) {
@ -129,7 +129,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
$filter = '';
$disabled = $filter;
}
switch ($disabled) {
case "notfired":
$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;
default:
$filter .= '';
break;
}
if (is_array ($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);
}
$orderbyText = '';
if ($orderby !== false) {
if (is_array($orderby)) {
@ -191,26 +192,26 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
if ($count !== false) {
$selectText = 'COUNT(talert_template_modules.id) AS count';
}
// TODO: Clean extra_sql
$extra_sql = '';
$sql = sprintf ("SELECT %s
FROM talert_template_modules
INNER JOIN tagente_modulo t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates t4
ON talert_template_modules.id_alert_template = t4.id
WHERE (%s id_agent_module in (%s)) %s %s %s",
FROM talert_template_modules
INNER JOIN tagente_modulo t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente t3
ON t2.id_agente = t3.id_agente
INNER JOIN talert_templates t4
ON talert_template_modules.id_alert_template = t4.id
WHERE (%s id_agent_module in (%s)) %s %s %s",
$selectText, $extra_sql, $subQuery, $where, $filter, $orderbyText);
$alerts = db_get_all_rows_sql ($sql);
if ($alerts === false)
return array ();
if ($count !== false) {
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 ($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 {
$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';
}
$sql = sprintf ("SELECT %s FROM talert_compound
$sql = sprintf ("SELECT %s
FROM talert_compound
WHERE id_agent IN (%s) %s %s",
$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.
*/
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)) {
$filter = array ();
}
if(isset($filter['search'])) {
if (isset($filter['search'])) {
$search = $filter['search'];
unset($filter['search']);
}
else{
else {
$search = '';
}
if(isset($filter['offset'])) {
if (isset($filter['offset'])) {
$offset = $filter['offset'];
unset($filter['offset']);
}
if(isset($filter['limit'])) {
if (isset($filter['limit'])) {
$limit = $filter['limit'];
unset($filter['limit']);
}
$status_sql = ' 1 = 1';
if(isset($filter['status'])) {
$normal_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
if (isset($filter['status'])) {
$normal_modules = 'SELECT 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_modulo.disabled = 0 AND estado = 0
AND (utimestamp != 0)' /*OR tagente_modulo.id_tipo_modulo IN (21,22,23))
AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'*/;
$warning_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
$warning_modules = 'SELECT 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_modulo.disabled = 0 AND estado = 2 AND tagente_estado.utimestamp != 0';
/* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';*/
$critical_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
$critical_modules = 'SELECT 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_modulo.disabled = 0 AND estado = 1 AND tagente_estado.utimestamp != 0';
/* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'; */
$unknown_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
$unknown_modules = 'SELECT tagente.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_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'*/;
$notinit_modules = 'SELECT tagente_estado.id_agente FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
$notinit_modules = 'SELECT 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_modulo.disabled = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23)
AND utimestamp = 0';
switch ($filter['status']) {
// Normal
case 0:
@ -384,7 +392,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$status_sql = "id_agente IN ($critical_modules)";
break;
// Unknown
case 3:
case 3:
$status_sql = "id_agente IN ($unknown_modules) &&
id_agente NOT IN ($critical_modules) && id_agente NOT IN ($warning_modules)";
break;
@ -399,19 +407,18 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$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)";
break;
}
unset($filter['status']);
}
unset($filter['order']);
$filter_nogroup = $filter;
//Get user groups
$groups = array_keys (users_get_groups ($config["id_user"], $access, false));
//If no group specified, get all user groups
if (empty ($filter['id_grupo'])) {
$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_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', '');
if ($where_nogroup == '') {
$where_nogroup = '1 = 1';
}
$extra = false;
// TODO: CLEAN extra_sql
$sql_extra = '';
if ($all_groups){
if ($all_groups) {
$where_nogroup = '1 = 1';
}
if($extra) {
$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);
}
$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"]) {
case "mysql":
$limit_sql = '';
if(isset($offset) && isset($limit)) {
if (isset($offset) && isset($limit)) {
$limit_sql = " LIMIT $offset, $limit ";
}
$sql = sprintf("%s %s", $sql, $limit_sql);
@ -498,7 +508,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
break;
case "postgresql":
$limit_sql = '';
if(isset($offset) && isset($limit)) {
if (isset($offset) && isset($limit)) {
$limit_sql = " OFFSET $offset LIMIT $limit ";
}
$sql = sprintf("%s %s", $sql, $limit_sql);
@ -510,7 +520,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
break;
case "oracle":
$set = array();
if(isset($offset) && isset($limit)) {
if (isset($offset) && isset($limit)) {
$set['limit'] = $limit;
$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) {
global $config;
if (empty ($source_id_agent)) {
echo '<h3 class="error">'.__('No source agent to copy').'</h3>';
return false;
@ -588,7 +598,7 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
if (empty ($target_modules)) {
if (! $copy_alerts) {
echo '<h3 class="error">'.__('No modules have been selected').'</h3>';
ui_print_error_message(__('No modules have been selected'));
return false;
}
$target_modules = array ();
@ -615,30 +625,28 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
break;
}
$error = false;
$repeated_modules = array();
foreach ($destiny_id_agents as $id_destiny_agent) {
foreach ($target_modules as $id_agent_module) {
// Check the module name exists in target
$module = modules_get_agentmodule ($id_agent_module);
if ($module === false)
return false;
$modules = agents_get_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => false));
// Keep all modules repeated
if (! empty ($modules)) {
$modules_repeated = array_pop (array_keys ($modules));
$result = $modules_repeated;
$repeated_modules[] = $modules_repeated;
$repeated_modules[] = $modules_repeated;
}
else {
$result = modules_copy_agent_module_to_agent ($id_agent_module,
$id_destiny_agent);
if ($result === false) {
$error = true;
break;
@ -694,7 +702,8 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
}
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']) {
case "mysql":
case "postgresql":
@ -704,8 +713,9 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
db_process_sql_rollback();
break;
}
} else {
echo '<h3 class="suc">'.__('Successfully copied').'</h3>';
}
else {
ui_print_success_message(__('Successfully copied'));
switch ($config['dbtype']) {
case "mysql":
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) {
$agent = db_get_row_sql("SELECT * FROM tagente WHERE id_agente = " . $idAgent);
$agent = db_get_row_sql("SELECT *
FROM tagente
WHERE id_agente = " . $idAgent);
$difference = get_system_time () - strtotime ($agent["ultimo_contacto"]);
@ -734,7 +745,9 @@ function agents_get_next_contact($idAgent, $maxModules = false) {
$max = $agent["intervalo"];
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);
if ($maxModules > 0)
$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) {
$id_agent = safe_int ($id_agent, 1);
$where = '';
if (! empty ($id_agent)) {
$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) {
$id_agent = safe_int ($id_agent, 1);
$where = '';
if (! empty ($id_agent)) {
$where = sprintf (' WHERE delete_pending = 0 AND id_agente IN (%s)
AND (
SELECT count(nombre)
FROM tagente_modulo t2
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 (
SELECT count(nombre)
FROM tagente_modulo t2
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));
}
if (! empty ($filter)) {
$where .= ' AND ';
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) {
global $config;
if (!$noACL) {
$id_group = groups_safe_acl($config["id_user"], $id_group, "AR");
if (empty ($id_group)) {
//An empty array means the user doesn't have access
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));
}
if (is_array($id_group)) {
$all_groups = false;
$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;
$search_group_sql = sprintf ('id_grupo = %d', $id_group);
}
$search_sql = '1 = 1';
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.'%\'))';
break;
}
unset ($search["string"]);
}
if (isset ($search["name"])) {
$name = io_safe_input ($search["name"]);
switch ($config["dbtype"]) {
@ -1152,7 +1165,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
$operatorDistin = true;
}
}
if ($value[0] == '%') {
switch ($config['dbtype']){
case "mysql":
@ -1266,14 +1279,14 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
}
$result = db_get_all_rows_sql ($sql);
if (empty ($result)) {
return array ();
}
if (! $indexed)
return $result;
$modules = array ();
foreach ($result as $module) {
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":
default:
return ($agent);
break;
}
}
@ -1352,17 +1366,17 @@ function agents_get_name ($id_agent, $case = "none") {
*/
function agents_get_modules_data_count ($id_agent = 0) {
$id_agent = safe_int ($id_agent, 1);
if (empty ($id_agent)) {
$id_agent = array ();
}
else {
$id_agent = (array) $id_agent;
}
$count = array ();
$count["total"] = 0;
$query[0] = "SELECT COUNT(*) FROM tagente_datos";
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
$count["total"] += $count[$agent_id];
}
if ($count["total"] == 0) {
foreach ($query as $sql) {
$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
AND times_fired > 0 AND id_agente = %d",
$id_agent);
$value = db_get_sql ($sql);
if ($value > 0)
return true;
@ -1450,7 +1464,7 @@ function agents_give_agentmodule_flag ($id_agent_module) {
*/
function agents_add_address ($id_agent, $ip_address) {
global $config;
// Check if already is attached to agent
switch ($config["dbtype"]) {
case "mysql":
@ -1468,15 +1482,15 @@ function agents_add_address ($id_agent, $ip_address) {
$current_address = db_get_sql ($sql);
if ($current_address > 0)
return;
// Look for a record with this IP Address
$id_address = (int) db_get_value ('id_a', 'taddress', 'ip', $ip_address);
if ($id_address === 0) {
// Create IP address in tadress table
$id_address = db_process_sql_insert('taddress', array('ip' => $ip_address));
}
// Add address to agent
$values = array('id_a' => $id_address, 'id_agent' => $id_agent);
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) {
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'
AND id_agent = %d", $ip_address, $id_agent);
$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, "");
db_pandora_audit("Agent management",
"Deleted IP $ip_address from agent '$agent_name'");
// Need to change main address?
if (agents_get_address ($id_agent) == $ip_address) {
$new_ips = agents_get_addresses ($id_agent);
@ -1550,7 +1565,7 @@ function agents_get_agent_with_ip ($ip_address) {
AND ip = \'%s\'', $ip_address);
break;
}
return db_get_row_sql ($sql);
}
@ -1566,18 +1581,18 @@ function agents_get_addresses ($id_agent) {
FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a
AND id_agent = %d", $id_agent);
$ips = db_get_all_rows_sql ($sql);
if ($ips === false) {
$ips = array ();
}
$ret_arr = array ();
foreach ($ips as $row) {
$ret_arr[$row["ip"]] = $row["ip"];
}
return $ret_arr;
}
@ -1593,7 +1608,7 @@ function agents_get_addresses ($id_agent) {
function agents_get_status($id_agent = 0, $noACLs = false) {
global $config;
if (!$noACLs){
if (!$noACLs) {
$modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false);
}
else{
@ -1602,29 +1617,29 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
$filter_modules['delete_pending'] = 0;
// Get all non disabled modules of the agent
$all_modules = db_get_all_rows_filter('tagente_modulo', $filter_modules, 'id_agente_modulo');
$result_modules = array();
// Skip non init modules
foreach ($all_modules as $module){
if (modules_get_agentmodule_is_init($module['id_agente_modulo'])){
$modules[] = $module['id_agente_modulo'];
}
}
}
}
$modules_status = array();
$modules_async = 0;
foreach($modules as $module) {
$modules_status[] = modules_get_agentmodule_status($module);
$module_type = modules_get_agentmodule_type($module);
if(($module_type >= 21 && $module_type <= 23) || $module_type == 100) {
$modules_async++;
}
}
}
// 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 ();
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));
break;
}
if (! $status)
return -1;
}
// 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)
if(is_int(array_search(4,$modules_status))){
if (is_int(array_search(4,$modules_status))) {
return 4;
}
// 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;
}
// 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;
}
// 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;
}
else {
@ -1685,34 +1700,34 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
*/
function agents_delete_agent ($id_agents, $disableACL = false) {
global $config;
$error = false;
//Convert single values to an array
if (! is_array ($id_agents))
$id_agents = (array) $id_agents;
//Start transaction
db_process_sql_begin ();
foreach ($id_agents as $id_agent) {
$id_agent = (int) $id_agent; //Cast as integer
if ($id_agent < 1)
continue;
$agent_name = agents_get_name($id_agent, "");
/* Check for deletion permissions */
$id_group = agents_get_agent_group ($id_agent);
if ((! check_acl ($config['id_user'], $id_group, "AW")) && !$disableACL) {
db_process_sql_rollback ();
return false;
}
//A variable where we store that long subquery thing for
//modules
$where_modules = "ANY(SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente = ".$id_agent.")";
//IP address
$sql = sprintf ("SELECT id_ag
FROM taddress_agent, taddress
@ -1720,68 +1735,68 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
AND id_agent = %d",
$id_agent);
$addresses = db_get_all_rows_sql ($sql);
if ($addresses === false) {
$addresses = array ();
}
foreach ($addresses as $address) {
db_process_delete_temp ("taddress_agent", "id_ag", $address["id_ag"]);
}
// We cannot delete tagente_datos and tagente_datos_string here
// 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
// daily maintance process, all data for that modules are deleted
//Alert
db_process_delete_temp ("talert_compound", "id_agent", $id_agent);
db_process_delete_temp ("talert_template_modules", "id_agent_module", $where_modules);
//Events (up/down monitors)
// Dont delete here, could be very time-exausting, let the daily script
// delete them after XXX days
// db_process_delete_temp ("tevento", "id_agente", $id_agent);
//Graphs, layouts & reports
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 ("treport_content", "id_agent_module", $where_modules);
//Planned Downtime
db_process_delete_temp ("tplanned_downtime_agents", "id_agent", $id_agent);
//The status of the module
db_process_delete_temp ("tagente_estado", "id_agente", $id_agent);
//The actual modules, don't put anything based on
// DONT Delete this, just mark for deletion
// db_process_delete_temp ("tagente_modulo", "id_agente", $id_agent);
db_process_sql_update ('tagente_modulo',
array ('delete_pending' => 1, 'disabled' => 1, 'nombre' => 'pendingdelete'),
'id_agente = '. $id_agent);
// Access entries
// Dont delete here, this records are deleted in daily script
// db_process_delete_temp ("tagent_access", "id_agent", $id_agent);
// Delete agent policies
enterprise_hook('policies_delete_agent', array($id_agent));
// tagente_datos_inc
// Dont delete here, this records are deleted later, in database script
// db_process_delete_temp ("tagente_datos_inc", "id_agente_modulo", $where_modules);
// Delete remote configuration
if (isset ($config["remote_config"])) {
$agent_md5 = md5 ($agent_name, FALSE);
if (file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5")) {
// Agent remote configuration editor
$file_name = $config["remote_config"]."/conf/".$agent_md5.".conf";
$error = !@unlink ($file_name);
if (!$error) {
$file_name = $config["remote_config"]."/md5/".$agent_md5.".md5";
$error = !@unlink ($file_name);
@ -1793,19 +1808,19 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
}
}
}
//And at long last, the agent
db_process_delete_temp ("tagente", "id_agente", $id_agent);
db_pandora_audit( "Agent management",
"Deleted agent '$agent_name'");
/* Break the loop on error */
if ($error)
break;
}
if ($error) {
db_process_sql_rollback ();
return false;
@ -1909,18 +1924,19 @@ function agents_get_alerts_fired ($id_agent, $filter="") {
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);
}
//Returns the alert image to display tree view
function agents_tree_view_alert_img ($alert_fired) {
if ($alert_fired) {
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);
}
}
@ -1940,8 +1956,6 @@ function agetns_tree_view_status_img ($critical, $warning, $unknown) {
}
else {
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;
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)";
}

View File

@ -326,11 +326,11 @@ function config_process_config () {
// Load user session
if (isset ($_SESSION['id_usuario']))
$config["id_user"] = $_SESSION["id_usuario"];
if (!isset ($config["round_corner"])) {
config_update_value ('round_corner', false);
}
if (!isset ($config["agentaccess"])) {
config_update_value ('agentaccess', true);
}
@ -338,39 +338,39 @@ function config_process_config () {
if (!isset ($config["timezone"])) {
config_update_value ('timezone', "Europe/Berlin");
}
if (!isset ($config["stats_interval"])) {
config_update_value ('stats_interval', 300);
config_update_value ('stats_interval', SECONDS_5MINUTES);
}
if (!isset ($config["realtimestats"])) {
config_update_value ('realtimestats', 1);
}
if (!isset ($config["event_purge"])) {
config_update_value ('event_purge', 15);
}
if (!isset ($config["trap_purge"])) {
config_update_value ('trap_purge', 7);
}
if (!isset ($config["string_purge"])) {
config_update_value ('string_purge', 14);
}
if (!isset ($config["audit_purge"])) {
config_update_value ('audit_purge', 30);
}
if (!isset ($config["acl_enterprise"])) {
config_update_value ('acl_enterprise', 0);
}
if (!isset ($config["metaconsole"])) {
config_update_value ('metaconsole', 0);
}
if (!isset ($config["gis_purge"])) {
config_update_value ('gis_purge', 7);
}
@ -415,55 +415,55 @@ function config_process_config () {
if (!isset ($config['fontpath'])) {
config_update_value ( 'fontpath', $config['homedir'].'/include/fonts/smallfont.ttf');
}
if (!isset ($config['style'])) {
config_update_value ( 'style', 'pandora');
}
if (!isset ($config['flash_charts'])) {
config_update_value ( 'flash_charts', true);
}
if (!isset ($config["custom_logo"])){
if (!isset ($config["custom_logo"])) {
config_update_value ('custom_logo', 'none.png');
}
if (!isset ($config['history_db_enabled'])) {
config_update_value ( 'history_db_enabled', false);
}
if (!isset ($config['history_db_host'])) {
config_update_value ( 'history_db_host', '');
}
if (!isset ($config['history_db_port'])) {
config_update_value ( 'history_db_port', 3306);
}
if (!isset ($config['history_db_name'])) {
config_update_value ( 'history_db_name', 'pandora');
}
if (!isset ($config['history_db_user'])) {
config_update_value ( 'history_db_user', 'pandora');
}
if (!isset ($config['history_db_pass'])) {
config_update_value ( 'history_db_pass', '');
}
if (!isset ($config['history_db_days'])) {
config_update_value ( 'history_db_days', 0);
}
if (!isset ($config['history_db_step'])) {
config_update_value ( 'history_db_step', 0);
}
if (!isset ($config['history_db_delay'])) {
config_update_value ( 'history_db_delay', 0);
}
if (!isset ($config['activate_gis'])) {
config_update_value ( 'activate_gis', 0);
}
@ -471,135 +471,135 @@ function config_process_config () {
if (!isset ($config['activate_netflow'])) {
config_update_value ( 'activate_netflow', 0);
}
if (!isset ($config['netflow_path'])) {
config_update_value ( 'netflow_path', '/var/spool/pandora/data_in/netflow');
}
if (!isset ($config['netflow_interval'])) {
config_update_value ( 'netflow_interval', 300);
config_update_value ( 'netflow_interval', SECONDS_5MINUTES);
}
if (!isset ($config['netflow_daemon'])) {
config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd');
}
if (!isset ($config['auth'])) {
config_update_value ( 'auth', 'mysql');
}
if (!isset ($config['autocreate_remote_users'])) {
config_update_value ('autocreate_remote_users', 0);
}
if (!isset ($config['autocreate_blacklist'])) {
config_update_value ('autocreate_blacklist', '');
}
if (!isset ($config['default_remote_profile'])) {
config_update_value ('default_remote_profile', 0);
}
if (!isset ($config['default_remote_group'])) {
config_update_value ('default_remote_group', 0);
}
if (!isset ($config['ldap_server'])) {
config_update_value ( 'ldap_server', 'localhost');
}
if (!isset ($config['ldap_port'])) {
config_update_value ( 'ldap_port', 389);
}
if (!isset ($config['ldap_version'])) {
config_update_value ( 'ldap_version', '3');
}
if (!isset ($config['ldap_start_tls'])) {
config_update_value ( 'ldap_start_tls', 0);
}
if (!isset ($config['ldap_base_dn'])) {
config_update_value ( 'ldap_base_dn', 'ou=People,dc=edu,dc=example,dc=org');
}
if (!isset ($config['ldap_login_attr'])) {
config_update_value ( 'ldap_login_attr', 'uid');
}
if (!isset ($config['ad_server'])) {
config_update_value ( 'ad_server', 'localhost');
}
if (!isset ($config['ad_port'])) {
config_update_value ( 'ad_port', 389);
}
if (!isset ($config['ad_start_tls'])) {
config_update_value ( 'ad_start_tls', 0);
}
if (!isset ($config['ad_domain'])) {
config_update_value ( 'ad_domain', '');
}
if (!isset ($config['rpandora_server'])) {
config_update_value ( 'rpandora_server', 'localhost');
}
if (!isset ($config['rpandora_port'])) {
config_update_value ( 'rpandora_port', 3306);
}
if (!isset ($config['rpandora_dbname'])) {
config_update_value ( 'rpandora_dbname', 'pandora');
}
if (!isset ($config['rpandora_user'])) {
config_update_value ( 'rpandora_user', 'pandora');
}
if (!isset ($config['rpandora_pass'])) {
config_update_value ( 'rpandora_pass', '');
}
if (!isset ($config['rbabel_server'])) {
config_update_value ( 'rbabel_server', 'localhost');
}
if (!isset ($config['rbabel_port'])) {
config_update_value ( 'rbabel_port', 3306);
}
if (!isset ($config['rbabel_dbname'])) {
config_update_value ( 'rbabel_dbname', 'babel');
}
if (!isset ($config['rbabel_user'])) {
config_update_value ( 'rbabel_user', 'babel');
}
if (!isset ($config['rbabel_pass'])) {
config_update_value ( 'rbabel_pass', '');
}
if (!isset ($config['rintegria_server'])) {
config_update_value ( 'rintegria_server', 'localhost');
}
if (!isset ($config['rintegria_port'])) {
config_update_value ( 'rintegria_port', 3306);
}
if (!isset ($config['rintegria_dbname'])) {
config_update_value ( 'rintegria_dbname', 'integria');
}
if (!isset ($config['rintegria_user'])) {
config_update_value ( 'rintegria_user', 'integria');
}
if (!isset ($config['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
else if (!is_array($module_data) and preg_match('/^<img(.)*$/', $module_data)) {
return;
}
}
// Data initialization
$sum_obs = 0;
$sum_xi = 0;
@ -55,14 +55,14 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$sum_xi_yi = 0;
$sum_xi2 = 0;
$sum_yi2 = 0;
$sum_diff_dates = 0;
$sum_diff_dates = 0;
$last_timestamp = get_system_time();
$agent_interval = 300;
$agent_interval = SECONDS_5MINUTES;
$cont = 1;
$data = array();
//$table->data = array();
//$table->data = array();
// Creates data for calculation
// Creates data for calculation
foreach ($module_data as $utimestamp => $row) {
if ($utimestamp == '') {
continue;
@ -76,12 +76,12 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$data[5] = $utimestamp * $row['sum'];
$data[6] = $utimestamp * $utimestamp;
$data[7] = $row['sum'] * $row['sum'];
if ($cont == 1){
if ($cont == 1) {
$data[8] = 0;
}
else {
else {
$data[8] = $utimestamp - $last_timestamp;
}
}
$sum_obs = $sum_obs + $cont;
$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_xi2 = $sum_xi2 + $data[6];
$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;
$cont++;
//array_push($table->data, $data);
}
}
$cont--;
// 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_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y));
// Prevents division by zero
if ($dev_x != 0 and $dev_y != 0){
$linear_coef = $covariance / ($dev_x * $dev_y);
if ($dev_x != 0 and $dev_y != 0) {
$linear_coef = $covariance / ($dev_x * $dev_y);
}
// 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
// if $linear_coef < 0.0
// 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_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi));
if ($b_den == 0) return;
if ($b_den == 0)
return;
$b = $b_num / $b_den;
$a_num = ($sum_yi) - ($b * $sum_xi);
$a = $a_num / $cont;
$a = $a_num / $cont;
// Data inicialization
$output_data = array();
if ($prediction_period != false){
if ($prediction_period != false) {
$limit_timestamp = $last_timestamp + $prediction_period;
}
$current_ts = $last_timestamp;
@ -160,17 +164,17 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
if ($period < $prediction_period)
$temp_range = $prediction_period;
if ($temp_range <= 21600) {
if ($temp_range <= SECONDS_6HOURS) {
$time_format = 'H:i:s';
}
elseif ($temp_range < 86400) {
elseif ($temp_range < SECONDS_1DAY) {
$time_format = 'H:i';
}
elseif ($temp_range < 1296000) {
elseif ($temp_range < SECONDS_15DAYS) {
$time_format = 'M d';
$time_format_2 = 'H\h';
}
elseif ($temp_range <= 2592000) {
elseif ($temp_range <= SECONDS_1MONTH) {
$time_format = 'M d';
$time_format_2 = 'H\h';
}
@ -182,38 +186,39 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$output_data = array();
$idx = 0;
// 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 = graph_get_formatted_date($current_ts, $time_format, $time_format_2);
if ($csv){
if ($csv) {
$output_data[$idx]['date'] = $current_ts;
$output_data[$idx]['data'] = ($a + ($b * $current_ts));
}
else{
else {
$output_data[$timestamp_f] = ($a + ($b * $current_ts));
}
// 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
if ($current_ts - $last_timestamp >= 94608000){
if ($current_ts - $last_timestamp >= 94608000) {
return false;
}
}
//html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]);
// Found it
if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){
return $current_ts;
}
}else if ($current_ts > $limit_timestamp){
}
else if ($current_ts > $limit_timestamp) {
$in_range = false;
}
$current_ts = $current_ts + $agent_interval;
$idx++;
}
}
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){
// Checks interval
if ($min_value > $max_value){
if ($min_value > $max_value) {
return false;
}
}
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"])){
$id_agente = $_GET["id_agente"];
}
include_once($config['homedir'] . "/include/functions_modules.php");
// View last data packet
// View last data packet
// Get timestamp of last packet
$agent = db_get_row ('tagente', 'id_agente', $id_agente,
array ('ultimo_contacto_remoto',
@ -180,12 +180,12 @@ $extra_sql = '';
// Build the order sql
if(!empty($order)) {
if (!empty($order)) {
$order_sql = ' ORDER BY ';
}
$first = true;
foreach($order as $ord) {
if($first) {
foreach ($order as $ord) {
if ($first) {
$first = false;
}
else {
@ -232,20 +232,20 @@ switch ($config["dbtype"]) {
case "postgresql":
$limit_sql = " LIMIT $limit OFFSET $offset ";
case "mysql":
if(!isset($limit_sql)) {
if (!isset($limit_sql)) {
$limit_sql = " LIMIT $offset, $limit ";
}
$order[] = array('field' => 'tagente_modulo.nombre', 'order' => 'ASC');
$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);
break;
case "oracle":
$order[] = array('field' => 'dbms_lob.substr(tagente_modulo.nombre,4000,1)', 'order' => 'ASC');
$set = array();
$set['limit'] = $limit;
$set['offset'] = $offset;
@ -276,16 +276,16 @@ if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
echo "<th><span title='" . __('Policy') . "'>".__('P.')."</span></th>";
}
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=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . '</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>';
echo "</th>";
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=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectTypeDown, "alt" => "down")) . '</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>';
echo "</th>";
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=down">' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown, "alt" => "down")) . '</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>';
echo "</th>";
echo "<th>".__('Description') . "</th>";
echo "<th>".__('Data') . ' ' .
@ -303,7 +303,7 @@ $color = 1;
$write = check_acl ($config['id_user'], $agent['id_grupo'], "AW");
foreach ($modules as $module) {
// Calculate table line color
if ($color == 1){
if ($color == 1) {
$tdcolor = "datos";
$color = 0;
}
@ -312,7 +312,7 @@ foreach ($modules as $module) {
$color = 1;
}
if ($module["id_module_group"] != $last_modulegroup ){
if ($module["id_module_group"] != $last_modulegroup ) {
// Render module group names (fixed code)
$nombre_grupomodulo = modules_get_modulegroup_name ($module["id_module_group"]);
$last_modulegroup = $module["id_module_group"];
@ -338,7 +338,7 @@ foreach ($modules as $module) {
echo "</td>";
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']);
$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);
@ -382,7 +382,7 @@ foreach ($modules as $module) {
}
}
$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
$label_group = -1;
$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 "</td>";
}
else{
else {
echo "<td></td>";
}
@ -454,7 +454,7 @@ foreach ($modules as $module) {
io_safe_output(io_safe_output($module["datos"]), 45, false);
}
echo "</td>";
$handle = "stat".$nombre_tipo_modulo."_".$module["id_agente_modulo"];
$url = 'include/procesos.php?agente='.$module["id_agente_modulo"];
$win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
@ -504,4 +504,4 @@ foreach ($modules as $module) {
}
echo '</table>';
?>
?>

View File

@ -59,7 +59,8 @@ $filename_map .= "_".$id_networkmap.".map";
$filename_img .= "_".$id_networkmap.".png";
$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;
}
else {

View File

@ -37,6 +37,7 @@ $graph = networkmap_generate_dot (__('Pandora FMS'), $group, $simple, $font_size
if ($graph === false) {
ui_print_error_message (__('Map could not be generated'));
echo '<div class="nf">' . __('No agents found') . '</div>';
return;
}
@ -59,7 +60,8 @@ $filename_map .= "_".$id_networkmap.".map";
$filename_img .= "_".$id_networkmap.".png";
$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;
}
else {
@ -83,6 +85,7 @@ if ($result !== false) {
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 /><br /> Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?";
return;
}
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 /><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"];
return;
}

View File

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

View File

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