2012-07-16 Miguel de Dios <miguel.dedios@artica.es>

* extensions/agents_modules.php, extensions/users_connected.php,
	extensions/agents_alerts.php,
	operation/visual_console/render_view.php,
	operation/visual_console/public_console.php,
	operation/agentes/networkmap.groups.php,
	operation/agentes/estado_ultimopaquete.php,
	operation/agentes/networkmap.topology.php, general/header.php,
	godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
	godmode/alerts/configure_alert_compound.php,
	godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
	godmode/modules/manage_network_components_form_wmi.php,
	include/functions_config.php, include/functions_api.php,
	include/functions_agents.php, include/functions_forecast.php:
	cleaned source code style and change magic numbers for time
	constants.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-16 09:24:04 +00:00
parent dbf98363f4
commit b967940c41
20 changed files with 826 additions and 723 deletions

View File

@ -1,3 +1,21 @@
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
2012-07-16 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2012-07-16 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* operation/tree.php: Removed trace. * operation/tree.php: Removed trace.

View File

@ -76,7 +76,13 @@ function mainAgentsAlerts() {
$comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">'; $comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">';
$comborefr .= '<b>'.__('Refresh').'</b>'; $comborefr .= '<b>'.__('Refresh').'</b>';
$comborefr .= html_print_select (array('30' => '30 '.__('seconds'), '60' => '1 '.__('minute'), '120' => '2 '.__('minutes'), '300' => '5 '.__('minutes'), '600' => '10 '.__('minutes')) , 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); $comborefr .= html_print_select (
array('30' => '30 '.__('seconds'),
(string)SECONDS_1MINUTE => __('1 minute'),
(string)SECONDS_2MINUTES => __('2 minutes'),
(string)SECONDS_5MINUTES => __('5 minutes'),
(string)SECONDS_10MINUTES => __('10 minutes'))
, 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;');
$comborefr .= "</form>"; $comborefr .= "</form>";
if ($config["pure"] == 0) { if ($config["pure"] == 0) {
@ -114,8 +120,11 @@ function mainAgentsAlerts() {
} }
// Get the id of all agents with alerts // Get the id of all agents with alerts
$sql = 'SELECT DISTINCT(id_agente) FROM tagente_modulo WHERE id_agente_modulo IN $sql = 'SELECT DISTINCT(id_agente)
(SELECT id_agent_module FROM talert_template_modules)'; FROM tagente_modulo
WHERE id_agente_modulo IN
(SELECT id_agent_module
FROM talert_template_modules)';
$agents_with_alerts_raw = db_get_all_rows_sql($sql); $agents_with_alerts_raw = db_get_all_rows_sql($sql);
if ($agents_with_alerts_raw === false) { if ($agents_with_alerts_raw === false) {
@ -165,7 +174,8 @@ function mainAgentsAlerts() {
} }
if (!empty($templates)) { if (!empty($templates)) {
$sql = sprintf('SELECT id, name FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates))); $sql = sprintf('SELECT id, name
FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates)));
$templates_raw = db_get_all_rows_sql($sql); $templates_raw = db_get_all_rows_sql($sql);
} }

View File

@ -84,7 +84,13 @@ function mainAgentsModules() {
$comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">'; $comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => 0, 'hor_offset' => 0)).'">';
$comborefr .= '<b>'.__('Refresh').'</b>'; $comborefr .= '<b>'.__('Refresh').'</b>';
$comborefr .= html_print_select (array('30' => '30 '.__('seconds'), '60' => '1 '.__('minute'), '120' => '2 '.__('minutes'), '300' => '5 '.__('minutes'), '600' => '10 '.__('minutes')) , 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); $comborefr .= html_print_select (
array('30' => '30 '.__('seconds'),
(string)SECONDS_1MINUTE => __('1 minute'),
(string)SECONDS_2MINUTES => __('2 minutes'),
(string)SECONDS_5MINUTES => __('5 minutes'),
(string)SECONDS_10MINUTES => __('10 minutes')),
'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;');
$comborefr .= "</form>"; $comborefr .= "</form>";
if ($config["pure"] == 0) { if ($config["pure"] == 0) {
@ -308,4 +314,3 @@ extensions_add_operation_menu_option(__("Agents/Modules view"), 'estado', 'agent
extensions_add_main_function('mainAgentsModules'); extensions_add_main_function('mainAgentsModules');
?> ?>

View File

@ -35,17 +35,20 @@ function users_extension_main_god ($god = true) {
case "mysql": case "mysql":
$sql = "SELECT id_user, last_connect $sql = "SELECT id_user, last_connect
FROM tusuario FROM tusuario
WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - 300) ORDER BY last_connect DESC"; WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - " . SECONDS_5MINUTES . ")
ORDER BY last_connect DESC";
break; break;
case "postgresql": case "postgresql":
$sql = "SELECT id_user, last_connect $sql = "SELECT id_user, last_connect
FROM tusuario FROM tusuario
WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - 300) ORDER BY last_connect DESC"; WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_5MINUTES . ")
ORDER BY last_connect DESC";
break; break;
case "oracle": case "oracle":
$sql = "SELECT id_user, last_connect $sql = "SELECT id_user, last_connect
FROM tusuario FROM tusuario
WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) - 300) ORDER BY last_connect DESC"; WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_5MINUTES . ")
ORDER BY last_connect DESC";
break; break;
} }

View File

