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:
parent
a437aba1c0
commit
23cccf20ed
|
@ -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.
|
||||
|
|
|
@ -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) {
|
||||
|
@ -94,7 +100,7 @@ function mainAgentsAlerts() {
|
|||
$onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen,
|
||||
'combo_groups' => $filter_groups);
|
||||
|
||||
if($config['pure'] == 1) {
|
||||
if ($config['pure'] == 1) {
|
||||
$onheader['combo_refr'] = $comborefr;
|
||||
}
|
||||
|
||||
|
@ -108,22 +114,25 @@ function mainAgentsAlerts() {
|
|||
'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'];
|
||||
}
|
||||
|
||||
|
@ -134,8 +143,8 @@ function mainAgentsAlerts() {
|
|||
|
||||
$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;
|
||||
}
|
||||
|
@ -159,53 +168,54 @@ 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;
|
||||
|
|
|
@ -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) {
|
||||
|
@ -103,7 +109,7 @@ function mainAgentsModules() {
|
|||
'combo_module_groups' => $filter_module_groups,
|
||||
'combo_groups' => $filter_groups);
|
||||
|
||||
if($config['pure'] == 1) {
|
||||
if ($config['pure'] == 1) {
|
||||
$onheader['combo_refr'] = $comborefr;
|
||||
}
|
||||
|
||||
|
@ -114,14 +120,14 @@ function mainAgentsModules() {
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -308,4 +314,3 @@ extensions_add_operation_menu_option(__("Agents/Modules view"), 'estado', 'agent
|
|||
extensions_add_main_function('mainAgentsModules');
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -35,17 +35,20 @@ function users_extension_main_god ($god = true) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
?>
|
||||
|
@ -98,11 +99,11 @@ config_check();
|
|||
echo " ";
|
||||
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&sec2=godmode/servers/modificar_server&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,35 +140,36 @@ 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')) . ' '. __('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'>";
|
||||
?>
|
||||
</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">
|
||||
|
@ -196,26 +197,19 @@ config_check();
|
|||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if ($config["metaconsole"] == 0){
|
||||
if ($config["metaconsole"] == 0){
|
||||
echo '<a class="white_bold" href="index.php?sec=eventos&sec2=operation/events/events">' . html_print_image("images/lightning_go.png", true, array("alt" => 'lightning_go', "class" => 'bot')) . ' '.__('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>
|
|
@ -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",'');
|
||||
|
@ -148,11 +148,11 @@ if ($create_agent) {
|
|||
|
||||
$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'], '');
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,8 @@ if ($create_agent) {
|
|||
$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));
|
||||
}
|
||||
|
@ -220,7 +221,7 @@ if ($id_agente) {
|
|||
. html_print_image ("images/zoom.png", true, array ("title" =>__('View')))
|
||||
. '</a>';
|
||||
|
||||
if($tab == 'view')
|
||||
if ($tab == 'view')
|
||||
$viewtab['active'] = true;
|
||||
else
|
||||
$viewtab['active'] = false;
|
||||
|
@ -229,8 +230,7 @@ if ($id_agente) {
|
|||
$maintab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente.'">'
|
||||
. html_print_image ("images/cog.png", true, array ("title" =>__('Setup')))
|
||||
. '</a>';
|
||||
if($tab == 'main')
|
||||
|
||||
if ($tab == 'main')
|
||||
$maintab['active'] = true;
|
||||
else
|
||||
$maintab['active'] = false;
|
||||
|
@ -250,7 +250,7 @@ if ($id_agente) {
|
|||
. html_print_image ("images/bell.png", true, array ("title" =>__('Alerts')))
|
||||
. '</a>';
|
||||
|
||||
if($tab == 'alert')
|
||||
if ($tab == 'alert')
|
||||
$alerttab['active'] = true;
|
||||
else
|
||||
$alerttab['active'] = false;
|
||||
|
@ -260,7 +260,7 @@ if ($id_agente) {
|
|||
. 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;
|
||||
|
@ -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&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente='.$id_agente.'">'
|
||||
. 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'];
|
||||
|
@ -375,9 +382,10 @@ if ($id_agente) {
|
|||
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:
|
||||
|
@ -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('`','‘',(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,19 +489,19 @@ 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));
|
||||
|
@ -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
|
||||
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
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +581,7 @@ if ($id_agente) {
|
|||
$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) {
|
||||
|
@ -617,7 +628,7 @@ if ($update_module || $create_module) {
|
|||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -674,7 +685,7 @@ if ($update_module || $create_module) {
|
|||
$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');
|
||||
|
@ -691,7 +702,6 @@ 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');
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -768,7 +778,7 @@ if ($update_module) {
|
|||
'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,10 +812,10 @@ 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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -875,8 +883,8 @@ if ($create_module) {
|
|||
'custom_integer_1' => $custom_integer_1,
|
||||
'custom_integer_2' => $custom_integer_2,
|
||||
'min_ff_event' => $ff_event,
|
||||
'unit' => $unit
|
||||
);
|
||||
'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,7 +918,7 @@ 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;
|
||||
|
||||
|
@ -982,12 +989,12 @@ if ($delete_module) { // DELETE agent module !
|
|||
// 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,8 +1003,10 @@ 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));
|
||||
|
@ -1013,11 +1022,11 @@ if ($delete_module) { // DELETE agent 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",
|
||||
|
@ -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;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ 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>';
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'
|
||||
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, $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'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
@ -145,6 +145,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f
|
|||
break;
|
||||
default:
|
||||
$filter .= '';
|
||||
break;
|
||||
}
|
||||
|
||||
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 ($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);
|
||||
|
||||
|
@ -313,27 +316,28 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||
$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
|
||||
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
|
||||
|
@ -341,27 +345,31 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||
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
|
||||
$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
|
||||
$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
|
||||
$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
|
||||
$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
|
||||
|
@ -399,7 +407,6 @@ 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']);
|
||||
}
|
||||
|
@ -472,21 +479,24 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
|
|||
|
||||
// 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;
|
||||
}
|
||||
|
@ -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 ();
|
||||
|
@ -619,7 +629,6 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
|
|||
$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)
|
||||
|
@ -635,7 +644,6 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
|
|||
$repeated_modules[] = $modules_repeated;
|
||||
}
|
||||
else {
|
||||
|
||||
$result = modules_copy_agent_module_to_agent ($id_agent_module,
|
||||
$id_destiny_agent);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1337,6 +1350,7 @@ function agents_get_name ($id_agent, $case = "none") {
|
|||
case "none":
|
||||
default:
|
||||
return ($agent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1505,8 @@ 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);
|
||||
|
@ -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{
|
||||
|
@ -1624,7 +1639,7 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
|
|||
}
|
||||
|
||||
// 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"]) {
|
||||
|
@ -1654,19 +1669,19 @@ function agents_get_status($id_agent = 0, $noACLs = false) {
|
|||
|
||||
// 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 {
|
||||
|
@ -1920,7 +1935,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -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)";
|
||||
}
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ function config_process_config () {
|
|||
}
|
||||
|
||||
if (!isset ($config["stats_interval"])) {
|
||||
config_update_value ('stats_interval', 300);
|
||||
config_update_value ('stats_interval', SECONDS_5MINUTES);
|
||||
}
|
||||
|
||||
if (!isset ($config["realtimestats"])) {
|
||||
|
@ -424,7 +424,7 @@ function config_process_config () {
|
|||
config_update_value ( 'flash_charts', true);
|
||||
}
|
||||
|
||||
if (!isset ($config["custom_logo"])){
|
||||
if (!isset ($config["custom_logo"])) {
|
||||
config_update_value ('custom_logo', 'none.png');
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ function config_process_config () {
|
|||
}
|
||||
|
||||
if (!isset ($config['netflow_interval'])) {
|
||||
config_update_value ( 'netflow_interval', 300);
|
||||
config_update_value ( 'netflow_interval', SECONDS_5MINUTES);
|
||||
}
|
||||
|
||||
if (!isset ($config['netflow_daemon'])) {
|
||||
|
|
|
@ -57,7 +57,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
|
|||
$sum_yi2 = 0;
|
||||
$sum_diff_dates = 0;
|
||||
$last_timestamp = get_system_time();
|
||||
$agent_interval = 300;
|
||||
$agent_interval = SECONDS_5MINUTES;
|
||||
$cont = 1;
|
||||
$data = array();
|
||||
//$table->data = array();
|
||||
|
@ -76,7 +76,7 @@ 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 {
|
||||
|
@ -92,8 +92,6 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
|
|||
$sum_diff_dates = $sum_diff_dates + $data[8];
|
||||
$last_timestamp = $utimestamp;
|
||||
$cont++;
|
||||
|
||||
//array_push($table->data, $data);
|
||||
}
|
||||
|
||||
$cont--;
|
||||
|
@ -117,11 +115,16 @@ 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){
|
||||
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
|
||||
|
@ -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_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);
|
||||
|
@ -149,7 +153,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
|
|||
|
||||
// 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,23 +186,23 @@ 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]);
|
||||
|
@ -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]){
|
||||
return $current_ts;
|
||||
}
|
||||
}else if ($current_ts > $limit_timestamp){
|
||||
}
|
||||
else if ($current_ts > $limit_timestamp) {
|
||||
$in_range = false;
|
||||
}
|
||||
$current_ts = $current_ts + $agent_interval;
|
||||
|
@ -229,7 +234,7 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 +232,7 @@ 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 ";
|
||||
}
|
||||
|
||||
|
@ -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>";
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 <apache user> ".$config["attachment_store"];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 +92,7 @@ $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;
|
||||
}
|
||||
|
@ -134,12 +134,16 @@ $(document).ready (function () {
|
|||
$("#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.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');
|
||||
});
|
||||
/* ]]> */
|
||||
|
|
|
@ -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,7 +100,7 @@ $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;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ $table->data[0][1] = html_print_select ($values, 'refr', $config["vc_refr"], '',
|
|||
$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){
|
||||
if ($vc_refr) {
|
||||
$config["vc_refr"] = 0;
|
||||
}
|
||||
|
||||
|
@ -141,12 +141,16 @@ $(document).ready (function () {
|
|||
$("#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.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');
|
||||
});
|
||||
/* ]]> */
|
||||
|
|
Loading…
Reference in New Issue