@ -36,7 +36,8 @@ config_check();
<?php <?php
if (!defined ('PANDORA_ENTERPRISE')) { if (!defined ('PANDORA_ENTERPRISE')) {
echo html_print_image('images/pandora_header_logo.png', true, array("alt" => 'Pandora FMS Opensource', "border" => '0')); echo html_print_image('images/pandora_header_logo.png', true, array("alt" => 'Pandora FMS Opensource', "border" => '0'));
} else { }
else {
echo html_print_image('images/pandora_header_logo_enterprise.png', true, array("alt" => 'Pandora FMS Enterprise', "border" => '0')); echo html_print_image('images/pandora_header_logo_enterprise.png', true, array("alt" => 'Pandora FMS Enterprise', "border" => '0'));
} }
?> ?>
@ -98,10 +99,10 @@ config_check();
echo "&nbsp;"; echo "&nbsp;";
html_print_image("images/application_double.png", false, array("alt" => __('Metaconsole activated'), "class" => 'bot', "title" => __('You are using metaconsole'))); html_print_image("images/application_double.png", false, array("alt" => __('Metaconsole activated'), "class" => 'bot', "title" => __('You are using metaconsole')));
} }
?>
echo '</td>'; </td>
echo '<td width="20%">'; <td width="20%">
<?php
if ($config["metaconsole"] == 0) { if ($config["metaconsole"] == 0) {
echo '<a class="white_bold" href="index.php?sec=gservers&amp;sec2=godmode/servers/modificar_server&amp;refr=60">'; echo '<a class="white_bold" href="index.php?sec=gservers&amp;sec2=godmode/servers/modificar_server&amp;refr=60">';
@ -123,7 +124,6 @@ config_check();
unset ($servers); // Since this is the header, we don't like to trickle down variables. unset ($servers); // Since this is the header, we don't like to trickle down variables.
echo '</a>'; echo '</a>';
} }
?> ?>
</td> </td>
<td width="20%"> <td width="20%">
@ -140,23 +140,25 @@ config_check();
$ignored_params['refr'] = ''; $ignored_params['refr'] = '';
echo '<a id="autorefresh" class="white_bold" href="' . ui_get_url_refresh ($ignored_params).'">' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . '&nbsp;'. __('Autorefresh').'</a>'; echo '<a id="autorefresh" class="white_bold" href="' . ui_get_url_refresh ($ignored_params).'">' . html_print_image("images/page_refresh.png", true, array("class" => 'bot', "alt" => 'lightning')) . '&nbsp;'. __('Autorefresh').'</a>';
$values = array ( $values = array (
'5' => '5 '.__('seconds'), '5' => __('5 seconds'),
'10' => '10 '.__('seconds'), '10' => __('10 seconds'),
'15' => '15 '.__('seconds'), '15' => __('15 seconds'),
'30' => '30 '.__('seconds'), '30' => __('30 seconds'),
'60' => '1 '.__('minute'), (string)SECONDS_1MINUTE => __('1 minute'),
'120' => '2 '.__('minutes'), (string)SECONDS_2MINUTES => __('2 minutes'),
'300' => '5 '.__('minutes'), (string)SECONDS_5MINUTES => __('5 minutes'),
'900' => '15 '.__('minutes'), (string)SECONDS_15MINUTES => __('15 minutes'),
'1800' => '30 '.__('minutes'), (string)SECONDS_30MINUTES => __('30 minutes'),
'3600' => '1 '.__('hour')); (string)SECONDS_1HOUR => __('1 hour'));
echo '<span id="combo_refr" style="display: none">'; echo '<span id="combo_refr" style="display: none">';
html_print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false); html_print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false);
unset ($values); unset ($values);
echo '</span>'; echo '</span>';
} }
echo "</td>"; ?>
echo "<td width='20%' rowspan='2'>"; </td>
<td width='20%' rowspan='2'>
<?php
echo "<a href='index.php?sec=main'>"; echo "<a href='index.php?sec=main'>";
if (isset($config["custom_logo"])) if (isset($config["custom_logo"]))
echo html_print_image("images/custom_logo/" . $config["custom_logo"], true,array("height" => '60', "width" => '139', "alt" => 'Logo')); echo html_print_image("images/custom_logo/" . $config["custom_logo"], true,array("height" => '60', "width" => '139', "alt" => 'Logo'));
@ -166,7 +168,6 @@ config_check();
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<?php <?php
if ($config["metaconsole"] == 0) { if ($config["metaconsole"] == 0) {
?> ?>
@ -208,14 +209,7 @@ if ($config["metaconsole"] == 0){
ui_require_css_file ('jquery-ui-1.8.17.custom'); ui_require_css_file ('jquery-ui-1.8.17.custom');
ui_require_jquery_file('jquery-ui-1.8.17.custom.min'); ui_require_jquery_file('jquery-ui-1.8.17.custom.min');
?> ?>
<!--
<script type="text/javascript" src="include/javascript/jquery.ui.dialog.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.draggable.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.droppable.js "></script>
<script type="text/javascript" src="include/javascript/jquery.ui.resizable.js "></script>
-->
<script type="text/javascript" src="include/javascript/webchat.js "></script> <script type="text/javascript" src="include/javascript/webchat.js "></script>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
var new_chat = <?php echo (int)$_SESSION['new_chat'];?>; var new_chat = <?php echo (int)$_SESSION['new_chat'];?>;
@ -230,13 +224,28 @@ if ($config["metaconsole"] == 0){
$("#agent_access").css("display",""); $("#agent_access").css("display","");
}); });
<?php if ($msg_cnt > 0): ?>
<?php
if ($msg_cnt > 0) {
?>
$("#yougotmail").pulsate (); $("#yougotmail").pulsate ();
<?php endif; ?> <?php
<?php if ($config["alert_cnt"] > 0): ?> }
?>
<?php
if ($config["alert_cnt"] > 0) {
?>
$("#yougotalert").pulsate (); $("#yougotalert").pulsate ();
<?php endif; ?> <?php
<?php if ($config["refr"]): ?> }
?>
<?php
if ($config["refr"]) {
?>
t = new Date(); t = new Date();
t.setTime (t.getTime () + <?php echo $config["refr"] * 1000; ?>); t.setTime (t.getTime () + <?php echo $config["refr"] * 1000; ?>);
$("#refrcounter").countdown ({until: t, $("#refrcounter").countdown ({until: t,
@ -246,7 +255,10 @@ if ($config["metaconsole"] == 0){
$(this).text ("..."); $(this).text ("...");
} }
}); });
<?php else: ?> <?php
}
else {
?>
$("a#autorefresh").click (function () { $("a#autorefresh").click (function () {
var a = this; var a = this;
@ -259,7 +271,9 @@ if ($config["metaconsole"] == 0){
return false; return false;
}); });
<?php endif; ?> <?php
}
?>
}); });
/* ]]> */ /* ]]> */
</script> </script>

View File

@ -62,7 +62,7 @@ $maximo = 0;
$minimo = 0; $minimo = 0;
$nombre_agente = ""; $nombre_agente = "";
$direccion_agente = get_parameter ('direccion', ''); $direccion_agente = get_parameter ('direccion', '');
$intervalo = 300; $intervalo = SECONDS_5MINUTES;
$ff_interval = 0; $ff_interval = 0;
$id_server = ""; $id_server = "";
$max_alerts = 0; $max_alerts = 0;
@ -131,7 +131,7 @@ if ($create_agent) {
$nombre_agente = (string) get_parameter_post ("agente",''); $nombre_agente = (string) get_parameter_post ("agente",'');
$direccion_agente = (string) get_parameter_post ("direccion",''); $direccion_agente = (string) get_parameter_post ("direccion",'');
$grupo = (int) get_parameter_post ("grupo"); $grupo = (int) get_parameter_post ("grupo");
$intervalo = (string) get_parameter_post ("intervalo", 300); $intervalo = (string) get_parameter_post ("intervalo", SECONDS_5MINUTES);
$comentarios = (string) get_parameter_post ("comentarios", ''); $comentarios = (string) get_parameter_post ("comentarios", '');
$modo = (int) get_parameter_post ("modo"); $modo = (int) get_parameter_post ("modo");
$id_parent = (string) get_parameter_post ("id_parent",''); $id_parent = (string) get_parameter_post ("id_parent",'');
@ -162,7 +162,8 @@ if ($create_agent) {
$agent_created_ok = 0; $agent_created_ok = 0;
} }
elseif (agents_get_agent_id ($nombre_agente)) { elseif (agents_get_agent_id ($nombre_agente)) {
$agent_creation_error = __('There is already an agent in the database with this name'); $agent_creation_error =
__('There is already an agent in the database with this name');
$agent_created_ok = 0; $agent_created_ok = 0;
} }
else { else {
@ -230,7 +231,6 @@ if ($id_agente) {
. html_print_image ("images/cog.png", true, array ("title" =>__('Setup'))) . html_print_image ("images/cog.png", true, array ("title" =>__('Setup')))
. '</a>'; . '</a>';
if ($tab == 'main') if ($tab == 'main')
$maintab['active'] = true; $maintab['active'] = true;
else else
$maintab['active'] = false; $maintab['active'] = false;
@ -315,9 +315,16 @@ if ($id_agente) {
$incidenttab['active'] = false; $incidenttab['active'] = false;
} }
$onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab, $onheader = array('view' => $viewtab,
'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab, 'separator' => "",
'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab); 'main' => $maintab,
'module' => $moduletab,
'alert' => $alerttab,
'template' => $templatetab,
'inventory' => $inventorytab,
'collection'=> $collectiontab,
'group' => $grouptab,
'gis' => $gistab);
// Only if the agent has incidents associated show incidents tab // Only if the agent has incidents associated show incidents tab
if ($total_incidents) { if ($total_incidents) {
@ -378,6 +385,7 @@ if ($id_agente) {
switch ($id_extension) { switch ($id_extension) {
case "snmp_explorer": case "snmp_explorer":
$tab_description = '- ' . __('SNMP explorer') . ui_print_help_icon('snmp_explorer', true); $tab_description = '- ' . __('SNMP explorer') . ui_print_help_icon('snmp_explorer', true);
break;
} }
break; break;
default: default:
@ -465,7 +473,7 @@ if ($update_agent) { // if modified some agent paramenter
$direccion_agente = $address_list; $direccion_agente = $address_list;
} }
$grupo = (int) get_parameter_post ("grupo", 0); $grupo = (int) get_parameter_post ("grupo", 0);
$intervalo = (int) get_parameter_post ("intervalo", 300); $intervalo = (int) get_parameter_post ("intervalo", SECONDS_5MINUTES);
$comentarios = str_replace('`','&lsquo;',(string) get_parameter_post ("comentarios", "")); $comentarios = str_replace('`','&lsquo;',(string) get_parameter_post ("comentarios", ""));
$modo = (bool) get_parameter_post ("modo", 0); //Mode: Learning or Normal $modo = (bool) get_parameter_post ("modo", 0); //Mode: Learning or Normal
$id_os = (int) get_parameter_post ("id_os"); $id_os = (int) get_parameter_post ("id_os");
@ -507,16 +515,19 @@ if ($update_agent) { // if modified some agent paramenter
//Verify if there is another agent with the same name but different ID //Verify if there is another agent with the same name but different ID
if ($nombre_agente == "") { if ($nombre_agente == "") {
echo '<h3 class="error">'.__('No agent name specified').'</h3>'; ui_print_error_message(__('No agent name specified'));
//If there is an agent with the same name, but a different ID //If there is an agent with the same name, but a different ID
} }
elseif (agents_get_agent_id ($nombre_agente) > 0 && agents_get_agent_id ($nombre_agente) != $id_agente) { elseif (agents_get_agent_id ($nombre_agente) > 0 &&
echo '<h3 class="error">'.__('There is already an agent in the database with this name').'</h3>'; agents_get_agent_id ($nombre_agente) != $id_agente) {
ui_print_error_message(__('There is already an agent in the database with this name'));
} }
else { else {
//If different IP is specified than previous, add the IP //If different IP is specified than previous, add the IP
if ($direccion_agente != '' && $direccion_agente != agents_get_address ($id_agente)) if ($direccion_agente != '' &&
$direccion_agente != agents_get_address ($id_agente)) {
agents_add_address ($id_agente, $direccion_agente); agents_add_address ($id_agente, $direccion_agente);
}
//If IP is set for deletion, delete first //If IP is set for deletion, delete first
if (isset ($_POST["delete_ip"])) { if (isset ($_POST["delete_ip"])) {
@ -543,7 +554,8 @@ if ($update_agent) { // if modified some agent paramenter
array ('id_agente' => $id_agente)); array ('id_agente' => $id_agente));
if ($result === false) { if ($result === false) {
ui_print_error_message (__('There was a problem updating the agent')); ui_print_error_message(
__('There was a problem updating the agent'));
} }
else { else {
$info = 'Group: ' . $grupo . ' Interval: ' . $intervalo . $info = 'Group: ' . $grupo . ' Interval: ' . $intervalo .
@ -558,7 +570,6 @@ if ($update_agent) { // if modified some agent paramenter
ui_print_success_message (__('Successfully updated')); ui_print_success_message (__('Successfully updated'));
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
"Updated agent $nombre_agente", false, false, $info); "Updated agent $nombre_agente", false, false, $info);
} }
} }
} }
@ -691,7 +702,6 @@ if ($update_module || $create_module) {
$plugin_pass = (int) get_parameter ('plugin_pass'); $plugin_pass = (int) get_parameter ('plugin_pass');
else else
$plugin_pass = (string) get_parameter ('plugin_pass'); $plugin_pass = (string) get_parameter ('plugin_pass');
$plugin_parameter = (string) get_parameter ('plugin_parameter'); $plugin_parameter = (string) get_parameter ('plugin_parameter');
} }
@ -716,7 +726,7 @@ if ($update_module || $create_module) {
$active_snmp_v3 = get_parameter('active_snmp_v3'); $active_snmp_v3 = get_parameter('active_snmp_v3');
if ($active_snmp_v3) { if ($active_snmp_v3) {
// //LOST CODE?
} }
// Make changes in the conf file if necessary // Make changes in the conf file if necessary
@ -777,26 +787,24 @@ if ($update_module) {
} }
if (is_error($result)) { if (is_error($result)) {
$msg = __('There was a problem updating module').'. ';
switch($result) { switch($result) {
case ERR_EXIST: case ERR_EXIST:
$msg .= __('Another module already exists with the same name').'.'; $msg = __('There was a problem updating module. Another module already exists with the same name.');
break; break;
case ERR_INCOMPLETE: case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')'; $msg = __('There was a problem updating module. Some required fields are missed: (name)');
break; break;
case ERR_NOCHANGES: case ERR_NOCHANGES:
$msg .= __('"No change"'); $msg = __('There was a problem updating module. "No change"');
break; break;
case ERR_DB: case ERR_DB:
case ERR_GENERIC: case ERR_GENERIC:
default: default:
$msg .= __('Processing error'); $msg = __('There was a problem updating module. Processing error');
break; break;
} }
$result = false; $result = false;
echo '<h3 class="error">'.$msg.'</h3>'; ui_print_error_message($msg);
$edit_module = true; $edit_module = true;
@ -807,7 +815,7 @@ if ($update_module) {
if ($prediction_module == 3) { if ($prediction_module == 3) {
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops)); enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
} }
echo '<h3 class="suc">'.__('Module successfully updated').'</h3>'; ui_print_success_message(__('Module successfully updated'));
$id_agent_module = false; $id_agent_module = false;
$edit_module = false; $edit_module = false;
@ -875,8 +883,8 @@ if ($create_module) {
'custom_integer_1' => $custom_integer_1, 'custom_integer_1' => $custom_integer_1,
'custom_integer_2' => $custom_integer_2, 'custom_integer_2' => $custom_integer_2,
'min_ff_event' => $ff_event, 'min_ff_event' => $ff_event,
'unit' => $unit 'unit' => $unit);
);
if($prediction_module == 3 && $serialize_ops == '') { if($prediction_module == 3 && $serialize_ops == '') {
$id_agent_module = false; $id_agent_module = false;
} }
@ -885,22 +893,21 @@ if ($create_module) {
} }
if (is_error($id_agent_module)) { if (is_error($id_agent_module)) {
$msg = __('There was a problem adding module').'. ';
switch($id_agent_module) { switch($id_agent_module) {
case ERR_EXIST: case ERR_EXIST:
$msg .= __('Another module already exists with the same name').'.'; $msg __('There was a problem adding module. Another module already exists with the same name.');
break; break;
case ERR_INCOMPLETE: case ERR_INCOMPLETE:
$msg .= __('Some required fields are missed').': ('.__('name').')'; $msg __('There was a problem adding module. Some required fields are missed : (name)');
break; break;
case ERR_DB: case ERR_DB:
case ERR_GENERIC: case ERR_GENERIC:
default: default:
$msg .= __('Processing error'); $msg __('There was a problem adding module. Processing error');
break; break;
} }
$id_agent_module = false; $id_agent_module = false;
echo '<h3 class="error">'.$msg.'</h3>'; ui_print_error_message($msg);
$edit_module = true; $edit_module = true;
$moduletype = $id_module; $moduletype = $id_module;
db_pandora_audit("Agent management", db_pandora_audit("Agent management",
@ -911,7 +918,7 @@ if ($create_module) {
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops)); enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
} }
echo '<h3 class="suc">'.__('Module added successfully').'</h3>'; ui_print_success_message(__('Module added successfully'));
$id_agent_module = false; $id_agent_module = false;
$edit_module = false; $edit_module = false;
@ -996,8 +1003,10 @@ if ($delete_module) { // DELETE agent module !
$last_target_module = 0; $last_target_module = 0;
foreach ($result_components as $id_target_module){ foreach ($result_components as $id_target_module){
// Detects change of component or last component to update orders // Detects change of component or last component to update orders
if (($count_components == $num_components) or ($last_target_module != $id_target_module)) if (($count_components == $num_components) or
($last_target_module != $id_target_module)) {
$update_orders = true; $update_orders = true;
}
else else
$update_orders = false; $update_orders = false;
$result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_borrar_modulo, $update_orders)); $result = enterprise_hook('modules_delete_synthetic_operations', array($id_target_module, $id_borrar_modulo, $update_orders));
@ -1031,7 +1040,7 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
$id_duplicate_module = $duplicate_module; $id_duplicate_module = $duplicate_module;
$original_name = modules_get_agentmodule_name($id_duplicate_module); $original_name = modules_get_agentmodule_name($id_duplicate_module);
$copy_name = io_safe_input(__('copy of') . ' ') . $original_name; $copy_name = sprintf(__('copy of %s'), $original_name);
$cont = 0; $cont = 0;
$exists = true; $exists = true;
@ -1040,8 +1049,7 @@ if (!empty($duplicate_module)) { // DUPLICATE agent module !
'nombre', $copy_name); 'nombre', $copy_name);
if ($exists) { if ($exists) {
$cont++; $cont++;
$copy_name = io_safe_input(__('copy of') . ' ') . $original_name $copy_name = sprintf(__('copy of %s (%d)'), $original_name, $cont);
. io_safe_input(' (' . $cont . ')');
} }
} }
@ -1085,7 +1093,7 @@ if ($updateGIS) {
"altitude" => $previusAgentGISData['stored_altitude'], "altitude" => $previusAgentGISData['stored_altitude'],
"start_timestamp" => $previusAgentGISData['start_timestamp'], "start_timestamp" => $previusAgentGISData['start_timestamp'],
"end_timestamp" => date( 'Y-m-d H:i:s'), "end_timestamp" => date( 'Y-m-d H:i:s'),
"description" => "Save by Pandora Console", "description" => __('Save by Pandora Console'),
"manual_placement" => $previusAgentGISData['manual_placement'], "manual_placement" => $previusAgentGISData['manual_placement'],
"number_of_packages" => $previusAgentGISData['number_of_packages'], "number_of_packages" => $previusAgentGISData['number_of_packages'],
"tagente_id_agente" => $previusAgentGISData['tagente_id_agente'] "tagente_id_agente" => $previusAgentGISData['tagente_id_agente']
@ -1100,7 +1108,7 @@ if ($updateGIS) {
"stored_altitude" => $lastAltitude, "stored_altitude" => $lastAltitude,
"start_timestamp" => date( 'Y-m-d H:i:s'), "start_timestamp" => date( 'Y-m-d H:i:s'),
"manual_placement" => 1, "manual_placement" => 1,
"description" => "Update by Pandora Console"), "description" => __('Update by Pandora Console')),
array("tagente_id_agente" => $idAgente)); array("tagente_id_agente" => $idAgente));
} }
else { else {
@ -1113,7 +1121,7 @@ if ($updateGIS) {
"stored_latitude" => $lastLatitude, "stored_latitude" => $lastLatitude,
"stored_altitude" => $lastAltitude, "stored_altitude" => $lastAltitude,
"manual_placement" => 1, "manual_placement" => 1,
"description" => "Insert by Pandora Console" "description" => __('Insert by Pandora Console')
)); ));
} }
db_process_sql_commit(); db_process_sql_commit();
@ -1165,13 +1173,15 @@ switch ($tab) {
} }
} }
if (!$found) { if (!$found) {
ui_print_error_message ("Invalid tab specified"); ui_print_error_message (__('Invalid tab specified'));
} }
break; break;
default: default:
if (enterprise_hook ('switch_agent_tab', array ($tab))) if (enterprise_hook ('switch_agent_tab', array ($tab))) {
//This will make sure that blank pages will have at least some //This will make sure that blank pages will have at least some
//debug info in them - do not translate debug //debug info in them - do not translate debug
ui_print_error_message ("Invalid tab specified"); ui_print_error_message (__('Invalid tab specified'));
}
break;
} }
?> ?>

View File

@ -236,7 +236,7 @@ $field2 = '';
$field3 = ''; $field3 = '';
$min_alerts = 0; $min_alerts = 0;
$max_alerts = 1; $max_alerts = 1;
$threshold = 300; $threshold = SECONDS_5MINUTES;
$recovery_notify = false; $recovery_notify = false;
$field2_recovery = ''; $field2_recovery = '';
$field3_recovery = ''; $field3_recovery = '';
@ -287,7 +287,8 @@ if ($create_compound) {
/* Go to previous step in case of error */ /* Go to previous step in case of error */
if ($result === false) { if ($result === false) {
$step = $step - 1; $step = $step - 1;
} else { }
else {
$id = $result; $id = $result;
$alerts = (array) get_parameter ('conditions'); $alerts = (array) get_parameter ('conditions');
$operations = (array) get_parameter ('operations'); $operations = (array) get_parameter ('operations');
@ -329,7 +330,8 @@ if ($step == 2) {
$table->style['other_label'] = 'display:none; font-weight: bold'; $table->style['other_label'] = 'display:none; font-weight: bold';
$table->style['other_input'] = 'display:none'; $table->style['other_input'] = 'display:none';
$threshold_selected = $threshold; $threshold_selected = $threshold;
} else { }
else {
$table->style['other_label'] = 'font-weight: bold'; $table->style['other_label'] = 'font-weight: bold';
$threshold_selected = -1; $threshold_selected = -1;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
return false; return false;
if (empty ($ip_address)) if (empty ($ip_address))
return false; return false;
$interval = safe_int ($interval,1, 300); $interval = safe_int ($interval,1, SECONDS_5MINUTES);
if (empty ($interval)) if (empty ($interval))
return false; return false;
if (! is_array ($values)) if (! is_array ($values))
@ -145,6 +145,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
break; break;
default: default:
$filter .= ''; $filter .= '';
break;
} }
if (is_array ($options)) { if (is_array ($options)) {
@ -254,7 +255,8 @@ function agents_get_alerts_compound ($id_agent = false, $filter = '', $options =
if (($id_agent !== false) && ($idGroup !== false)) { if (($id_agent !== false) && ($idGroup !== false)) {
if ($idGroup != 0) { //All group if ($idGroup != 0) { //All group
$subQuery = 'SELECT id_agente FROM tagente WHERE id_grupo = ' . $idGroup; $subQuery = 'SELECT id_agente
FROM tagente WHERE id_grupo = ' . $idGroup;
} }
else { else {
$subQuery = 'SELECT id_agente FROM tagente'; $subQuery = 'SELECT id_agente FROM tagente';
@ -275,7 +277,8 @@ function agents_get_alerts_compound ($id_agent = false, $filter = '', $options =
$selectText = 'COUNT(id) AS count'; $selectText = 'COUNT(id) AS count';
} }
$sql = sprintf ("SELECT %s FROM talert_compound $sql = sprintf ("SELECT %s
FROM talert_compound
WHERE id_agent IN (%s) %s %s", WHERE id_agent IN (%s) %s %s",
$selectText, $subQuery, $where, $filter); $selectText, $subQuery, $where, $filter);
@ -333,7 +336,8 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$status_sql = ' 1 = 1'; $status_sql = ' 1 = 1';
if (isset($filter['status'])) { if (isset($filter['status'])) {
$normal_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $normal_modules = 'SELECT tagente.id_agente
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 0 AND tagente_modulo.disabled = 0 AND estado = 0
@ -341,27 +345,31 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2)) AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'*/; OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'*/;
$warning_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $warning_modules = 'SELECT tagente.id_agente
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 2 AND tagente_estado.utimestamp != 0'; AND tagente_modulo.disabled = 0 AND estado = 2 AND tagente_estado.utimestamp != 0';
/* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2)) /* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';*/ OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';*/
$critical_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $critical_modules = 'SELECT tagente.id_agente
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente WHERE tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.utimestamp != 0'; AND tagente_modulo.disabled = 0 AND estado = 1 AND tagente_estado.utimestamp != 0';
/* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2)) /* AND (utimestamp >= ( UNIX_TIMESTAMP() - (current_interval * 2))
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'; */ OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))'; */
$unknown_modules = 'SELECT tagente.id_agente FROM tagente_estado, tagente, tagente_modulo $unknown_modules = 'SELECT tagente.id_agente
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND estado = 3 AND utimestamp != 0' /*AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100) AND tagente_modulo.disabled = 0 AND estado = 3 AND utimestamp != 0' /*AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)
AND utimestamp < ( UNIX_TIMESTAMP() - (current_interval * 2)) AND utimestamp != 0'*/; AND utimestamp < ( UNIX_TIMESTAMP() - (current_interval * 2)) AND utimestamp != 0'*/;
$notinit_modules = 'SELECT tagente_estado.id_agente FROM tagente_estado, tagente, tagente_modulo $notinit_modules = 'SELECT tagente_estado.id_agente
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente WHERE tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
@ -399,7 +407,6 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$status_sql = "id_agente NOT IN ($warning_modules) && $status_sql = "id_agente NOT IN ($warning_modules) &&
id_agente NOT IN ($critical_modules) && id_agente NOT IN ($unknown_modules) && id_agente NOT IN ($normal_modules)"; id_agente NOT IN ($critical_modules) && id_agente NOT IN ($unknown_modules) && id_agente NOT IN ($normal_modules)";
break; break;
} }
unset($filter['status']); unset($filter['status']);
} }
@ -478,10 +485,13 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
if($extra) { if($extra) {
$where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search); $where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search);
} else { }
else {
$where = sprintf('%s AND %s AND (%s) %s', $where, $where_nogroup, $status_sql, $search); $where = sprintf('%s AND %s AND (%s) %s', $where, $where_nogroup, $status_sql, $search);
} }
$sql = sprintf('SELECT %s FROM tagente WHERE %s %s', implode(',',$fields), $where, $order); $sql = sprintf('SELECT %s
FROM tagente
WHERE %s %s', implode(',',$fields), $where, $order);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
@ -588,7 +598,7 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
if (empty ($target_modules)) { if (empty ($target_modules)) {
if (! $copy_alerts) { if (! $copy_alerts) {
echo '<h3 class="error">'.__('No modules have been selected').'</h3>'; ui_print_error_message(__('No modules have been selected'));
return false; return false;
} }
$target_modules = array (); $target_modules = array ();
@ -619,7 +629,6 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
$repeated_modules = array(); $repeated_modules = array();
foreach ($destiny_id_agents as $id_destiny_agent) { foreach ($destiny_id_agents as $id_destiny_agent) {
foreach ($target_modules as $id_agent_module) { foreach ($target_modules as $id_agent_module) {
// Check the module name exists in target // Check the module name exists in target
$module = modules_get_agentmodule ($id_agent_module); $module = modules_get_agentmodule ($id_agent_module);
if ($module === false) if ($module === false)
@ -635,7 +644,6 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
$repeated_modules[] = $modules_repeated; $repeated_modules[] = $modules_repeated;
} }
else { else {
$result = modules_copy_agent_module_to_agent ($id_agent_module, $result = modules_copy_agent_module_to_agent ($id_agent_module,
$id_destiny_agent); $id_destiny_agent);
@ -694,7 +702,8 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
} }
if ($error) { if ($error) {
echo '<h3 class="error">'.__('There was an error copying the agent configuration, the copy has been cancelled').'</h3>'; ui_print_error_message(
__('There was an error copying the agent configuration, the copy has been cancelled'));
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
@ -704,8 +713,9 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
db_process_sql_rollback(); db_process_sql_rollback();
break; break;
} }
} else { }
echo '<h3 class="suc">'.__('Successfully copied').'</h3>'; else {
ui_print_success_message(__('Successfully copied'));
switch ($config['dbtype']) { switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
@ -725,8 +735,9 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
} }
function agents_get_next_contact($idAgent, $maxModules = false) { function agents_get_next_contact($idAgent, $maxModules = false) {
$agent = db_get_row_sql("SELECT *
$agent = db_get_row_sql("SELECT * FROM tagente WHERE id_agente = " . $idAgent); FROM tagente
WHERE id_agente = " . $idAgent);
$difference = get_system_time () - strtotime ($agent["ultimo_contacto"]); $difference = get_system_time () - strtotime ($agent["ultimo_contacto"]);
@ -734,7 +745,9 @@ function agents_get_next_contact($idAgent, $maxModules = false) {
$max = $agent["intervalo"]; $max = $agent["intervalo"];
if ($maxModules) { if ($maxModules) {
$sql = sprintf ("SELECT MAX(module_interval) FROM tagente_modulo WHERE id_agente = %d", $id_agente); $sql = sprintf ("SELECT MAX(module_interval)
FROM tagente_modulo
WHERE id_agente = %d", $id_agente);
$maxModules = (int) db_get_sql ($sql); $maxModules = (int) db_get_sql ($sql);
if ($maxModules > 0) if ($maxModules > 0)
$max = $maxModules; $max = $maxModules;
@ -1337,6 +1350,7 @@ function agents_get_name ($id_agent, $case = "none") {
case "none": case "none":
default: default:
return ($agent); return ($agent);
break;
} }
} }
@ -1491,7 +1505,8 @@ function agents_add_address ($id_agent, $ip_address) {
function agents_delete_address ($id_agent, $ip_address) { function agents_delete_address ($id_agent, $ip_address) {
global $config; global $config;
$sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress $sql = sprintf ("SELECT id_ag
FROM taddress_agent, taddress
WHERE taddress_agent.id_a = taddress.id_a AND ip = '%s' WHERE taddress_agent.id_a = taddress.id_a AND ip = '%s'
AND id_agent = %d", $ip_address, $id_agent); AND id_agent = %d", $ip_address, $id_agent);
$id_ag = db_get_sql ($sql); $id_ag = db_get_sql ($sql);
@ -1920,7 +1935,8 @@ function agents_tree_view_alert_img ($alert_fired) {
if ($alert_fired) { if ($alert_fired) {
return ui_print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true); return ui_print_status_image (STATUS_ALERT_FIRED, __('Alert fired'), true);
} else { }
else {
return ui_print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true); return ui_print_status_image (STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true);
} }
} }
@ -1942,6 +1958,4 @@ function agetns_tree_view_status_img ($critical, $warning, $unknown) {
return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true); return ui_print_status_image (STATUS_AGENT_OK, __('All Monitors OK'), true);
} }
} }
?> ?>

View File

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

View File

@ -340,7 +340,7 @@ function config_process_config () {
} }
if (!isset ($config["stats_interval"])) { if (!isset ($config["stats_interval"])) {
config_update_value ('stats_interval', 300); config_update_value ('stats_interval', SECONDS_5MINUTES);
} }
if (!isset ($config["realtimestats"])) { if (!isset ($config["realtimestats"])) {
@ -477,7 +477,7 @@ function config_process_config () {
} }
if (!isset ($config['netflow_interval'])) { if (!isset ($config['netflow_interval'])) {
config_update_value ( 'netflow_interval', 300); config_update_value ( 'netflow_interval', SECONDS_5MINUTES);
} }
if (!isset ($config['netflow_daemon'])) { if (!isset ($config['netflow_daemon'])) {

View File

@ -57,7 +57,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$sum_yi2 = 0; $sum_yi2 = 0;
$sum_diff_dates = 0; $sum_diff_dates = 0;
$last_timestamp = get_system_time(); $last_timestamp = get_system_time();
$agent_interval = 300; $agent_interval = SECONDS_5MINUTES;
$cont = 1; $cont = 1;
$data = array(); $data = array();
//$table->data = array(); //$table->data = array();
@ -92,8 +92,6 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$sum_diff_dates = $sum_diff_dates + $data[8]; $sum_diff_dates = $sum_diff_dates + $data[8];
$last_timestamp = $utimestamp; $last_timestamp = $utimestamp;
$cont++; $cont++;
//array_push($table->data, $data);
} }
$cont--; $cont--;
@ -121,7 +119,12 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$linear_coef = $covariance / ($dev_x * $dev_y); $linear_coef = $covariance / ($dev_x * $dev_y);
} }
// Agent interval could be zero, 300 is the predefined // Agent interval could be zero, 300 is the predefined
($sum_obs == 0)? $agent_interval = 300 : $agent_interval = $sum_diff_dates / $sum_obs; if ($sum_obs == 0) {
$agent_interval = SECONDS_5MINUTES;
}
else {
$agent_interval = $sum_diff_dates / $sum_obs;
}
// Could be a inverse correlation coefficient // Could be a inverse correlation coefficient
// if $linear_coef < 0.0 // if $linear_coef < 0.0
@ -141,7 +144,8 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi)); $b_num = (($cont * $sum_xi_yi) - ($sum_xi * $sum_yi));
$b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi)); $b_den = (($cont * $sum_xi2) - ($sum_xi * $sum_xi));
if ($b_den == 0) return; if ($b_den == 0)
return;
$b = $b_num / $b_den; $b = $b_num / $b_den;
$a_num = ($sum_yi) - ($b * $sum_xi); $a_num = ($sum_yi) - ($b * $sum_xi);
@ -160,17 +164,17 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
if ($period < $prediction_period) if ($period < $prediction_period)
$temp_range = $prediction_period; $temp_range = $prediction_period;
if ($temp_range <= 21600) { if ($temp_range <= SECONDS_6HOURS) {
$time_format = 'H:i:s'; $time_format = 'H:i:s';
} }
elseif ($temp_range < 86400) { elseif ($temp_range < SECONDS_1DAY) {
$time_format = 'H:i'; $time_format = 'H:i';
} }
elseif ($temp_range < 1296000) { elseif ($temp_range < SECONDS_15DAYS) {
$time_format = 'M d'; $time_format = 'M d';
$time_format_2 = 'H\h'; $time_format_2 = 'H\h';
} }
elseif ($temp_range <= 2592000) { elseif ($temp_range <= SECONDS_1MONTH) {
$time_format = 'M d'; $time_format = 'M d';
$time_format_2 = 'H\h'; $time_format_2 = 'H\h';
} }
@ -207,7 +211,8 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){ if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]){
return $current_ts; return $current_ts;
} }
}else if ($current_ts > $limit_timestamp){ }
else if ($current_ts > $limit_timestamp) {
$in_range = false; $in_range = false;
} }
$current_ts = $current_ts + $agent_interval; $current_ts = $current_ts + $agent_interval;

View File

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

View File

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

View File

@ -80,11 +80,11 @@ visual_map_print_visual_map ($id_layout, true, true, null, null, '../../');
$values = array (); $values = array ();
$values[5] = human_time_description_raw (5); $values[5] = human_time_description_raw (5);
$values[30] = human_time_description_raw (30); $values[30] = human_time_description_raw (30);
$values[60] = human_time_description_raw (60); $values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE);
$values[120] = human_time_description_raw (120); $values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES);
$values[300] = human_time_description_raw (300); $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
$values[600] = human_time_description_raw (600); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
$values[1800] = human_time_description_raw (1800); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
$table->width = '90%'; $table->width = '90%';
$table->data = array (); $table->data = array ();
@ -134,12 +134,16 @@ $(document).ready (function () {
$("#hidden-vc_refr").val($("#refr option:selected").val()); $("#hidden-vc_refr").val($("#refr option:selected").val());
}); });
<?php if ($config["pure"] && $config["refr"] > 0): ?> <?php
if ($config["pure"] && $config["refr"] > 0) {
?>
t = new Date(); t = new Date();
t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>); t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>);
$("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'}); $("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'});
<?php endif; ?> <?php
}
?>
draw_lines (lines, 'layout_map'); draw_lines (lines, 'layout_map');
}); });
/* ]]> */ /* ]]> */

View File

@ -88,11 +88,11 @@ visual_map_print_visual_map ($id_layout);
$values = array (); $values = array ();
$values[5] = human_time_description_raw (5); $values[5] = human_time_description_raw (5);
$values[30] = human_time_description_raw (30); $values[30] = human_time_description_raw (30);
$values[60] = human_time_description_raw (60); $values[SECONDS_1MINUTE] = human_time_description_raw(SECONDS_1MINUTE);
$values[120] = human_time_description_raw (120); $values[SECONDS_2MINUTES] = human_time_description_raw(SECONDS_2MINUTES);
$values[300] = human_time_description_raw (300); $values[SECONDS_5MINUTES] = human_time_description_raw(SECONDS_5MINUTES);
$values[600] = human_time_description_raw (600); $values[SECONDS_10MINUTES] = human_time_description_raw(SECONDS_10MINUTES);
$values[1800] = human_time_description_raw (1800); $values[SECONDS_30MINUTES] = human_time_description_raw(SECONDS_30MINUTES);
$table->width = '90%'; $table->width = '90%';
$table->data = array (); $table->data = array ();
@ -141,12 +141,16 @@ $(document).ready (function () {
$("#hidden-vc_refr").val($("#refr option:selected").val()); $("#hidden-vc_refr").val($("#refr option:selected").val());
}); });
<?php if ($config["pure"] && $config["refr"] > 0): ?> <?php
if ($config["pure"] && $config["refr"] > 0) {
?>
t = new Date(); t = new Date();
t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>); t.setTime (t.getTime() + <?php echo $config["refr"] * 1000; ?>);
$("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'}); $("#countdown").countdown({until: t, format: 'MS', description: '<?php echo __('Until refresh'); ?>'});
<?php endif; ?> <?php
}
?>
draw_lines (lines, 'layout_map'); draw_lines (lines, 'layout_map');
}); });
/* ]]> */ /* ]]> */